Skip to content

Instantly share code, notes, and snippets.

@zapu
Created June 12, 2017 18:17
Show Gist options
  • Save zapu/7ce0576acad346f0237e81d684cd089e to your computer and use it in GitHub Desktop.
Save zapu/7ce0576acad346f0237e81d684cd089e to your computer and use it in GitHub Desktop.
kbpgp = require '../kbpgp'
{Message} = kbpgp.processor
await kbpgp.KeyManager.import_from_armored_pgp {
armored: """-----BEGIN PGP PUBLIC KEY BLOCK-----
mI0EWT7ZgAEEAMzYy+AJehsdFUEbY2hcY32qHe0QaqX/OMm97TGcGx/v1Fvtn3l1
7LnFAe7aDlBn1VnCqnqrU5lDjcY9mep0FuphYvPdoHVydbhxa0hwRr0UcyZ+caRj
yooG7FKmguqlr+yKe7qK13nOGeHcNSCP/1pRh6/IUnt6HIRb+zMBFl7hABEBAAG0
EFJTQSBDcmFzaGVyIFRlc3SItwQTAQgAIQUCWT7ZgAIbAwULCQgHAgYVCAkKCwIE
FgIDAQIeAQIXgAAKCRDkS/dyJqi3NkjtA/42AmG8M2fpnA/JQKuu+Qy0bJtICgqj
qRvjpXJZQCbZViHxCLpACfhqOKMqL/ih+IBR/oW4+LvIzmXu4NcUHydAia0e2Mow
Xw+8gWQLpYyeb1a871KbZY68e5kMxIpXfFi+WLorIiqckbrsRcNXARcd/J280Cid
HWZdi/nF9dGB/LiNBFk+2YABBACsxXQoBbESrMSYXtaBNWmI/ZpPBiPEXfvGcurW
34rOIjNFKtlpMIexzSByHOji7MIcuUdIsPR6feVzFKpBxxlxvGEDbD7ZMjsAP+mq
+3LpTimUraGADCkMUtkM0lazO8QASZ0kyyu5ny4n6/QBDWg65Fnqg+itydTYi5g9
kiY+3QARAQABiJ8EGAEIAAkFAlk+2YACGwwACgkQ5Ev3ciaotzacFgP/YdSeBlkb
UZ8gNS4YZbVrCtwNmR0v6sCmnV2UEkIEvnmhReBQjWk2zEjcQ08PrmVCS5TdN+GL
btbcaXIA33xgPk/BtukdPrtJDsY7MSUaQmQjS8YS2+bGGE94hKFM+PcScgZ+KSyb
Ec91fZC5vIGGtc7fbB8dy1+iOe2mTwkzwcY=
=ZN31
-----END PGP PUBLIC KEY BLOCK-----
"""
}, defer err, mallory, warnings
proc = new Message { keyfetch : mallory }
msg = """-----BEGIN PGP MESSAGE-----
hIwDngMwVxC7skYBBACchO7qwsZijeI3/LeJ0yM7INw2m+mHiRRjU3y0eaEcMO5O
Ehsh6oR5durkChbvBaFomwDL9plm+VtdCkmaGv8rXtubjWUKDZzyZqBjUK0gkzdY
8Sr4DF/VBJOZYZzashSYehatRvP1xmucmy7Fs4O3b6xwHAfMA9hrUKNLIqw5UNJB
Af2rUEQbnmaih0pJAkwEvyziczzWh1qGF1lX2i0/s5X8/dMnaOamRhNd5+WakG/P
KvM54Cs1mx1a8u+Cnc18Pgk=
=ukSg
-----END PGP MESSAGE-----
"""
[err,msg] = kbpgp.armor.decode msg
await proc.parse_and_process msg, defer err, literals
console.log err
console.log literals
@maxtaco
Copy link

maxtaco commented Jun 12, 2017

exports.sigeng_verify_encrypt_msg = (T,cb) ->
  esc = make_esc cb, "sigeng_verify_encrypt_msg"
  armored = """-----BEGIN PGP PUBLIC KEY BLOCK-----

mI0EWT7YPwEEAMpf5t3pNShLAEy1zSnhS9uTZwna5aVFcox5FPHkBHMKCpd7RjJp
R0TfVM+kfvCjJlwpcn/uznVLU9TSsfiikDGo6Rltrj0lTqhz0zRBkwID1D76KhSG
IYtoGO8JvA6OjRFZ31YUzOkdv7EioNHj0wNGhzyojmKtEFiKq7qP8/wNABEBAAG0
KkZvb3IgODgzICh0ZXN0KSA8dGhlbWF4K2Zvb3I4ODNAZ21haWwuY29tPoi4BBMB
AgAiBQJZPtg/AhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRAyPbtU2NuF
vPf5A/4hfMgB2FKbiQTES8Ic4Qmr4FlNh64z+N0rDpmVNGPHUKcg2UbRJx54jV0o
JJ6kWbTW2N5QVVoUZMv5RK1FGYMAhmT8xIJayobDj60ZkP/iiLFkwior8RxBd1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AoprWwBgFd/5jO7QxFAYsK0KB+qYORhPS
mA8E2krlh4qhVzolYazAin4Q4qkbfatHS2UrWH21RlqL4RbbmxFmczCI9nR1BIuG
8vYdAy54Dprka6JavrrBGBlJcf/19REwEoXrid7fJta3fXYQzGVm6cJXlsYAdXUP
5txUdrUsv95jOM2VQxJn1CBlAVtwXRQ41UR476QAO52ShDMrzy1dCSewQIk2nrbZ
rT3tA/jpRZBEamYqXQ67JqNsEqe9nfIn7PszKOoz3PaoLUOAIfIc0/XU6WzfldSS
vog49ozvkIgTtkG+Yu1eHOKc1b1qEBz+9Gn2U6Dxh0F3uLyC30gPNaApCDX+4n1p
bxLxH8ynQ0tN65Nog67RE8zzwhlifWLi4C6nO4ma02rqy/VaBT2BhnTZC6SZfmvQ
KVz0tO9vcnWOkH1nA6iTJPxduAzCxDmVx3XaoVj9LPjajlROyWyMogdnZ5u0vP+l
Kn2YXxcsF30=
=iWKX
-----END PGP MESSAGE-----"""

  await KeyManager.import_from_armored_pgp { armored }, esc defer mallory
  sig_eng = km.make_sig_eng()
  await sig_eng.unbox msg, defer err
  console.log err
  cb()```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment