windows - How to simulate keypress in script? [GPG expert key generation] -


how make batch (or c/c++) script (running gpg command hundreds of times) able simulate following keyboard input (and being intelligent enough wait input asked)?

8
seq
4096
0y
jean dupont

born 1970-01-01 in paris, france
o
correct horse battery staple
correct horse battery staple


i generate myself pgp keypair (for private communication), wish key's short id easy remember, fffffffe example.

short id of pgp key last 8 characters of fingerprint. information, fingerprint of pgp key checksum (historically, sha-1).

my wishes generated pgp key following:

  • its short id (see above) must easy remember.
  • i want key “unusual” have use --expert mode.
    • by default, generated key can both encrypt (e) , sign other people’s keys (c, “cert”), want mine only sign other people’s keys.

okay. so, guess solution getting “custom” key id generate lots of them (beware, believe global entropy gets diminished if that), , choose 1 (like when phone provider allows choose future phone number in list).

what tried

by reading that page in doc, thought use gpg --batch --expert --gen-key gpg-keygen-settings.txt, following settings file:

key-type: rsa key-length: 4096 key-usage: cert name-real: jean dupont name-comment: born 1970-01-01 in paris, france expire-date: 0 passphrase: correct horse battery staple %commit %echo done. 

but not let me create key usage sign other people’s keys (cert). indeed, documentation says (for key-usage) “allowed values ‘encrypt’, ‘sign’, , ‘auth’”. cert default, using blank key-usage field doesn’t work either.

what believe must do

i think way me generate keys settings want, there no solution simulating key generation if real person interactively running gpg’ shell.

here excerpt of must done:

c:\> gpg --gen-key --expert please select kind of key want:    (1) rsa , rsa (default)    (2) dsa , elgamal    (3) dsa (sign only)    (4) rsa (sign only)    (7) dsa (set own capabilities)    (8) rsa (set own capabilities) selection? 8  possible actions rsa key: sign certify encrypt authenticate current allowed actions: sign certify encrypt     (s) toggle sign capability    (e) toggle encrypt capability    (a) toggle authenticate capability    (q) finished  selection?  […]  rsa keys may between 1024 , 4096 bits long. keysize want? (2048) 4096 requested keysize 4096 bits please specify how long key should valid.          0 = key not expire       <n>  = key expires in n days       <n>w = key expires in n weeks       <n>m = key expires in n months       <n>y = key expires in n years key valid for? (0) 0 key not expire @ correct? (y/n) y  need user id identify key; software constructs user id real name, comment , email address in form:     "heinrich heine (der dichter) <heinrichh@duesseldorf.de>"  real name: […] […] 

so, uh. thank much. weird request, know. chuckles

well, didn’t find solution looking (something make run in background, not buggy, etc.)—and still open, personal culture, better solutions , answers.

anyway, here autohotkey script came with. very dirty. coded bit, gave , used autoscriptwriter tool record macro, , adapted code suit needs (haha). annoying thing learn how interact gpg-agent (pinentry).

loop 100 {     run, cmd.exe /k "gpg --expert --gen-key"     winwait, c:\windows\system32\cmd.exe - gpg  --expert --gen-key,      ifwinnotactive, c:\windows\system32\cmd.exe - gpg  --expert --gen-key, , winactivate, c:\windows\system32\cmd.exe - gpg  --expert --gen-key,      winwaitactive, c:\windows\system32\cmd.exe - gpg  --expert --gen-key,       sleep 1500      send +8{enter}     send s{enter}c{enter}q{enter}     send +4+0+9+6{enter}     send +0{enter}o{enter}     send jean dupont{enter}     send {enter}     send born {shift down}1970{shift up}6{shift down}01{shift up}6{shift down}01{shift up} in paris, france{enter}o{enter}     ; "6" keypress above make - on french azerty keyboards.      winwait, pinentry,      ifwinnotactive, pinentry, , winactivate, pinentry,      winwaitactive, pinentry,      send, correct horse battery staple{enter}     sleep 1500     send, correct horse battery staple{enter}     sleep 10000     ;send exit{enter} } 

this little script allowed me bucketload of keys, 1 of having short id like.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -