2018-08-29 03:47:52 +03:00
|
|
|
/- asn1
|
|
|
|
/+ base64, der, tester
|
2018-04-27 23:31:18 +03:00
|
|
|
=, eyre
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
2018-05-25 10:28:26 +03:00
|
|
|
:::: %zuse additions
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
2018-05-25 10:28:26 +03:00
|
|
|
|%
|
|
|
|
:: +en-base64url: url-safe base64 encoding, without padding
|
2018-04-30 19:17:53 +03:00
|
|
|
::
|
2018-05-25 10:28:26 +03:00
|
|
|
++ en-base64url
|
|
|
|
~(en base64 | &)
|
|
|
|
:: +de-base64url: url-safe base64 decoding, without padding
|
2018-04-30 19:17:53 +03:00
|
|
|
::
|
|
|
|
++ de-base64url
|
|
|
|
~(de base64 | &)
|
2018-06-26 08:10:19 +03:00
|
|
|
:: |octn: encode/decode unsigned atoms as big-endian octet stream
|
|
|
|
::
|
|
|
|
++ octn
|
|
|
|
|%
|
|
|
|
++ en |=(a=@u `octs`[(met 3 a) (swp 3 a)])
|
|
|
|
++ de |=(a=octs `@u`(rev 3 p.a q.a))
|
|
|
|
--
|
2018-04-30 19:17:53 +03:00
|
|
|
::
|
2018-05-25 10:28:26 +03:00
|
|
|
:::: %/lib/pkcs
|
|
|
|
::
|
|
|
|
:: |rsa: primitive, textbook RSA
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: Unpadded, unsafe, unsuitable for encryption!
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
++ rsa
|
|
|
|
|%
|
|
|
|
:: +key:rsa: rsa public or private key
|
|
|
|
::
|
2018-05-16 22:38:50 +03:00
|
|
|
+= key
|
2018-05-25 10:28:26 +03:00
|
|
|
$: :: pub: public parameters (n=modulus, e=pub-exponent)
|
2018-05-28 08:57:58 +03:00
|
|
|
::
|
2018-05-25 10:28:26 +03:00
|
|
|
pub=[n=@ux e=@ux]
|
|
|
|
:: sek: secret parameters (d=private-exponent, p/q=primes)
|
2018-05-28 08:57:58 +03:00
|
|
|
::
|
2018-05-16 22:38:50 +03:00
|
|
|
sek=(unit [d=@ux p=@ux q=@ux])
|
|
|
|
==
|
2018-06-26 18:24:42 +03:00
|
|
|
:: +ramp: make rabin-miller probabilistic prime
|
|
|
|
::
|
|
|
|
:: XX replace +ramp:number?
|
|
|
|
:: a: bitwidth
|
|
|
|
:: b: snags (XX small primes to check divisibility?)
|
|
|
|
:: c: entropy
|
|
|
|
::
|
|
|
|
++ ramp
|
|
|
|
|= [a=@ b=(list @) c=@]
|
|
|
|
=. c (shas %ramp c)
|
|
|
|
:: XX what is this value?
|
|
|
|
::
|
|
|
|
=| d=@
|
|
|
|
|- ^- @ux
|
|
|
|
:: XX what is this condition?
|
|
|
|
::
|
|
|
|
?: =((mul 100 a) d)
|
|
|
|
~|(%ar-ramp !!)
|
|
|
|
:: e: prime candidate
|
|
|
|
::
|
|
|
|
:: Sets low bit, as prime must be odd.
|
|
|
|
:: Sets high bit, as +raw:og only gives up to :a bits.
|
|
|
|
::
|
|
|
|
=/ e :(con 1 (lsh 0 (dec a) 1) (~(raw og c) a))
|
|
|
|
:: XX what algorithm is this modular remainder check?
|
|
|
|
::
|
|
|
|
?: ?& (levy b |=(f/@ !=(1 (mod e f))))
|
|
|
|
(pram:number e)
|
|
|
|
==
|
|
|
|
e
|
|
|
|
$(c +(c), d (shax d))
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +elcm:rsa: carmichael totient
|
|
|
|
::
|
|
|
|
++ elcm
|
2018-04-30 21:53:58 +03:00
|
|
|
|= [a=@ b=@]
|
|
|
|
(div (mul a b) d:(egcd a b))
|
2018-05-28 08:57:58 +03:00
|
|
|
:: +new-key:rsa: write somethingXXX
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
++ new-key
|
2018-04-30 21:53:58 +03:00
|
|
|
=/ e `@ux`65.537
|
|
|
|
|= [wid=@ eny=@]
|
|
|
|
^- key
|
|
|
|
=/ diw (rsh 0 1 wid)
|
2018-06-26 18:24:42 +03:00
|
|
|
=/ p=@ux (ramp diw [3 5 ~] eny)
|
|
|
|
=/ q=@ux (ramp diw [3 5 ~] +(eny))
|
2018-04-30 21:53:58 +03:00
|
|
|
=/ n=@ux (mul p q)
|
|
|
|
=/ d=@ux (~(inv fo (elcm (dec p) (dec q))) e)
|
2018-05-16 22:38:50 +03:00
|
|
|
[[n e] `[d p q]]
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +en:rsa: primitive RSA encryption
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: ciphertext = message^e (mod n)
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
++ en
|
2018-04-30 21:53:58 +03:00
|
|
|
|= [m=@ k=key]
|
|
|
|
~| %rsa-len
|
2018-05-16 22:38:50 +03:00
|
|
|
?> (lte (met 0 m) (met 0 n.pub.k))
|
|
|
|
(~(exp fo n.pub.k) e.pub.k m)
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +de:rsa: primitive RSA decryption
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: message = ciphertext^d (mod e)
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
2018-05-26 00:14:40 +03:00
|
|
|
++ de
|
2018-04-30 21:53:58 +03:00
|
|
|
|= [m=@ k=key]
|
|
|
|
:: XX assert rsa-len here too?
|
2018-05-16 22:38:50 +03:00
|
|
|
~| %rsa-need-ring
|
|
|
|
?> ?=(^ sek.k)
|
|
|
|
=/ fu (fu:number p.u.sek.k q.u.sek.k)
|
|
|
|
(out.fu (exp.fu d.u.sek.k (sit.fu m)))
|
2018-04-30 21:53:58 +03:00
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +rs256: RSA signatures over a sha-256 digest
|
|
|
|
::
|
|
|
|
++ rs256
|
2018-04-19 09:27:55 +03:00
|
|
|
|_ k=key:rsa
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +emsa:rs256: message digest
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: Padded, DER encoded sha-256 hash (EMSA-PKCS1-v1_5).
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
++ emsa
|
2018-04-28 06:52:52 +03:00
|
|
|
|= m=@
|
2018-05-16 22:38:50 +03:00
|
|
|
=/ emlen (met 3 n.pub.k)
|
2018-04-28 06:52:52 +03:00
|
|
|
=/ pec=spec:asn1
|
|
|
|
:~ %seq
|
|
|
|
[%seq [%obj sha-256:obj:asn1] [%nul ~] ~]
|
2018-06-25 21:08:15 +03:00
|
|
|
[%oct 32 (shax m)]
|
2018-04-28 06:52:52 +03:00
|
|
|
==
|
2018-06-27 19:57:44 +03:00
|
|
|
:: note: this asn.1 digest is rendered raw here, as we require
|
|
|
|
:: big-endian bytes, and the product of +en:der is little-endian
|
|
|
|
::
|
|
|
|
=/ t=(list @D) ~(ren raw:en:der pec)
|
|
|
|
=/ tlen=@ud (lent t)
|
2018-05-08 21:02:56 +03:00
|
|
|
?: (lth emlen (add 11 tlen))
|
|
|
|
~|(%emsa-too-short !!)
|
2018-06-27 19:57:44 +03:00
|
|
|
=/ ps=(list @D)
|
|
|
|
(reap (sub emlen (add 3 tlen)) 0xff)
|
|
|
|
(rep 3 (flop (weld [0x0 0x1 ps] [0x0 t])))
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +sign:rs256: sign message
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: An RSA signature is the primitive decryption of the message hash.
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
++ sign
|
|
|
|
|=(m=@ (de:rsa (emsa m) k))
|
|
|
|
:: +verify:rs256: verify signature
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: RSA signature verification confirms that the primitive encryption
|
|
|
|
:: of the signature matches the message hash.
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
++ verify
|
2018-04-19 09:27:55 +03:00
|
|
|
|= [s=@ m=@]
|
2018-05-08 21:02:56 +03:00
|
|
|
=((emsa m) (en:rsa s k))
|
2018-04-19 09:27:55 +03:00
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
:: |pem: generic PEM implementation (rfc7468)
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: PEM is the base64 encoding of DER encoded data, with BEGIN and
|
|
|
|
:: END labels indicating some type.
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
++ pem
|
|
|
|
|%
|
|
|
|
:: +en:pem: PEM encode
|
|
|
|
::
|
|
|
|
++ en
|
2018-06-26 08:10:19 +03:00
|
|
|
|= [lab=@t len=@ud der=@ux]
|
2018-05-17 08:40:22 +03:00
|
|
|
^- wain
|
|
|
|
:: XX validate label?
|
|
|
|
:- (rap 3 ['-----BEGIN ' lab '-----' ~])
|
2018-06-26 08:10:19 +03:00
|
|
|
=/ a (en:base64 len `@`der)
|
2018-05-17 08:40:22 +03:00
|
|
|
|- ^- wain
|
|
|
|
?~ a
|
|
|
|
[(rap 3 ['-----END ' lab '-----' ~]) ~]
|
|
|
|
[(end 3 64 a) $(a (rsh 3 64 a))]
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +de:pem: PEM decode
|
|
|
|
::
|
|
|
|
++ de
|
2018-05-17 08:40:22 +03:00
|
|
|
|= [lab=@t mep=wain]
|
2018-06-26 08:10:19 +03:00
|
|
|
^- (unit [len=@ud der=@ux])
|
2018-05-17 08:40:22 +03:00
|
|
|
=/ a (sub (lent mep) 2)
|
|
|
|
?~ mep ~
|
|
|
|
:: XX validate label?
|
|
|
|
?. =((rap 3 ['-----BEGIN ' lab '-----' ~]) i.mep) ~
|
|
|
|
?. =((rap 3 ['-----END ' lab '-----' ~]) (snag a t.mep)) ~
|
2018-06-26 10:21:32 +03:00
|
|
|
^- (unit [@ @])
|
2018-05-17 08:40:22 +03:00
|
|
|
(de:base64 (rap 3 (scag a t.mep)))
|
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
:: |pkcs1: RSA asymmetric cryptography (rfc3447)
|
|
|
|
::
|
|
|
|
++ pkcs1
|
|
|
|
|%
|
|
|
|
:: |spec:pkcs1: ASN.1 specs for RSA keys
|
|
|
|
::
|
2018-05-17 08:40:22 +03:00
|
|
|
++ spec
|
|
|
|
|%
|
2018-05-25 21:45:16 +03:00
|
|
|
:: |en:spec:pkcs1: ASN.1 encoding for RSA keys
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
2018-05-25 21:45:16 +03:00
|
|
|
++ en
|
|
|
|
|%
|
|
|
|
:: +pass:en:spec:pkcs1: encode public key to ASN.1
|
|
|
|
::
|
|
|
|
++ pass
|
|
|
|
|= k=key:rsa
|
|
|
|
^- spec:asn1
|
|
|
|
[%seq [%int n.pub.k] [%int e.pub.k] ~]
|
|
|
|
:: +ring:en:spec:pkcs1: encode private key to ASN.1
|
|
|
|
::
|
|
|
|
++ ring
|
|
|
|
|= k=key:rsa
|
|
|
|
^- spec:asn1
|
|
|
|
~| %rsa-need-ring
|
|
|
|
?> ?=(^ sek.k)
|
|
|
|
:~ %seq
|
|
|
|
[%int 0]
|
|
|
|
[%int n.pub.k]
|
|
|
|
[%int e.pub.k]
|
|
|
|
[%int d.u.sek.k]
|
|
|
|
[%int p.u.sek.k]
|
|
|
|
[%int q.u.sek.k]
|
|
|
|
[%int (mod d.u.sek.k (dec p.u.sek.k))]
|
|
|
|
[%int (mod d.u.sek.k (dec q.u.sek.k))]
|
|
|
|
[%int (~(inv fo p.u.sek.k) q.u.sek.k)]
|
|
|
|
==
|
|
|
|
--
|
|
|
|
:: |de:spec:pkcs1: ASN.1 decoding for RSA keys
|
2018-05-17 08:40:22 +03:00
|
|
|
::
|
2018-05-25 21:45:16 +03:00
|
|
|
++ de
|
|
|
|
|%
|
|
|
|
:: +pass:de:spec:pkcs1: decode ASN.1 public key
|
|
|
|
::
|
|
|
|
++ pass
|
|
|
|
|= a=spec:asn1
|
|
|
|
^- (unit key:rsa)
|
|
|
|
?. ?=([%seq [%int *] [%int *] ~] a)
|
|
|
|
~
|
|
|
|
=* n int.i.seq.a
|
|
|
|
=* e int.i.t.seq.a
|
|
|
|
`[[n e] ~]
|
|
|
|
:: +ring:de:spec:pkcs1: decode ASN.1 private key
|
|
|
|
::
|
|
|
|
++ ring
|
|
|
|
|= a=spec:asn1
|
|
|
|
^- (unit key:rsa)
|
|
|
|
?. ?=([%seq *] a) ~
|
|
|
|
?. ?= $: [%int %0]
|
|
|
|
[%int *]
|
|
|
|
[%int *]
|
|
|
|
[%int *]
|
|
|
|
[%int *]
|
|
|
|
[%int *]
|
|
|
|
*
|
|
|
|
==
|
|
|
|
seq.a
|
|
|
|
~
|
|
|
|
=* n int.i.t.seq.a
|
|
|
|
=* e int.i.t.t.seq.a
|
|
|
|
=* d int.i.t.t.t.seq.a
|
|
|
|
=* p int.i.t.t.t.t.seq.a
|
|
|
|
=* q int.i.t.t.t.t.t.seq.a
|
|
|
|
`[[n e] `[d p q]]
|
|
|
|
--
|
2018-05-17 08:40:22 +03:00
|
|
|
--
|
2018-05-26 00:14:40 +03:00
|
|
|
:: |der:pkcs1: DER encoding for RSA keys
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: En(coding) and de(coding) for public (pass) and private (ring) keys.
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
++ der
|
|
|
|
|%
|
|
|
|
++ en
|
2018-05-17 08:40:22 +03:00
|
|
|
|%
|
2018-06-26 08:10:19 +03:00
|
|
|
++ pass |=(k=key:rsa (en:^der (pass:en:spec k)))
|
|
|
|
++ ring |=(k=key:rsa (en:^der (ring:en:spec k)))
|
2018-05-17 08:40:22 +03:00
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
++ de
|
2018-05-11 06:13:30 +03:00
|
|
|
|%
|
2018-06-26 08:10:19 +03:00
|
|
|
++ pass |=([len=@ud dat=@ux] `(unit key:rsa)`(biff (de:^der len dat) pass:de:spec))
|
|
|
|
++ ring |=([len=@ud dat=@ux] `(unit key:rsa)`(biff (de:^der len dat) ring:de:spec))
|
2018-05-17 08:40:22 +03:00
|
|
|
--
|
|
|
|
--
|
2018-05-26 00:14:40 +03:00
|
|
|
:: |pem:pkcs1: PEM encoding for RSA keys
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: En(coding) and de(coding) for public (pass) and private (ring) keys.
|
2018-05-17 08:40:22 +03:00
|
|
|
::
|
|
|
|
++ pem
|
|
|
|
|%
|
2018-05-25 10:28:26 +03:00
|
|
|
++ en
|
2018-05-17 08:40:22 +03:00
|
|
|
|%
|
|
|
|
++ pass |=(k=key:rsa (en:^pem 'RSA PUBLIC KEY' (pass:en:der k)))
|
|
|
|
++ ring |=(k=key:rsa (en:^pem 'RSA PRIVATE KEY' (ring:en:der k)))
|
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
++ de
|
2018-05-17 08:40:22 +03:00
|
|
|
|%
|
|
|
|
++ pass |=(mep=wain (biff (de:^pem 'RSA PUBLIC KEY' mep) pass:de:der))
|
|
|
|
++ ring |=(mep=wain (biff (de:^pem 'RSA PRIVATE KEY' mep) ring:de:der))
|
|
|
|
--
|
|
|
|
--
|
|
|
|
--
|
2018-06-27 08:15:35 +03:00
|
|
|
:: |pkcs8: asymmetric cryptography (rfc5208, rfc5958)
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: RSA-only for now.
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
++ pkcs8
|
|
|
|
|%
|
|
|
|
:: |spec:pkcs8: ASN.1 specs for asymmetric keys
|
|
|
|
::
|
2018-05-17 08:40:22 +03:00
|
|
|
++ spec
|
2018-05-25 10:28:26 +03:00
|
|
|
|%
|
|
|
|
++ en
|
2018-05-17 08:40:22 +03:00
|
|
|
|%
|
2018-05-26 00:14:40 +03:00
|
|
|
:: +pass:spec:pkcs8: public key ASN.1
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
2018-06-27 08:15:35 +03:00
|
|
|
:: Technically not part of pkcs8, but standardized later in
|
|
|
|
:: the superseding RFC. Included here for symmetry.
|
|
|
|
::
|
2018-05-25 10:28:26 +03:00
|
|
|
++ pass
|
2018-05-26 00:14:40 +03:00
|
|
|
|= k=key:rsa
|
|
|
|
^- spec:asn1
|
|
|
|
:~ %seq
|
|
|
|
[%seq [[%obj rsa:obj:asn1] [%nul ~] ~]]
|
2018-06-26 21:29:42 +03:00
|
|
|
=/ a=[len=@ud dat=@ux]
|
|
|
|
(pass:en:der:pkcs1 k)
|
|
|
|
[%bit (mul 8 len.a) dat.a]
|
2018-05-26 00:14:40 +03:00
|
|
|
==
|
|
|
|
:: +ring:spec:pkcs8: private key ASN.1
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
2018-06-27 08:15:35 +03:00
|
|
|
++ ring
|
|
|
|
|= k=key:rsa
|
|
|
|
^- spec:asn1
|
|
|
|
:~ %seq
|
2018-07-16 19:27:29 +03:00
|
|
|
[%int 0]
|
2018-06-27 08:15:35 +03:00
|
|
|
[%seq [[%obj rsa:obj:asn1] [%nul ~] ~]]
|
|
|
|
[%oct (ring:en:der:pkcs1 k)]
|
|
|
|
==
|
2018-05-11 06:13:30 +03:00
|
|
|
--
|
2018-06-27 08:15:35 +03:00
|
|
|
:: |de:spec:pkcs8: ASN.1 decoding for asymmetric keys
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
++ de
|
2018-05-11 06:13:30 +03:00
|
|
|
|%
|
2018-06-27 08:15:35 +03:00
|
|
|
:: +pass:de:spec:pkcs8: decode public key ASN.1
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
2018-05-17 08:40:22 +03:00
|
|
|
++ pass
|
2018-05-26 00:14:40 +03:00
|
|
|
|= a=spec:asn1
|
2018-05-17 08:40:22 +03:00
|
|
|
^- (unit key:rsa)
|
2018-05-26 00:14:40 +03:00
|
|
|
?. ?=([%seq [%seq *] [%bit *] ~] a)
|
2018-05-17 08:40:22 +03:00
|
|
|
~
|
2018-05-26 00:14:40 +03:00
|
|
|
?. ?& ?=([[%obj *] [%nul ~] ~] seq.i.seq.a)
|
|
|
|
=(rsa:obj:asn1 obj.i.seq.i.seq.a)
|
2018-05-17 08:40:22 +03:00
|
|
|
==
|
|
|
|
~
|
2018-06-26 21:29:42 +03:00
|
|
|
(pass:de:der:pkcs1 (div len.i.t.seq.a 8) bit.i.t.seq.a)
|
2018-06-27 08:15:35 +03:00
|
|
|
:: +ring:de:spec:pkcs8: decode private key ASN.1
|
2018-05-11 06:13:30 +03:00
|
|
|
::
|
2018-06-27 08:15:35 +03:00
|
|
|
++ ring
|
|
|
|
|= a=spec:asn1
|
|
|
|
^- (unit key:rsa)
|
2018-07-16 19:27:29 +03:00
|
|
|
?. ?=([%seq [%int %0] [%seq *] [%oct *] ~] a)
|
2018-06-27 08:15:35 +03:00
|
|
|
~
|
2018-07-16 19:27:29 +03:00
|
|
|
?. ?& ?=([[%obj *] [%nul ~] ~] seq.i.t.seq.a)
|
|
|
|
=(rsa:obj:asn1 obj.i.seq.i.t.seq.a)
|
2018-06-27 08:15:35 +03:00
|
|
|
==
|
|
|
|
~
|
2018-07-16 19:27:29 +03:00
|
|
|
(ring:de:der:pkcs1 [len oct]:i.t.t.seq.a)
|
2018-05-11 06:13:30 +03:00
|
|
|
--
|
|
|
|
--
|
2018-05-26 00:14:40 +03:00
|
|
|
:: |der:pkcs8: DER encoding for asymmetric keys
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: En(coding) and de(coding) for public (pass) and private (ring) keys.
|
|
|
|
:: RSA-only for now.
|
2018-05-26 00:14:40 +03:00
|
|
|
::
|
|
|
|
++ der
|
|
|
|
|%
|
|
|
|
++ en
|
|
|
|
|%
|
2018-06-26 08:10:19 +03:00
|
|
|
++ pass |=(k=key:rsa `[len=@ud dat=@ux]`(en:^der (pass:en:spec k)))
|
2018-06-27 08:15:35 +03:00
|
|
|
++ ring |=(k=key:rsa `[len=@ud dat=@ux]`(en:^der (ring:en:spec k)))
|
2018-05-26 00:14:40 +03:00
|
|
|
--
|
|
|
|
++ de
|
|
|
|
|%
|
2018-06-26 08:10:19 +03:00
|
|
|
++ pass |=([len=@ud dat=@ux] `(unit key:rsa)`(biff (de:^der len dat) pass:de:spec))
|
2018-06-27 08:15:35 +03:00
|
|
|
++ ring |=([len=@ud dat=@ux] `(unit key:rsa)`(biff (de:^der len dat) ring:de:spec))
|
2018-05-26 00:14:40 +03:00
|
|
|
--
|
|
|
|
--
|
|
|
|
:: |pem:pkcs8: PEM encoding for asymmetric keys
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: En(coding) and de(coding) for public (pass) and private (ring) keys.
|
|
|
|
:: RSA-only for now.
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
++ pem
|
|
|
|
|%
|
|
|
|
++ en
|
2018-05-11 06:13:30 +03:00
|
|
|
|%
|
2018-05-26 00:14:40 +03:00
|
|
|
++ pass |=(k=key:rsa (en:^pem 'PUBLIC KEY' (pass:en:der k)))
|
2018-06-27 08:15:35 +03:00
|
|
|
++ ring |=(k=key:rsa (en:^pem 'PRIVATE KEY' (ring:en:der k)))
|
2018-05-11 06:13:30 +03:00
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
++ de
|
2018-05-11 06:13:30 +03:00
|
|
|
|%
|
2018-05-26 00:14:40 +03:00
|
|
|
++ pass |=(mep=wain (biff (de:^pem 'PUBLIC KEY' mep) pass:de:der))
|
2018-06-27 08:15:35 +03:00
|
|
|
++ ring |=(mep=wain (biff (de:^pem 'PRIVATE KEY' mep) ring:de:der))
|
2018-05-11 06:13:30 +03:00
|
|
|
--
|
|
|
|
--
|
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
:: |pkcs10: certificate signing requests (rfc2986)
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: Only implemented for RSA keys with subject-alternate names.
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
++ pkcs10
|
|
|
|
=> |%
|
2018-05-25 21:45:16 +03:00
|
|
|
:: +csr:pkcs10: certificate request
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
2018-05-18 01:10:24 +03:00
|
|
|
+= csr [key=key:rsa hot=(list (list @t))]
|
2018-05-17 08:40:22 +03:00
|
|
|
--
|
2018-05-11 07:53:10 +03:00
|
|
|
|%
|
2018-05-25 10:28:26 +03:00
|
|
|
:: |spec:pkcs10: ASN.1 specs for certificate signing requests
|
2018-05-25 21:45:16 +03:00
|
|
|
::
|
2018-05-17 08:40:22 +03:00
|
|
|
++ spec
|
2018-05-25 10:28:26 +03:00
|
|
|
|%
|
2018-05-26 00:14:40 +03:00
|
|
|
:: +en:spec:pkcs10: ASN.1 encoding for certificate signing requests
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
2018-05-25 21:45:16 +03:00
|
|
|
++ en
|
2018-05-26 00:14:40 +03:00
|
|
|
|= csr
|
|
|
|
^- spec:asn1
|
|
|
|
|^ =/ dat=spec:asn1 (info key hot)
|
|
|
|
:~ %seq
|
|
|
|
dat
|
|
|
|
[%seq [[%obj rsa-sha-256:obj:asn1] [%nul ~] ~]]
|
2018-06-26 21:29:42 +03:00
|
|
|
:: big-endian signature bits
|
|
|
|
::
|
|
|
|
:: the signature bitwidth is definitionally the key length
|
|
|
|
::
|
|
|
|
:+ %bit
|
|
|
|
(met 0 n.pub.key)
|
|
|
|
(swp 3 (~(sign rs256 key) +:(en:^der dat)))
|
2018-05-26 00:14:40 +03:00
|
|
|
==
|
|
|
|
:: +info:en:spec:pkcs10: certificate request info
|
2018-05-25 21:45:16 +03:00
|
|
|
::
|
2018-05-26 00:14:40 +03:00
|
|
|
++ info
|
2018-05-25 21:45:16 +03:00
|
|
|
|= csr
|
|
|
|
^- spec:asn1
|
2018-05-26 00:14:40 +03:00
|
|
|
:~ %seq
|
|
|
|
[%int 0]
|
|
|
|
[%seq ~]
|
|
|
|
(pass:en:spec:pkcs8 key)
|
2018-06-27 00:53:07 +03:00
|
|
|
:: explicit, context-specific tag #0 (extensions)
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:+ %con
|
|
|
|
`bespoke:asn1`[| 0]
|
|
|
|
%~ ren
|
|
|
|
raw:en:^der
|
2018-05-25 21:45:16 +03:00
|
|
|
:~ %seq
|
2018-05-26 00:14:40 +03:00
|
|
|
[%obj csr-ext:obj:asn1]
|
|
|
|
:~ %set
|
|
|
|
:~ %seq
|
|
|
|
:~ %seq
|
|
|
|
[%obj sub-alt:obj:asn1]
|
2018-06-26 08:10:19 +03:00
|
|
|
[%oct (en:^der (san hot))]
|
2018-05-26 00:14:40 +03:00
|
|
|
== == == == ==
|
|
|
|
:: +san:en:spec:pkcs10: subject-alternate-names
|
|
|
|
::
|
|
|
|
++ san
|
|
|
|
|= hot=(list (list @t))
|
|
|
|
^- spec:asn1
|
|
|
|
:- %seq
|
|
|
|
%+ turn hot
|
|
|
|
:: implicit, context-specific tag #2 (IA5String)
|
|
|
|
:: XX sanitize string?
|
2018-05-28 08:57:58 +03:00
|
|
|
|=(h=(list @t) [%con `bespoke:asn1`[& 2] (rip 3 (join '.' h))])
|
2018-05-25 21:45:16 +03:00
|
|
|
--
|
|
|
|
:: |de:spec:pkcs10: ASN.1 decoding for certificate signing requests
|
|
|
|
++ de !!
|
2018-05-17 08:40:22 +03:00
|
|
|
--
|
2018-05-26 00:14:40 +03:00
|
|
|
:: |der:pkcs10: DER encoding for certificate signing requests
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
2018-05-17 08:40:22 +03:00
|
|
|
++ der
|
|
|
|
|%
|
2018-06-26 08:10:19 +03:00
|
|
|
++ en |=(a=csr `[len=@ud der=@ux]`(en:^der (en:spec a)))
|
2018-05-26 00:14:40 +03:00
|
|
|
++ de !! ::|=(a=@ `(unit csr)`(biff (de:^der a) de:spec))
|
2018-05-11 07:53:10 +03:00
|
|
|
--
|
2018-05-26 00:14:40 +03:00
|
|
|
:: |pem:pkcs10: PEM encoding for certificate signing requests
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
2018-05-11 07:53:10 +03:00
|
|
|
++ pem
|
|
|
|
|%
|
2018-05-26 00:14:40 +03:00
|
|
|
++ en |=(a=csr (en:^pem 'CERTIFICATE REQUEST' (en:der a)))
|
|
|
|
++ de !! ::|=(mep=wain (biff (de:^pem 'CERTIFICATE REQUEST' mep) de:der))
|
2018-05-11 07:53:10 +03:00
|
|
|
--
|
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +en-json-sort: json encoding with sorted object keys
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: to be included in %zuse, with sorting optional?
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
++ en-json-sort :: XX rename
|
|
|
|
|^ |=([sor=$-(^ ?) val=json] (apex val sor ""))
|
2018-04-19 09:27:55 +03:00
|
|
|
:: :: ++apex:en-json:html
|
|
|
|
++ apex
|
|
|
|
=, en-json:html
|
|
|
|
|= {val/json sor/$-(^ ?) rez/tape}
|
|
|
|
^- tape
|
|
|
|
?~ val (weld "null" rez)
|
|
|
|
?- -.val
|
|
|
|
$a
|
|
|
|
:- '['
|
|
|
|
=. rez [']' rez]
|
|
|
|
!.
|
|
|
|
?~ p.val rez
|
|
|
|
|-
|
|
|
|
?~ t.p.val ^$(val i.p.val)
|
|
|
|
^$(val i.p.val, rez [',' $(p.val t.p.val)])
|
|
|
|
::
|
|
|
|
$b (weld ?:(p.val "true" "false") rez)
|
|
|
|
$n (weld (trip p.val) rez)
|
|
|
|
$s
|
|
|
|
:- '"'
|
|
|
|
=. rez ['"' rez]
|
|
|
|
=+ viz=(trip p.val)
|
|
|
|
!.
|
|
|
|
|- ^- tape
|
|
|
|
?~ viz rez
|
|
|
|
=+ hed=(jesc i.viz)
|
|
|
|
?: ?=({@ $~} hed)
|
|
|
|
[i.hed $(viz t.viz)]
|
|
|
|
(weld hed $(viz t.viz))
|
|
|
|
::
|
|
|
|
$o
|
|
|
|
:- '{'
|
|
|
|
=. rez ['}' rez]
|
|
|
|
=/ viz
|
|
|
|
%+ sort ~(tap by p.val)
|
|
|
|
|=((pair) (sor (head p) (head q)))
|
|
|
|
?~ viz rez
|
|
|
|
!.
|
|
|
|
|- ^+ rez
|
|
|
|
?~ t.viz ^$(val [%s p.i.viz], rez [':' ^$(val q.i.viz)])
|
|
|
|
=. rez [',' $(viz t.viz)]
|
|
|
|
^$(val [%s p.i.viz], rez [':' ^$(val q.i.viz)])
|
|
|
|
==
|
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
:: %/lib/jose
|
|
|
|
::
|
|
|
|
:: |jwk: json representations of cryptographic keys (rfc7517)
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: Url-safe base64 encoding of key parameters in big-endian byte order.
|
|
|
|
:: RSA-only for now
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
++ jwk
|
|
|
|
|%
|
|
|
|
:: |en:jwk: encoding of json cryptographic keys
|
|
|
|
::
|
2018-05-09 07:03:51 +03:00
|
|
|
++ en
|
2018-06-26 19:22:48 +03:00
|
|
|
=> |%
|
|
|
|
:: +numb:en:jwk: base64-url encode big-endian number
|
|
|
|
::
|
|
|
|
++ numb (corl en-base64url en:octn)
|
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
|%
|
|
|
|
:: +pass:en:jwk: json encode public key
|
|
|
|
::
|
|
|
|
++ pass
|
2018-05-09 07:03:51 +03:00
|
|
|
|= k=key:rsa
|
|
|
|
^- json
|
2018-06-26 19:22:48 +03:00
|
|
|
[%o (my kty+s+'RSA' n+s+(numb n.pub.k) e+s+(numb e.pub.k) ~)]
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +ring:en:jwk: json encode private key
|
|
|
|
::
|
|
|
|
++ ring
|
2018-05-09 20:45:39 +03:00
|
|
|
|= k=key:rsa
|
|
|
|
^- json
|
2018-05-16 22:38:50 +03:00
|
|
|
~| %rsa-need-ring
|
|
|
|
?> ?=(^ sek.k)
|
2018-05-09 20:45:39 +03:00
|
|
|
:- %o %- my :~
|
|
|
|
kty+s+'RSA'
|
2018-06-26 19:22:48 +03:00
|
|
|
n+s+(numb n.pub.k)
|
|
|
|
e+s+(numb e.pub.k)
|
|
|
|
d+s+(numb d.u.sek.k)
|
|
|
|
p+s+(numb p.u.sek.k)
|
|
|
|
q+s+(numb q.u.sek.k)
|
2018-05-09 20:45:39 +03:00
|
|
|
==
|
2018-05-09 07:03:51 +03:00
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
:: |de:jwk: decoding of json cryptographic keys
|
|
|
|
::
|
2018-05-09 07:03:51 +03:00
|
|
|
++ de
|
2018-06-26 19:22:48 +03:00
|
|
|
=, dejs-soft:format
|
|
|
|
=> |%
|
|
|
|
:: +numb:de:jwk: parse base64-url big-endian number
|
|
|
|
::
|
|
|
|
++ numb (cu (cork de-base64url (lift de:octn)) so)
|
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
|%
|
|
|
|
:: +pass:de:jwk: decode json public key
|
|
|
|
::
|
2018-05-26 00:14:40 +03:00
|
|
|
++ pass
|
2018-05-09 07:03:51 +03:00
|
|
|
%+ ci
|
2018-06-26 19:22:48 +03:00
|
|
|
=/ a (unit @ux)
|
|
|
|
|= [kty=@t n=a e=a]
|
2018-05-16 22:38:50 +03:00
|
|
|
^- (unit key:rsa)
|
2018-06-26 19:22:48 +03:00
|
|
|
=/ pub (both n e)
|
2018-05-16 22:38:50 +03:00
|
|
|
?~(pub ~ `[u.pub ~])
|
2018-06-26 19:22:48 +03:00
|
|
|
(ot kty+(su (jest 'RSA')) n+numb e+numb ~)
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +ring:de:jwk: decode json private key
|
|
|
|
::
|
|
|
|
++ ring
|
2018-05-09 20:45:39 +03:00
|
|
|
%+ ci
|
2018-06-26 19:22:48 +03:00
|
|
|
=/ a (unit @ux)
|
|
|
|
|= [kty=@t n=a e=a d=a p=a q=a]
|
2018-05-09 20:45:39 +03:00
|
|
|
^- (unit key:rsa)
|
2018-06-26 19:22:48 +03:00
|
|
|
=/ pub (both n e)
|
|
|
|
=/ sek :(both d p q)
|
2018-05-16 22:38:50 +03:00
|
|
|
?:(|(?=(~ pub) ?=(~ sek)) ~ `[u.pub sek])
|
2018-06-26 19:22:48 +03:00
|
|
|
(ot kty+(su (jest 'RSA')) n+numb e+numb d+numb p+numb q+numb ~)
|
2018-05-09 07:03:51 +03:00
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
:: |thumb:jwk: "thumbprint" json-encoded key (rfc7638)
|
|
|
|
::
|
|
|
|
++ thumb
|
|
|
|
|%
|
|
|
|
:: +pass:thumb:jwk: thumbprint json-encoded public key
|
|
|
|
::
|
2018-05-17 19:36:29 +03:00
|
|
|
++ pass
|
|
|
|
|= k=key:rsa
|
2018-06-26 08:10:19 +03:00
|
|
|
(en-base64url 32 (shax (crip (en-json-sort aor (pass:en k)))))
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +ring:thumb:jwk: thumbprint json-encoded private key
|
|
|
|
::
|
|
|
|
++ ring !!
|
2018-05-17 19:36:29 +03:00
|
|
|
--
|
2018-04-19 09:27:55 +03:00
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
:: |jws: json web signatures (rfc7515)
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: Note: flattened signature form only.
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
++ jws
|
|
|
|
|%
|
|
|
|
:: +sign:jws: sign json value
|
|
|
|
::
|
|
|
|
++ sign
|
|
|
|
|= [k=key:rsa pro=json lod=json]
|
2018-05-17 19:36:29 +03:00
|
|
|
|^ ^- json
|
|
|
|
=. pro header
|
|
|
|
=/ protect=cord (encode pro)
|
|
|
|
=/ payload=cord (encode lod)
|
|
|
|
:- %o %- my :~
|
|
|
|
protected+s+protect
|
|
|
|
payload+s+payload
|
|
|
|
signature+s+(sign protect payload)
|
|
|
|
==
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +header:sign:jws: set signature algorithm in header
|
2018-05-17 19:36:29 +03:00
|
|
|
::
|
|
|
|
++ header
|
|
|
|
?> ?=([%o *] pro)
|
|
|
|
^- json
|
|
|
|
[%o (~(put by p.pro) %alg s+'RS256')]
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +encode:sign:jws: encode json for signing
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: Alphabetically sort object keys, url-safe base64 encode
|
|
|
|
:: the serialized json.
|
2018-05-17 19:36:29 +03:00
|
|
|
::
|
|
|
|
++ encode
|
|
|
|
|= jon=json
|
2018-06-26 08:10:19 +03:00
|
|
|
%- en-base64url
|
|
|
|
%- as-octt:mimes:html
|
|
|
|
(en-json-sort aor jon)
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +sign:sign:jws: compute signature
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: Url-safe base64 encode in big-endian byte order.
|
2018-05-17 19:36:29 +03:00
|
|
|
::
|
|
|
|
++ sign
|
|
|
|
|= [protect=cord payload=cord]
|
2018-06-26 08:10:19 +03:00
|
|
|
=/ sig=@ud (~(sign rs256 k) (rap 3 ~[protect '.' payload]))
|
|
|
|
=/ len=@ud (met 3 n.pub.k)
|
|
|
|
(en-base64url len (rev 3 len sig))
|
2018-05-17 19:36:29 +03:00
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +verify:jws: verify signature
|
2018-05-17 19:36:29 +03:00
|
|
|
::
|
|
|
|
++ verify !!
|
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +eor: explicit sort order comparator
|
|
|
|
::
|
2018-05-28 08:57:58 +03:00
|
|
|
:: Lookup :a and :b in :lit, and pass their indices to :com.
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
|
|
|
++ eor
|
2018-05-09 20:45:39 +03:00
|
|
|
|= [com=$-([@ @] ?) lit=(list)]
|
|
|
|
|= [a=* b=*]
|
|
|
|
^- ?
|
|
|
|
(fall (bind (both (find ~[a] lit) (find ~[b] lit)) com) |)
|
2018-05-25 10:28:26 +03:00
|
|
|
:: +join: join list of cords with separator
|
|
|
|
::
|
|
|
|
++ join
|
2018-05-24 19:57:06 +03:00
|
|
|
|= [sep=@t hot=(list @t)]
|
2018-05-15 07:26:59 +03:00
|
|
|
^- @t
|
2018-05-11 07:53:10 +03:00
|
|
|
=| out=(list @t)
|
2018-05-15 07:26:59 +03:00
|
|
|
?> ?=(^ hot)
|
2018-05-11 07:53:10 +03:00
|
|
|
|- ^- @t
|
|
|
|
?~ t.hot
|
|
|
|
(rap 3 [i.hot out])
|
2018-05-24 19:57:06 +03:00
|
|
|
$(out [sep i.hot out], hot t.hot)
|
2018-06-23 06:43:41 +03:00
|
|
|
:: |grab: acme api response json reparsers
|
2018-05-18 01:10:24 +03:00
|
|
|
::
|
2018-05-15 07:26:59 +03:00
|
|
|
++ grab
|
2018-04-19 09:27:55 +03:00
|
|
|
=, dejs:format
|
2018-05-15 07:26:59 +03:00
|
|
|
|%
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +json-purl: parse url
|
|
|
|
::
|
2018-05-15 07:26:59 +03:00
|
|
|
++ json-purl (su auri:de-purl:html)
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +directory: parse ACME service directory
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
|
|
|
++ directory
|
|
|
|
%- ot
|
|
|
|
:~ ['newAccount' json-purl]
|
|
|
|
['newNonce' json-purl]
|
|
|
|
['newOrder' json-purl]
|
|
|
|
['revokeCert' json-purl]
|
|
|
|
['keyChange' json-purl]
|
|
|
|
==
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +acct: parse ACME service account
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
|
|
|
++ acct
|
|
|
|
%- ot
|
|
|
|
:~ ['id' no]
|
|
|
|
['createdAt' so] :: XX (su iso-8601)
|
|
|
|
['status' so]
|
|
|
|
:: ignore key, contact, initialIp
|
|
|
|
==
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +order: parse certificate order
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
|
|
|
++ order
|
|
|
|
%- ot
|
|
|
|
:~ ['authorizations' (ar json-purl)]
|
|
|
|
['finalize' json-purl]
|
|
|
|
['expires' so] :: XX (su iso-8601)
|
2018-05-15 23:52:54 +03:00
|
|
|
['status' so]
|
|
|
|
==
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +finalizing-order: parse order in a finalizing state
|
|
|
|
::
|
|
|
|
:: XX remove once +order has optional keys
|
2018-05-15 23:52:54 +03:00
|
|
|
::
|
2018-05-18 19:50:45 +03:00
|
|
|
++ finalizing-order
|
|
|
|
%- ot
|
|
|
|
:~ ['expires' so] :: XX (su iso-8601)
|
|
|
|
['status' so]
|
|
|
|
==
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +final-order: parse order in a finalized state
|
|
|
|
::
|
|
|
|
:: XX remove once +order has optional keys
|
2018-05-18 19:50:45 +03:00
|
|
|
::
|
2018-05-15 23:52:54 +03:00
|
|
|
++ final-order
|
|
|
|
%- ot
|
2018-05-18 19:50:45 +03:00
|
|
|
:~ ['expires' so] :: XX (su iso-8601)
|
2018-05-15 23:52:54 +03:00
|
|
|
['status' so]
|
|
|
|
['certificate' json-purl]
|
2018-05-15 07:26:59 +03:00
|
|
|
==
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +auth: parse authorization
|
2018-05-15 07:26:59 +03:00
|
|
|
++ auth
|
|
|
|
=> |%
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +iden: parse dns identifier to +turf
|
|
|
|
::
|
2018-05-15 07:26:59 +03:00
|
|
|
++ iden
|
|
|
|
|= [typ=@t hot=host]
|
|
|
|
?>(&(?=(%dns typ) ?=([%& *] hot)) p.hot)
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +trial: transform parsed domain validation challenge
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
|
|
|
++ trial
|
|
|
|
|= a=(list [typ=@t sas=@t url=purl tok=@t])
|
|
|
|
^+ ?>(?=(^ a) i.a)
|
|
|
|
=/ b
|
|
|
|
(skim a |=([typ=@t *] ?=(%http-01 typ)))
|
|
|
|
?>(?=(^ b) i.b)
|
|
|
|
--
|
|
|
|
%- ot
|
|
|
|
:~ ['identifier' (cu iden (ot type+so value+(su thos:de-purl:html) ~))]
|
|
|
|
['status' so]
|
|
|
|
['expires' so] :: XX (su iso-8601)
|
2018-05-15 23:52:54 +03:00
|
|
|
['challenges' (cu trial (ar challenge))]
|
|
|
|
==
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +challenge: parse domain validation challenge
|
2018-05-15 23:52:54 +03:00
|
|
|
::
|
|
|
|
++ challenge
|
|
|
|
%- ot
|
|
|
|
:~ ['type' so]
|
|
|
|
['status' so]
|
|
|
|
['url' json-purl]
|
|
|
|
['token' so]
|
2018-05-15 07:26:59 +03:00
|
|
|
==
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +error: parse ACME service error response
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
|
|
|
++ error
|
|
|
|
%- ot
|
|
|
|
:~ ['type' so]
|
|
|
|
['detail' so]
|
|
|
|
==
|
|
|
|
--
|
2018-04-19 09:27:55 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
:::: acme state
|
|
|
|
::
|
|
|
|
|%
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +move: output effect
|
|
|
|
::
|
|
|
|
+= move [bone card]
|
|
|
|
:: +card: output effect payload
|
|
|
|
::
|
|
|
|
+= card
|
|
|
|
$% [%hiss wire [~ ~] %httr %hiss hiss:eyre]
|
2018-06-29 03:03:16 +03:00
|
|
|
[%wait wire @da]
|
2018-06-23 06:43:41 +03:00
|
|
|
[%well wire path (unit mime)]
|
2018-06-28 22:56:20 +03:00
|
|
|
[%rule wire %cert (unit [wain wain])]
|
2018-06-23 06:43:41 +03:00
|
|
|
==
|
2018-06-27 00:53:29 +03:00
|
|
|
:: +nonce-next: next effect to emit upon receiving nonce
|
|
|
|
::
|
|
|
|
+= nonce-next
|
|
|
|
$? %register
|
|
|
|
%new-order
|
|
|
|
%finalize-order
|
|
|
|
%finalize-trial
|
|
|
|
==
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +turf: a domain, TLD first
|
|
|
|
::
|
|
|
|
+= turf (list @t)
|
|
|
|
:: +acct: an ACME service account
|
|
|
|
::
|
|
|
|
+= acct
|
|
|
|
$: :: key: account keypair
|
|
|
|
::
|
|
|
|
key=key:rsa
|
|
|
|
:: reg: account registration
|
|
|
|
::
|
|
|
|
reg=(unit [wen=@t kid=@t]) :: XX wen=@da
|
|
|
|
==
|
|
|
|
:: +config: finalized configuration
|
|
|
|
::
|
|
|
|
+= config
|
|
|
|
$: :: dom: domains
|
|
|
|
::
|
|
|
|
dom=(set turf)
|
|
|
|
:: key: certificate keypair
|
|
|
|
::
|
|
|
|
key=key:rsa
|
|
|
|
:: cer: signed certificate
|
|
|
|
::
|
|
|
|
cer=wain
|
|
|
|
:: exp: expiration date
|
|
|
|
::
|
|
|
|
exp=@da
|
|
|
|
:: dor: source ACME service order URL
|
|
|
|
::
|
|
|
|
dor=purl
|
|
|
|
==
|
|
|
|
:: +trial: domain validation challenge
|
|
|
|
::
|
|
|
|
+= trial
|
|
|
|
$% :: %http only for now
|
|
|
|
$: %http
|
|
|
|
:: ego: ACME service challenge url
|
|
|
|
::
|
|
|
|
ego=purl
|
|
|
|
:: tok: challenge token
|
|
|
|
::
|
|
|
|
tok=@t
|
|
|
|
:: sas: challenge status
|
|
|
|
::
|
|
|
|
sas=?(%recv %pend %auth)
|
|
|
|
== ==
|
|
|
|
:: +auth: domain authorization
|
|
|
|
::
|
|
|
|
+= auth
|
|
|
|
$: :: ego: ACME service authorization url
|
|
|
|
::
|
|
|
|
ego=purl
|
|
|
|
:: dom: domain under authorization
|
|
|
|
::
|
|
|
|
dom=turf
|
|
|
|
:: cal: domain validation challenge
|
|
|
|
::
|
|
|
|
cal=trial
|
|
|
|
==
|
|
|
|
:: +order-auth: domain authorization state for order processing
|
|
|
|
::
|
|
|
|
+= order-auth
|
|
|
|
$: :: pending: remote authorization urls
|
|
|
|
::
|
|
|
|
pending=(list purl)
|
|
|
|
:: active: authorization in progress
|
|
|
|
::
|
|
|
|
active=(unit [idx=@ auth])
|
|
|
|
:: done: finalized authorizations (XX or failed?)
|
|
|
|
::
|
|
|
|
done=(list auth)
|
|
|
|
==
|
|
|
|
:: +order: ACME certificate order
|
|
|
|
::
|
|
|
|
+= order
|
|
|
|
$: :: dom: domains
|
|
|
|
::
|
|
|
|
dom=(set turf)
|
|
|
|
:: sas: order state
|
|
|
|
::
|
|
|
|
sas=$@(%wake [%rest wen=@da])
|
|
|
|
:: exp: expiration date
|
|
|
|
::
|
|
|
|
:: XX @da once ISO-8601 parser
|
|
|
|
::
|
|
|
|
exp=@t
|
|
|
|
:: ego: ACME service order url
|
|
|
|
::
|
|
|
|
ego=purl
|
|
|
|
:: fin: ACME service order finalization url
|
|
|
|
::
|
|
|
|
fin=purl
|
|
|
|
:: key: certificate keypair
|
|
|
|
::
|
|
|
|
key=key:rsa
|
|
|
|
:: csr: DER-encoded PKCS10 certificate signing request
|
|
|
|
::
|
|
|
|
csr=@ux
|
|
|
|
:: aut: authorizations required by this order
|
|
|
|
::
|
|
|
|
aut=order-auth
|
|
|
|
==
|
|
|
|
:: +history: archive of past ACME service interactions
|
|
|
|
::
|
|
|
|
+= history
|
|
|
|
$: :: act: list of revoked account keypairs
|
|
|
|
::
|
|
|
|
act=(list acct)
|
|
|
|
:: fig: list of expired configurations
|
|
|
|
::
|
|
|
|
fig=(list config)
|
|
|
|
:: fal: list of failed order attempts
|
|
|
|
::
|
|
|
|
fal=(list order)
|
|
|
|
==
|
|
|
|
:: +directory: ACME v2 service directory
|
|
|
|
::
|
|
|
|
+= directory
|
|
|
|
$: :: reg: registration url (newAccount)
|
|
|
|
::
|
|
|
|
reg=purl
|
|
|
|
:: non: nonce creation url (newNonce)
|
|
|
|
::
|
|
|
|
non=purl
|
|
|
|
:: der: order creation url (newOrder)
|
|
|
|
::
|
|
|
|
der=purl
|
|
|
|
:: rev: certificate revocation url (revokeCert)
|
|
|
|
::
|
|
|
|
rev=purl
|
|
|
|
:: rek: account key revocation url (keyChange)
|
|
|
|
::
|
|
|
|
rek=purl
|
|
|
|
==
|
|
|
|
:: +acme: complete app state
|
|
|
|
::
|
|
|
|
+= acme
|
|
|
|
$: :: bas: ACME service root url
|
|
|
|
::
|
|
|
|
bas=purl
|
|
|
|
:: dir: ACME service directory
|
|
|
|
::
|
|
|
|
dir=directory
|
|
|
|
:: act: ACME service account
|
|
|
|
::
|
|
|
|
act=acct
|
|
|
|
:: liv: active, live configuration
|
|
|
|
::
|
|
|
|
liv=(unit config)
|
|
|
|
:: hit: ACME account history
|
|
|
|
::
|
|
|
|
hit=history
|
|
|
|
:: nonces: list of unused nonces
|
|
|
|
::
|
|
|
|
nonces=(list @t)
|
|
|
|
:: rod: active, in-progress order
|
|
|
|
::
|
|
|
|
rod=(unit order)
|
|
|
|
:: pen: pending domains for next order
|
|
|
|
::
|
|
|
|
pen=(unit (set turf))
|
|
|
|
:: cey: certificate key XX move?
|
|
|
|
::
|
|
|
|
cey=key:rsa
|
|
|
|
==
|
|
|
|
--
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
|
|
|
:::: acme app
|
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
:: mov: list of outgoing moves for the current transaction
|
|
|
|
::
|
2018-04-19 09:27:55 +03:00
|
|
|
=| mov=(list move)
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2018-05-15 07:26:59 +03:00
|
|
|
|_ [bow=bowl:gall acme]
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +this: self
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
:: XX Should be a +* core alias, see urbit/arvo#712
|
|
|
|
::
|
|
|
|
++ this .
|
|
|
|
:: +emit: emit a move
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
|
|
|
++ emit
|
|
|
|
|= car=card
|
2018-04-24 08:49:21 +03:00
|
|
|
~& [%emit car]
|
2018-04-19 09:27:55 +03:00
|
|
|
this(mov [[ost.bow car] mov])
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +abet: finalize transaction
|
2018-05-15 23:52:54 +03:00
|
|
|
::
|
2018-04-19 09:27:55 +03:00
|
|
|
++ abet
|
2018-06-23 06:43:41 +03:00
|
|
|
^- (quip move _this)
|
2018-04-19 09:27:55 +03:00
|
|
|
[(flop mov) this(mov ~)]
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +request: generic http request
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
2018-05-17 19:36:29 +03:00
|
|
|
++ request
|
2018-06-23 06:43:41 +03:00
|
|
|
|= [wir=wire req=hiss]
|
2018-05-15 23:52:54 +03:00
|
|
|
^- card
|
2018-06-23 06:43:41 +03:00
|
|
|
[%hiss wir [~ ~] %httr %hiss req]
|
|
|
|
:: +signed-request: JWS JSON POST
|
|
|
|
::
|
|
|
|
++ signed-request
|
|
|
|
|= [url=purl non=@t bod=json]
|
|
|
|
^- hiss
|
|
|
|
:^ url %post
|
|
|
|
(my content-type+['application/jose+json' ~] ~)
|
2018-05-15 07:26:59 +03:00
|
|
|
:- ~
|
2018-06-23 06:43:41 +03:00
|
|
|
^- octs
|
|
|
|
=; pro=json
|
|
|
|
(as-octt:mimes:html (en-json:html (sign:jws key.act pro bod)))
|
2018-04-19 09:27:55 +03:00
|
|
|
:- %o %- my :~
|
2018-06-23 06:43:41 +03:00
|
|
|
nonce+s+non
|
|
|
|
url+s+(crip (en-purl:html url))
|
|
|
|
?^ reg.act
|
|
|
|
kid+s+kid.u.reg.act
|
|
|
|
jwk+(pass:en:jwk key.act)
|
2018-04-19 09:27:55 +03:00
|
|
|
==
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +bad-nonce: check if an http response is a badNonce error
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
++ bad-nonce
|
|
|
|
|= rep=httr
|
|
|
|
^- ?
|
|
|
|
:: XX always 400?
|
|
|
|
?. =(400 p.rep) |
|
|
|
|
?~ r.rep |
|
|
|
|
=/ jon=(unit json) (de-json:html q.u.r.rep)
|
|
|
|
?~ jon |
|
|
|
|
:: XX unit parser, types
|
2018-06-27 00:53:29 +03:00
|
|
|
=('urn:ietf:params:acme:error:badNonce' -:(error:grab u.jon))
|
2018-06-23 06:43:41 +03:00
|
|
|
:: |effect: send moves to advance
|
2018-05-18 09:05:12 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
++ effect
|
|
|
|
|%
|
|
|
|
:: +directory: get ACME service directory
|
|
|
|
::
|
|
|
|
++ directory
|
|
|
|
^+ this
|
|
|
|
(emit (request /acme/directory/(scot %p our.bow) bas %get ~ ~)) :: XX now?
|
|
|
|
:: +nonce: get a new nonce for the next request
|
|
|
|
::
|
|
|
|
++ nonce
|
2018-06-27 00:53:29 +03:00
|
|
|
|= nex=@tas
|
|
|
|
~| [%bad-nonce-next nex]
|
|
|
|
?> ?=(nonce-next nex)
|
2018-06-23 06:43:41 +03:00
|
|
|
^+ this
|
2018-06-27 00:53:29 +03:00
|
|
|
:: XX now?
|
|
|
|
(emit (request /acme/nonce/next/[nex] non.dir %get ~ ~))
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +register: create ACME service account
|
|
|
|
::
|
|
|
|
:: Note: accepts services ToS.
|
|
|
|
::
|
|
|
|
++ register
|
|
|
|
^+ this
|
|
|
|
?~ nonces
|
2018-06-27 00:53:29 +03:00
|
|
|
(nonce %register)
|
2018-06-23 06:43:41 +03:00
|
|
|
%- emit(nonces t.nonces, reg.act ~)
|
|
|
|
%+ request
|
|
|
|
/acme/register/(scot %p our.bow) :: XX now?
|
|
|
|
%^ signed-request reg.dir i.nonces
|
|
|
|
[%o (my [['termsOfServiceAgreed' b+&] ~])]
|
|
|
|
:: XX rekey
|
|
|
|
::
|
|
|
|
:: +new-order: create a new certificate order
|
|
|
|
::
|
|
|
|
++ new-order
|
|
|
|
^+ this
|
|
|
|
~| %new-order-effect-fail
|
|
|
|
?. ?=(^ reg.act) ~|(%no-account !!)
|
|
|
|
?. ?=([~ ^] pen) ~|(%no-domains !!)
|
|
|
|
?~ nonces
|
2018-06-27 00:53:29 +03:00
|
|
|
(nonce %new-order)
|
2018-06-23 06:43:41 +03:00
|
|
|
%- emit(nonces t.nonces)
|
|
|
|
%+ request
|
|
|
|
/acme/new-order/(scot %da now.bow)
|
|
|
|
%^ signed-request der.dir i.nonces
|
|
|
|
:- %o %- my :~
|
|
|
|
:- %identifiers
|
|
|
|
:- %a
|
|
|
|
%+ turn
|
|
|
|
~(tap in `(set turf)`u.pen)
|
|
|
|
|=(a=turf [%o (my type+s+'dns' value+s+(join '.' a) ~)])
|
|
|
|
==
|
|
|
|
:: +finalize-order: finalize completed order
|
|
|
|
::
|
|
|
|
++ finalize-order
|
|
|
|
^+ this
|
|
|
|
~| %finalize-order-effect-fail
|
|
|
|
?. ?=(^ reg.act) ~|(%no-account !!)
|
|
|
|
?. ?=(^ rod) ~|(%no-active-order !!)
|
|
|
|
?. ?=(~ pending.aut.u.rod) ~|(%pending-authz !!)
|
|
|
|
?. ?=(~ active.aut.u.rod) ~|(%active-authz !!)
|
|
|
|
:: XX revisit wrt rate limits
|
|
|
|
?> ?=(%wake sas.u.rod)
|
|
|
|
?~ nonces
|
2018-06-27 00:53:29 +03:00
|
|
|
(nonce %finalize-order)
|
2018-06-23 06:43:41 +03:00
|
|
|
%- emit(nonces t.nonces)
|
|
|
|
%+ request
|
|
|
|
/acme/finalize-order/(scot %da now.bow)
|
|
|
|
%^ signed-request fin.u.rod i.nonces
|
2018-06-26 08:10:19 +03:00
|
|
|
[%o (my csr+s+(en-base64url (met 3 csr.u.rod) `@`csr.u.rod) ~)]
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +check-order: check completed order for certificate availability
|
|
|
|
::
|
|
|
|
++ check-order
|
|
|
|
^+ this
|
|
|
|
~| %check-order-effect-fail
|
|
|
|
?. ?=(^ reg.act) ~|(%no-account !!)
|
|
|
|
?. ?=(^ rod) ~|(%no-active-order !!)
|
|
|
|
?. ?=(~ pending.aut.u.rod) ~|(%pending-authz !!)
|
|
|
|
?. ?=(~ active.aut.u.rod) ~|(%active-authz !!)
|
|
|
|
:: XX revisit wrt rate limits
|
|
|
|
?> ?=(%wake sas.u.rod)
|
|
|
|
(emit (request /acme/check-order/(scot %da now.bow) ego.u.rod %get ~ ~))
|
|
|
|
:: +certificate: download PEM-encoded certificate
|
|
|
|
::
|
|
|
|
++ certificate
|
|
|
|
|= url=purl
|
|
|
|
^+ this
|
|
|
|
~| %certificate-effect-fail
|
|
|
|
?. ?=(^ reg.act) ~|(%no-account !!)
|
|
|
|
?. ?=(^ rod) ~|(%no-active-order !!)
|
|
|
|
=/ hed (my accept+['applicate/x-pem-file' ~] ~)
|
|
|
|
(emit (request /acme/certificate/(scot %da now.bow) url %get hed ~))
|
2018-06-28 22:56:20 +03:00
|
|
|
:: +install: tell %eyre about our certificate
|
|
|
|
::
|
|
|
|
++ install
|
|
|
|
^+ this
|
|
|
|
~| %install-effect-fail
|
|
|
|
?> ?=(^ liv)
|
2018-07-16 19:28:23 +03:00
|
|
|
=/ key=wain (ring:en:pem:pkcs8 key.u.liv)
|
2018-06-28 22:56:20 +03:00
|
|
|
(emit %rule /install %cert `[key `wain`cer.u.liv])
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +get-authz: get next ACME service domain authorization object
|
|
|
|
::
|
|
|
|
++ get-authz
|
|
|
|
^+ this
|
|
|
|
~| %get-authz-effect-fail
|
|
|
|
?. ?=(^ reg.act) ~|(%no-account !!)
|
|
|
|
?. ?=(^ rod) ~|(%no-active-order !!)
|
|
|
|
?. ?=(^ pending.aut.u.rod) ~|(%no-pending-authz !!)
|
|
|
|
:: XX revisit wrt rate limits
|
|
|
|
?> ?=(%wake sas.u.rod)
|
|
|
|
%- emit
|
|
|
|
(request /acme/get-authz/(scot %da now.bow) i.pending.aut.u.rod %get ~ ~)
|
|
|
|
:: XX check/finalize-authz ??
|
|
|
|
::
|
|
|
|
:: +save-trial: save ACME domain validation challenge to /.well-known/
|
|
|
|
::
|
|
|
|
++ save-trial
|
|
|
|
^+ this
|
|
|
|
~| %save-trial-effect-fail
|
|
|
|
?. ?=(^ reg.act) ~|(%no-account !!)
|
|
|
|
?. ?=(^ rod) ~|(%no-active-order !!)
|
|
|
|
?. ?=(^ active.aut.u.rod) ~|(%no-active-authz !!)
|
|
|
|
:: XX revisit wrt rate limits
|
|
|
|
?> ?=(%wake sas.u.rod)
|
|
|
|
=* aut u.active.aut.u.rod
|
|
|
|
%- emit
|
|
|
|
:^ %well
|
|
|
|
:: XX idx in wire?
|
|
|
|
/acme/save-trial/(scot %da now.bow)
|
|
|
|
/acme-challenge/[tok.cal.aut]
|
|
|
|
:+ ~
|
|
|
|
/text/plain
|
|
|
|
%- as-octs:mimes:html
|
|
|
|
(rap 3 [tok.cal.aut '.' (pass:thumb:jwk key.act) ~])
|
|
|
|
:: +test-trial: confirm that ACME domain validation challenge is available
|
|
|
|
::
|
|
|
|
++ test-trial
|
|
|
|
^+ this
|
|
|
|
~| %test-trial-effect-fail
|
|
|
|
?. ?=(^ reg.act) ~|(%no-account !!)
|
|
|
|
?. ?=(^ rod) ~|(%no-active-order !!)
|
|
|
|
?. ?=(^ active.aut.u.rod) ~|(%no-active-authz !!)
|
|
|
|
:: XX revisit wrt rate limits
|
|
|
|
?> ?=(%wake sas.u.rod)
|
|
|
|
=* aut u.active.aut.u.rod
|
|
|
|
=/ pat=path /'.well-known'/acme-challenge/[tok.cal.aut]
|
|
|
|
:: note: requires port 80, just as the ACME service will
|
|
|
|
=/ url=purl [[sec=| por=~ hos=[%& dom.aut]] [ext=~ pat] hed=~]
|
|
|
|
:: =/ url=purl [[sec=| por=`8.081 hos=[%& /localhost]] [ext=~ pat] hed=~]
|
|
|
|
:: XX idx in wire?
|
|
|
|
(emit (request /acme/test-trial/(scot %da now.bow) url %get ~ ~))
|
|
|
|
:: +finalize-trial: notify ACME service that challenge is ready
|
|
|
|
::
|
|
|
|
++ finalize-trial
|
|
|
|
^+ this
|
2018-07-17 02:15:15 +03:00
|
|
|
~| %finalize-trial-effect-fail
|
2018-06-23 06:43:41 +03:00
|
|
|
?. ?=(^ reg.act) ~|(%no-account !!)
|
|
|
|
?. ?=(^ rod) ~|(%no-active-order !!)
|
|
|
|
?. ?=(^ active.aut.u.rod) ~|(%no-active-authz !!)
|
|
|
|
:: XX revisit wrt rate limits
|
|
|
|
?> ?=(%wake sas.u.rod)
|
|
|
|
=* aut u.active.aut.u.rod
|
|
|
|
?~ nonces
|
2018-06-27 00:53:29 +03:00
|
|
|
(nonce %finalize-trial)
|
2018-06-23 06:43:41 +03:00
|
|
|
%- emit(nonces t.nonces)
|
|
|
|
%+ request
|
|
|
|
:: XX idx in wire?
|
|
|
|
/acme/finalize-trial/(scot %da now.bow)
|
|
|
|
:: empty object included for signature
|
|
|
|
(signed-request ego.cal.aut i.nonces [%o ~])
|
|
|
|
:: XX delete-trial?
|
|
|
|
::
|
|
|
|
:: +retry: retry effect after timeout
|
|
|
|
::
|
2018-06-29 03:03:16 +03:00
|
|
|
++ retry
|
|
|
|
|= [wir=wire wen=@da]
|
|
|
|
:: XX validate wire and date
|
|
|
|
(emit %wait [%acme wir] wen)
|
2018-06-23 06:43:41 +03:00
|
|
|
--
|
|
|
|
:: |event: accept event, emit next effect(s)
|
2018-05-15 23:52:54 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
:: XX should these next effects be triggered at call sites instead?
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
++ event
|
|
|
|
|%
|
|
|
|
:: +directory: accept ACME service directory, trigger registration
|
|
|
|
::
|
|
|
|
++ directory
|
2018-06-23 07:11:22 +03:00
|
|
|
|= [wir=wire rep=httr]
|
2018-06-23 06:43:41 +03:00
|
|
|
^+ this
|
|
|
|
?. =(200 p.rep)
|
|
|
|
:: XX never happened yet, wat do?
|
|
|
|
~& [%directory-fail rep]
|
|
|
|
this
|
|
|
|
=. dir (directory:grab (need (de-json:html q:(need r.rep))))
|
|
|
|
?~(reg.act register:effect this)
|
2018-06-27 00:53:29 +03:00
|
|
|
:: +nonce: accept new nonce and trigger next effect
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2018-06-27 00:53:29 +03:00
|
|
|
:: Nonce has already been saved in +sigh-httr. The next effect
|
|
|
|
:: is specified in the wire.
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ nonce
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^+ this
|
2018-06-27 00:53:29 +03:00
|
|
|
~| [%unrecognized-nonce-wire wir]
|
|
|
|
?> &(?=(^ wir) ?=([%next ^] t.wir))
|
2018-06-23 06:43:41 +03:00
|
|
|
=* nex i.t.t.wir
|
2018-06-27 00:53:29 +03:00
|
|
|
~| [%unknown-nonce-next nex]
|
|
|
|
?> ?=(nonce-next nex)
|
|
|
|
?. =(204 p.rep)
|
|
|
|
:: cttp i/o timeout, always retry
|
|
|
|
:: XX set timer to backoff?
|
|
|
|
?: =(504 p.rep) (nonce:effect nex)
|
|
|
|
:: XX never happened yet, retry nonce anyway?
|
|
|
|
::
|
|
|
|
~&([%nonce-fail wir rep] this)
|
|
|
|
?- nex
|
2018-06-23 06:43:41 +03:00
|
|
|
%register register:effect
|
|
|
|
%new-order new-order:effect
|
|
|
|
%finalize-order finalize-order:effect
|
|
|
|
%finalize-trial finalize-trial:effect
|
2018-05-15 07:26:59 +03:00
|
|
|
==
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +register: accept ACME service registration
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
++ register
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^+ this
|
|
|
|
?. =(201 p.rep)
|
|
|
|
::XX 204?
|
|
|
|
?: (bad-nonce rep)
|
2018-06-27 00:53:29 +03:00
|
|
|
(nonce:effect %register)
|
2018-06-23 06:43:41 +03:00
|
|
|
:: XX retry immediately or backoff?
|
|
|
|
~& [%register-fail wir rep]
|
|
|
|
this
|
2018-05-15 07:26:59 +03:00
|
|
|
=/ loc=@t
|
|
|
|
q:(head (skim q.rep |=((pair @t @t) ?=(%location p))))
|
2018-05-18 18:34:55 +03:00
|
|
|
=/ wen=@t :: XX @da
|
|
|
|
?~ r.rep
|
|
|
|
(scot %da now.bow)
|
|
|
|
=/ bod=[id=@t wen=@t sas=@t]
|
|
|
|
(acct:grab (need (de-json:html q.u.r.rep)))
|
|
|
|
?> ?=(%valid sas.bod)
|
|
|
|
wen.bod
|
2018-06-29 05:52:35 +03:00
|
|
|
=. reg.act `[wen loc]
|
|
|
|
?~(pen this new-order:effect)
|
2018-06-23 06:43:41 +03:00
|
|
|
:: XX rekey
|
|
|
|
::
|
|
|
|
:: +new-order: order created, begin processing authorizations
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
++ new-order
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^+ this
|
|
|
|
?. =(201 p.rep)
|
|
|
|
?: (bad-nonce rep)
|
2018-06-27 00:53:29 +03:00
|
|
|
(nonce:effect %new-order)
|
2018-06-23 06:43:41 +03:00
|
|
|
:: XX retry immediately or backoff?
|
|
|
|
:: XX possible 204?
|
|
|
|
~& [%new-order-fail wir rep]
|
|
|
|
this
|
|
|
|
:: XX delete order if not?
|
|
|
|
?> ?=(^ pen)
|
2018-05-15 23:52:54 +03:00
|
|
|
=/ loc=@t
|
|
|
|
q:(head (skim q.rep |=((pair @t @t) ?=(%location p))))
|
2018-06-23 06:43:41 +03:00
|
|
|
=/ ego=purl (need (de-purl:html loc))
|
|
|
|
:: XX add parser output types
|
|
|
|
:: XX parse identifiers, confirm equal to pending domains
|
|
|
|
:: XX check status
|
2018-05-15 23:52:54 +03:00
|
|
|
=/ bod=[aut=(list purl) fin=purl exp=@t sas=@t]
|
2018-05-15 07:26:59 +03:00
|
|
|
(order:grab (need (de-json:html q:(need r.rep))))
|
2018-06-23 06:43:41 +03:00
|
|
|
:: XX maybe generate key here?
|
2018-06-26 08:10:19 +03:00
|
|
|
=/ csr=@ux +:(en:der:pkcs10 cey ~(tap in u.pen))
|
2018-06-23 06:43:41 +03:00
|
|
|
=/ dor=order
|
|
|
|
[dom=u.pen sas=%wake exp.bod ego fin.bod cey csr [aut.bod ~ ~]]
|
|
|
|
get-authz:effect(rod `dor, pen ~)
|
|
|
|
:: +finalize-order: order finalized, poll for certificate
|
2018-05-18 09:05:12 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
++ finalize-order
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^+ this
|
|
|
|
?. =(200 p.rep)
|
|
|
|
?: (bad-nonce rep)
|
2018-06-27 00:53:29 +03:00
|
|
|
(nonce:effect %finalize-order)
|
2018-06-23 06:43:41 +03:00
|
|
|
~& [%finalize-order-fail wir rep]
|
|
|
|
?> ?=(^ rod)
|
|
|
|
:: XX get the failure reason
|
|
|
|
this(rod ~, fal.hit [u.rod fal.hit])
|
|
|
|
?> ?=(^ rod)
|
|
|
|
:: XX rep body missing authorizations, need flexible/separate parser
|
2018-05-18 19:50:45 +03:00
|
|
|
:: XX finalizing-order
|
2018-05-18 19:23:34 +03:00
|
|
|
:: =/ bod=[aut=(list purl) fin=purl exp=@t sas=@t]
|
|
|
|
:: (order:grab (need (de-json:html q:(need r.rep))))
|
2018-05-15 23:52:54 +03:00
|
|
|
:: XX check status? (i don't think failures get here)
|
2018-06-23 06:43:41 +03:00
|
|
|
check-order:effect
|
|
|
|
:: +check-order: check if certificate is ready for finalized order
|
2018-05-15 23:52:54 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
++ check-order
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^+ this
|
|
|
|
?. =(200 p.rep)
|
|
|
|
:: XX retry immediately? backoff?
|
|
|
|
~& [%check-order-fail wir rep]
|
|
|
|
this
|
|
|
|
?> ?=(^ rod)
|
2018-05-15 23:52:54 +03:00
|
|
|
=/ raw=json
|
|
|
|
(need (de-json:html q:(need r.rep)))
|
2018-05-18 19:50:45 +03:00
|
|
|
=/ bod=[exp=@t sas=@t]
|
|
|
|
(finalizing-order:grab raw)
|
2018-05-15 23:52:54 +03:00
|
|
|
?+ sas.bod
|
2018-06-23 06:43:41 +03:00
|
|
|
~& [%check-order-status-unknown sas.bod]
|
|
|
|
this
|
|
|
|
::
|
|
|
|
%invalid
|
|
|
|
~& [%check-order-fail %invalid wir rep]
|
|
|
|
:: XX check authz for debug info
|
|
|
|
:: XX send notification somehow?
|
|
|
|
:: XX start over with new order?
|
|
|
|
this
|
|
|
|
::
|
|
|
|
%pending
|
|
|
|
check-order:effect
|
|
|
|
::
|
|
|
|
%processing
|
|
|
|
check-order:effect
|
|
|
|
::
|
|
|
|
%valid
|
|
|
|
:: XX json reparser unit
|
|
|
|
=/ bod=[exp=@t sas=@t cer=purl]
|
|
|
|
(final-order:grab raw)
|
|
|
|
:: XX update order state
|
|
|
|
:: XX =< delete-trial
|
|
|
|
(certificate:effect cer.bod)
|
2018-05-15 23:52:54 +03:00
|
|
|
==
|
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +certificate: accept PEM-encoded certificate
|
|
|
|
::
|
|
|
|
++ certificate
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^+ this
|
|
|
|
?. =(200 p.rep)
|
|
|
|
:: XX retry immediately? backoff?
|
|
|
|
~& [%certificate-fail wir rep]
|
|
|
|
this
|
|
|
|
?> ?=(^ rod)
|
|
|
|
=/ cer=wain (to-wain:format q:(need r.rep))
|
|
|
|
=/ fig=config
|
|
|
|
:: XX expiration date
|
2018-06-28 22:56:20 +03:00
|
|
|
[dom.u.rod key.u.rod cer (add now.bow ~d90) ego.u.rod]
|
2018-06-23 06:43:41 +03:00
|
|
|
=? fig.hit ?=(^ liv) [u.liv fig.hit]
|
2018-06-28 22:56:20 +03:00
|
|
|
:: XX set renewal timer
|
|
|
|
install:effect(liv `fig, rod ~)
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +get-authz: accept ACME service authorization object
|
|
|
|
::
|
|
|
|
++ get-authz
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^+ this
|
|
|
|
?. =(200 p.rep)
|
|
|
|
:: XX retry immediately? backoff?
|
|
|
|
~& [%get-authz-fail wir rep]
|
|
|
|
this
|
|
|
|
?> ?=(^ rod)
|
|
|
|
?> ?=(^ pending.aut.u.rod)
|
|
|
|
:: XX parser types
|
|
|
|
=/ bod=[dom=turf sas=@t exp=@t cal=[typ=@t sas=@t ego=purl tok=@t]]
|
|
|
|
(auth:grab (need (de-json:html q:(need r.rep))))
|
|
|
|
=/ cal=trial
|
|
|
|
:: XX parse token to verify url-safe base64?
|
|
|
|
[%http ego.cal.bod tok.cal.bod %recv]
|
|
|
|
:: XX check that URLs are the same
|
|
|
|
=/ tau=auth [i.pending.aut.u.rod dom.bod cal]
|
|
|
|
:: XX get idx from wire instead?
|
|
|
|
=/ idx=@ud +((lent done.aut.u.rod))
|
|
|
|
=/ rod-aut=order-auth
|
|
|
|
%= aut.u.rod
|
|
|
|
pending t.pending.aut.u.rod
|
|
|
|
active `[idx tau]
|
|
|
|
==
|
|
|
|
=< test-trial:effect
|
|
|
|
save-trial:effect(aut.u.rod rod-aut)
|
|
|
|
:: XX check/finalize-authz ??
|
|
|
|
::
|
|
|
|
:: +test-trial: accept response from challenge test
|
|
|
|
::
|
|
|
|
:: Note that +save-trail:effect has no corresponding event.
|
|
|
|
::
|
|
|
|
++ test-trial
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^+ this
|
|
|
|
?. =(200 p.rep)
|
2018-07-19 00:24:08 +03:00
|
|
|
:: XX count retries, backoff
|
2018-06-23 06:43:41 +03:00
|
|
|
~& [%test-trial-fail wir rep]
|
2018-07-19 00:24:08 +03:00
|
|
|
(retry:effect /test-trial (add now.bow ~m10))
|
2018-06-23 06:43:41 +03:00
|
|
|
?> ?=(^ rod)
|
|
|
|
?> ?=(^ active.aut.u.rod)
|
|
|
|
:: XX check content type and response body
|
|
|
|
finalize-trial:effect
|
|
|
|
:: +finalize-trial:
|
|
|
|
::
|
|
|
|
++ finalize-trial
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^+ this
|
|
|
|
?. =(200 p.rep)
|
|
|
|
?: (bad-nonce rep)
|
2018-06-27 00:53:29 +03:00
|
|
|
(nonce:effect %finalize-trial)
|
2018-06-23 06:43:41 +03:00
|
|
|
:: XX retry? or cancel order?
|
|
|
|
:: XX 204 assume pending?
|
|
|
|
~& [%finalize-trial-fail wir rep]
|
|
|
|
:: XX handle "challenge is not pending"
|
|
|
|
this
|
|
|
|
?> ?=(^ rod)
|
|
|
|
?> ?=(^ active.aut.u.rod)
|
|
|
|
=* aut u.active.aut.u.rod
|
|
|
|
=/ bod=[typ=@t sas=@t url=purl tok=@t]
|
|
|
|
(challenge:grab (need (de-json:html q:(need r.rep))))
|
2018-06-24 05:31:20 +03:00
|
|
|
:: XX check for other possible values in 200 response
|
|
|
|
:: note: may have already been validated
|
|
|
|
?> ?=(?(%pending %valid) sas.bod)
|
2018-06-23 06:43:41 +03:00
|
|
|
=/ rod-aut=order-auth
|
|
|
|
aut.u.rod(active ~, done [+.aut(sas.cal %pend) done.aut.u.rod])
|
|
|
|
?~ pending.aut.u.rod
|
|
|
|
finalize-order:effect(aut.u.rod rod-aut)
|
|
|
|
get-authz:effect(aut.u.rod rod-aut)
|
|
|
|
:: XX delete-trial?
|
|
|
|
::
|
|
|
|
:: +retry: retry effect after timeout
|
|
|
|
::
|
|
|
|
++ retry
|
2018-06-29 03:03:16 +03:00
|
|
|
|= wir=wire
|
|
|
|
^+ this
|
|
|
|
?+ wir
|
|
|
|
~&(unknown-retry+wir this)
|
|
|
|
:: XX do the needful
|
|
|
|
[%directory ~] directory:effect
|
2018-07-19 00:24:08 +03:00
|
|
|
[%test-trial ~] test-trial:effect
|
2018-06-29 03:03:16 +03:00
|
|
|
==
|
2018-06-23 06:43:41 +03:00
|
|
|
--
|
|
|
|
:: +sigh-tang: handle http request failure
|
|
|
|
::
|
|
|
|
++ sigh-tang
|
|
|
|
|= [wir=wire saw=tang]
|
|
|
|
^- (quip move _this)
|
|
|
|
~& [%sigh-tang wir]
|
|
|
|
:: XX take evasive action
|
|
|
|
[((slog saw) ~) this]
|
2018-07-19 21:05:12 +03:00
|
|
|
:: +sigh-recoverable-error: handle http rate-limit response
|
|
|
|
::
|
|
|
|
++ sigh-recoverable-error
|
|
|
|
|= [wir=wire %429 %rate-limit lim=(unit @da)]
|
|
|
|
^- (quip move _this)
|
|
|
|
~& [%sigh-recoverable wir lim]
|
|
|
|
:: XX retry
|
|
|
|
[~ this]
|
2018-06-23 06:43:41 +03:00
|
|
|
:: +sigh-httr: accept http response
|
|
|
|
::
|
|
|
|
++ sigh-httr
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^- (quip move _this)
|
|
|
|
~& [wir rep]
|
|
|
|
?> ?=([%acme ^] wir)
|
|
|
|
:: add nonce to pool, if present
|
|
|
|
=/ nonhed (skim q.rep |=((pair @t @t) ?=(%replay-nonce p)))
|
|
|
|
=? nonces ?=(^ nonhed) [q.i.nonhed nonces]
|
|
|
|
=< abet
|
|
|
|
~| [%sigh-fail wir rep]
|
2018-06-23 07:11:22 +03:00
|
|
|
%. [t.wir rep]
|
2018-06-23 06:43:41 +03:00
|
|
|
?+ i.t.wir
|
|
|
|
~&([%unknown-wire i.t.wir] !!)
|
2018-06-23 07:11:22 +03:00
|
|
|
%directory directory:event
|
|
|
|
%nonce nonce:event
|
|
|
|
%register register:event
|
2018-06-23 06:43:41 +03:00
|
|
|
:: XX rekey
|
2018-06-23 07:11:22 +03:00
|
|
|
%new-order new-order:event
|
|
|
|
%finalize-order finalize-order:event
|
|
|
|
%check-order check-order:event
|
|
|
|
%certificate certificate:event
|
|
|
|
%get-authz get-authz:event
|
2018-06-23 06:43:41 +03:00
|
|
|
:: XX check/finalize-authz ??
|
2018-06-23 07:11:22 +03:00
|
|
|
%test-trial test-trial:event
|
|
|
|
%finalize-trial finalize-trial:event
|
2018-06-23 06:43:41 +03:00
|
|
|
:: XX delete-trial?
|
2018-04-19 09:27:55 +03:00
|
|
|
==
|
2018-06-29 03:03:16 +03:00
|
|
|
:: +wake: timer wakeup event
|
|
|
|
::
|
|
|
|
++ wake
|
|
|
|
|= [wir=wire ~]
|
|
|
|
^- (quip move _this)
|
|
|
|
~& [%wake wir]
|
|
|
|
?> ?=([%acme *] wir)
|
|
|
|
abet:(retry:event t.wir)
|
2018-06-28 22:56:20 +03:00
|
|
|
:: +poke-acme-order: create new order for a set of domains
|
|
|
|
::
|
|
|
|
++ poke-acme-order
|
2018-06-29 05:52:35 +03:00
|
|
|
|= a=(set turf)
|
|
|
|
~& [%poke-acme a]
|
|
|
|
abet:(add-order a)
|
2018-06-28 22:56:20 +03:00
|
|
|
:: +poke-noun: for debugging
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
2018-05-17 06:08:15 +03:00
|
|
|
++ poke-noun
|
|
|
|
|= a=*
|
|
|
|
^- (quip move _this)
|
2018-06-23 06:43:41 +03:00
|
|
|
=< abet
|
|
|
|
?+ a
|
|
|
|
~&(+<+.this this)
|
2018-06-24 06:56:27 +03:00
|
|
|
%dbug ~& [%private (ring:en:pem:pkcs1 key.act)]
|
|
|
|
~& [%public (pass:en:pem:pkcs1 key.act)]
|
|
|
|
this
|
2018-06-23 06:43:41 +03:00
|
|
|
%init init
|
|
|
|
%reg register:effect
|
|
|
|
%order new-order:effect
|
|
|
|
%auth get-authz:effect
|
|
|
|
%trial test-trial:effect
|
|
|
|
%final finalize-order:effect
|
|
|
|
%poll check-order:effect
|
2018-06-29 05:52:35 +03:00
|
|
|
%our (add-order (sy /org/urbit/(crip +:(scow %p our.bow)) ~))
|
2018-06-28 22:56:20 +03:00
|
|
|
%rule install:effect
|
2018-07-10 23:29:35 +03:00
|
|
|
%fake fake
|
|
|
|
%none none
|
2018-05-17 06:08:15 +03:00
|
|
|
%test test
|
|
|
|
==
|
2018-07-10 23:29:35 +03:00
|
|
|
++ none
|
|
|
|
^+ this
|
|
|
|
(emit %rule /uninstall %cert ~)
|
|
|
|
++ fake
|
|
|
|
^+ this
|
|
|
|
=/ key=wain
|
|
|
|
:~ '-----BEGIN RSA PRIVATE KEY-----'
|
|
|
|
'MIIEpAIBAAKCAQEAisQPzzmGWNZSNNAwY59XrqK/bU0NKNZS2ETOiJeSpzPAHYl+'
|
|
|
|
'c39V96/QUR0tra2zQI4QD6kpMYX/7R5nwuvsA4o7ypfYupNrlzLPThCKEHpZomDD'
|
|
|
|
'0Bb3T8u7YGrMjEX5cOmZIU2T/iy4GK/wWuBIy2TEp/0J+RoSCIr8Df/A7GIM8bwn'
|
|
|
|
'v23Vq0kE2xBqqaT5LjvuQoXfiLJ42F33DDno9lVikKEyt55D/08rH41KpXvn3tWZ'
|
|
|
|
'46tZK6Ds7Zr1hEV1LbDx1CXDzQ6gKObBe54DWDV3h7TJhr0BSW68dFJhro7Y60Ns'
|
|
|
|
'zTcFqY1RC9F0ePtsnKGFzMOe/U+fPvsGe2oWvwIDAQABAoIBACCf19ewfpWETe98'
|
|
|
|
'wuOpIsQ8HyVjaCShvvh5tNUITcJhuFk5ajFdTqjc/O0VHxgmLm6O99e2vaiXCISH'
|
|
|
|
'EX4SWXq7lTMcYCf9YN47Y+HGoa8eFNTIS0ExJRPtojAY695O1UZmpUnfI1wux1mG'
|
|
|
|
'g8vZz0OCfXnBVAbsyjCX/IqOBp2MVzfMyMuaF/oQ2xiX4AZ1hDIMDpUTGw7OKX15'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
|
|
|
|
'SVuvdDM5zGv2f9ltNWUiYZHJ1mmO97jSY/6YfdOUH66iRtQtDkHBRdkNBsMbD+Em'
|
|
|
|
'2TgBldtHNSJBfB3pm9FblgOcJ0FSWcUDWJ7vO0+NTXlgrRofRT6pVywzxVo6dND0'
|
|
|
|
'WzYlTWeUVsO40xJqhgUQRER9YLOLxJ0O6C8i0xFxAMKOtSdodMB3RIwt7RFQ0uyt'
|
|
|
|
'n5Z5MqkYhlMI3J1tPRTp1nEt9fyGspBOO05gi148Qasp+3N+svqKomoQglNoAxU='
|
|
|
|
'-----END CERTIFICATE-----'
|
|
|
|
==
|
2018-07-16 19:28:23 +03:00
|
|
|
=/ k=key:rsa (need (ring:de:pem:pkcs1 key))
|
|
|
|
=/ k8=wain (ring:en:pem:pkcs8 k)
|
|
|
|
(emit %rule /install %cert `[k8 cert])
|
2018-06-28 22:56:20 +03:00
|
|
|
:: +poke-path: for debugging
|
2018-05-17 06:08:15 +03:00
|
|
|
::
|
|
|
|
++ poke-path
|
2018-06-29 05:52:35 +03:00
|
|
|
|=(a=path abet:(add-order (sy a ~)))
|
2018-05-17 06:08:15 +03:00
|
|
|
::
|
2018-05-15 23:52:54 +03:00
|
|
|
:: ++ prep _[~ this]
|
2018-05-15 07:26:59 +03:00
|
|
|
++ prep
|
|
|
|
|= old=(unit acme)
|
2018-06-23 06:43:41 +03:00
|
|
|
^- (quip move _this)
|
2018-06-29 07:01:45 +03:00
|
|
|
?~ old
|
2018-06-23 06:43:41 +03:00
|
|
|
[~ this]
|
2018-06-29 07:01:45 +03:00
|
|
|
[~ this(+<+ u.old)]
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
2018-05-15 23:52:54 +03:00
|
|
|
++ rekey :: XX do something about this
|
2018-05-18 19:36:39 +03:00
|
|
|
|= eny=@
|
2018-05-15 23:52:54 +03:00
|
|
|
=| i=@
|
|
|
|
|- ^- key:rsa
|
2018-05-18 19:36:39 +03:00
|
|
|
=/ k (new-key:rsa 2.048 eny)
|
2018-05-16 22:38:50 +03:00
|
|
|
=/ m (met 0 n.pub.k)
|
2018-06-23 06:43:41 +03:00
|
|
|
:: ?: =(0 (mod m 8)) k
|
|
|
|
?: =(2.048 m) k
|
2018-05-15 23:52:54 +03:00
|
|
|
~& [%key iter=i width=m]
|
2018-05-18 19:36:39 +03:00
|
|
|
$(i +(i), eny +(eny))
|
2018-05-15 23:52:54 +03:00
|
|
|
::
|
2018-05-15 07:26:59 +03:00
|
|
|
++ init
|
|
|
|
=/ url
|
2018-05-17 06:08:15 +03:00
|
|
|
'https://acme-staging-v02.api.letsencrypt.org/directory'
|
2018-06-29 03:03:16 +03:00
|
|
|
=< (retry:effect /directory +(now.bow))
|
2018-06-23 06:43:41 +03:00
|
|
|
%= this
|
2018-05-18 19:36:39 +03:00
|
|
|
bas (need (de-purl:html url))
|
2018-05-18 19:58:55 +03:00
|
|
|
act [(rekey eny.bow) ~]
|
|
|
|
cey (rekey (mix eny.bow (shaz now.bow)))
|
2018-05-18 19:36:39 +03:00
|
|
|
==
|
2018-05-17 06:08:15 +03:00
|
|
|
::
|
|
|
|
++ add-order
|
2018-06-29 05:52:35 +03:00
|
|
|
|= dom=(set turf)
|
2018-05-17 06:08:15 +03:00
|
|
|
^+ this
|
2018-06-29 07:01:45 +03:00
|
|
|
?: ?=(?(%earl %pawn) (clan:title our.bow))
|
|
|
|
this
|
|
|
|
:: set pending order
|
|
|
|
::
|
|
|
|
=. pen `dom
|
|
|
|
:: archive active order if exists
|
|
|
|
::
|
|
|
|
:: XX we may have pending moves out for this order
|
|
|
|
:: put dates in wires, check against order creation date?
|
|
|
|
:: or re-use order-id?
|
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
=? fal.hit ?=(^ rod) [u.rod fal.hit]
|
2018-06-29 07:01:45 +03:00
|
|
|
=. rod ~
|
|
|
|
:: if registered, create order
|
|
|
|
::
|
|
|
|
?^ reg.act
|
|
|
|
new-order:effect
|
|
|
|
:: if initialized, defer
|
|
|
|
::
|
|
|
|
?.(=(act *acct) this init)
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
|
|
|
++ test
|
2018-04-27 23:31:18 +03:00
|
|
|
=, tester:tester
|
2018-04-19 09:27:55 +03:00
|
|
|
=/ eny eny.bow
|
|
|
|
:: non-deterministic for now
|
|
|
|
:: 0vhu.gp79o.hi7at.smp8u.g5hhr.u3rff.st8ms.q4dc2.hv5ls.tp5cp.10qds.
|
|
|
|
:: h9bpt.vlmm7.lh375.f6u9n.krqv8.5jcml.cujkr.v1uqv.cjhe5.nplta
|
2018-05-11 22:19:26 +03:00
|
|
|
|^ =/ out=tang
|
2018-04-19 09:27:55 +03:00
|
|
|
;: weld
|
2018-05-16 22:38:50 +03:00
|
|
|
test-rsakey
|
2018-05-09 02:56:56 +03:00
|
|
|
test-rsa
|
2018-04-30 19:17:53 +03:00
|
|
|
test-rsapem
|
2018-05-11 06:13:30 +03:00
|
|
|
test-rsa-pkcs8
|
2018-06-26 21:29:42 +03:00
|
|
|
test-rsa-pem-zero
|
2018-05-08 03:50:00 +03:00
|
|
|
test-rs256
|
2018-05-09 07:03:51 +03:00
|
|
|
test-jwk
|
2018-05-09 20:45:39 +03:00
|
|
|
test-jws
|
2018-06-25 21:07:48 +03:00
|
|
|
test-jws-2
|
2018-05-11 07:53:10 +03:00
|
|
|
test-csr
|
2018-04-19 09:27:55 +03:00
|
|
|
==
|
2018-06-23 06:43:41 +03:00
|
|
|
?~(out this ((slog out) this))
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
2018-05-09 02:56:56 +03:00
|
|
|
++ test-rsakey
|
2018-04-19 09:27:55 +03:00
|
|
|
=/ primes=(list @)
|
|
|
|
:~ 2 3 5 7 11 13 17 19 23 29 31 37 41 43
|
|
|
|
47 53 59 61 67 71 73 79 83 89 97 101 103 107
|
|
|
|
109 113 127 131 137 139 149 151 157 163 167 173 179 181
|
|
|
|
191 193 197 199 211 223 227 229 233 239 241 251 257 263
|
|
|
|
269 271 277 281 283 293 307 311 313 317 331 337 347 349
|
|
|
|
353 359 367 373 379 383 389 397 401 409 419 421 431 433
|
|
|
|
439 443 449 457 461 463 467 479 487 491 499 503 509 521
|
|
|
|
523 541 547 557 563 569 571 577 587 593 599 601 607 613
|
|
|
|
617 619 631 641 643 647 653 659 661 673 677 683 691 701
|
|
|
|
709 719 727 733 739 743 751
|
|
|
|
==
|
|
|
|
=/ k1 (new-key:rsa 2.048 eny)
|
|
|
|
::
|
2018-04-30 21:51:56 +03:00
|
|
|
=/ k2=key:rsa
|
2018-04-19 09:27:55 +03:00
|
|
|
=/ p 0x1837.be57.1286.bf6a.3cf8.4716.634f.ef85.f947.c654.da6e.e222.
|
|
|
|
5654.9466.0ab0.a2ef.1985.1095.e3c3.9e74.9478.e3f3.ee92.f885.ec3c.
|
|
|
|
84c3.6b3c.9731.65f9.9d1d.f743.646f.37d7.82d8.3f4a.856c.6453.b2c8.
|
|
|
|
28d5.d720.145e.c7ab.4ba9.a9c2.6b8e.8819.7aa8.69b3.420f.dbfa.1ddb.
|
|
|
|
4d1a.9c2e.e25a.d4de.d351.945f.d7ca.74a4.815d.5f0e.9f44.df64.39bd
|
|
|
|
=/ q 0xf1bc.ec8f.d238.32d9.afb8.8083.76b3.82da.6274.f56e.1b5b.662b.
|
|
|
|
ab1b.1e01.fbd5.86c5.ba98.b246.b621.f190.2425.25ea.b39f.efa2.4fb8.
|
|
|
|
0d6b.c3c4.460d.e7df.d2f5.6604.51e0.415b.db60.db5a.6601.16c7.46ec.
|
|
|
|
5e67.9195.f3c9.80d3.47c5.fe24.fbfd.43c3.380a.40bd.c4f5.d65e.b93b.
|
|
|
|
60ca.5f26.4ed7.9c64.d26d.b0fe.985d.7be3.1308.34dd.b8c5.4d7c.d8a5
|
|
|
|
=/ n (mul p q)
|
|
|
|
=/ e 0x1.0001
|
|
|
|
=/ d (~(inv fo (elcm:rsa (dec p) (dec q))) e)
|
2018-05-16 22:38:50 +03:00
|
|
|
[[n e] `[d p q]]
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
2018-05-11 22:19:26 +03:00
|
|
|
|^ ^- tang
|
2018-04-19 09:27:55 +03:00
|
|
|
;: weld
|
|
|
|
(check-primes k1)
|
|
|
|
(check-primes k2)
|
|
|
|
==
|
|
|
|
++ check-primes
|
|
|
|
=, number
|
|
|
|
|= k=key:rsa
|
2018-05-16 22:38:50 +03:00
|
|
|
?> ?=(^ sek.k)
|
2018-04-19 09:27:55 +03:00
|
|
|
%+ roll primes
|
2018-05-11 22:19:26 +03:00
|
|
|
|= [p=@ a=tang]
|
2018-04-19 09:27:55 +03:00
|
|
|
?^ a a
|
2018-05-16 22:38:50 +03:00
|
|
|
?: =(0 (mod n.pub.k p))
|
|
|
|
:~ leaf+"{(scow %ux n.pub.k)}"
|
2018-05-11 22:19:26 +03:00
|
|
|
:- %leaf
|
|
|
|
%+ weld
|
2018-05-16 22:38:50 +03:00
|
|
|
"n.pub.key (prime? {(scow %f (pram n.pub.k))})"
|
2018-05-11 22:19:26 +03:00
|
|
|
" divisible by {(scow %ud p)}:"
|
2018-04-19 09:27:55 +03:00
|
|
|
==
|
2018-05-16 22:38:50 +03:00
|
|
|
?: =(0 (mod p.u.sek.k p))
|
|
|
|
:~ leaf+"{(scow %ux p.u.sek.k)}"
|
2018-05-11 22:19:26 +03:00
|
|
|
:- %leaf
|
|
|
|
%+ weld
|
2018-05-16 22:38:50 +03:00
|
|
|
"p.u.sek.key (prime? {(scow %f (pram p.u.sek.k))})"
|
2018-05-11 22:19:26 +03:00
|
|
|
" divisible by {(scow %ud p)}:"
|
2018-04-19 09:27:55 +03:00
|
|
|
==
|
2018-05-16 22:38:50 +03:00
|
|
|
?: =(0 (mod q.u.sek.k p))
|
|
|
|
:~ leaf+"{(scow %ux q.u.sek.k)}"
|
2018-05-11 22:19:26 +03:00
|
|
|
:- %leaf
|
|
|
|
%+ weld
|
2018-05-16 22:38:50 +03:00
|
|
|
"q.u.sek.key (prime? {(scow %f (pram q.u.sek.k))})"
|
2018-05-11 22:19:26 +03:00
|
|
|
" divisible by {(scow %ud p)}:"
|
2018-04-19 09:27:55 +03:00
|
|
|
==
|
|
|
|
~
|
|
|
|
--
|
|
|
|
::
|
2018-05-01 05:15:57 +03:00
|
|
|
++ test-rsapem
|
2018-05-09 02:56:56 +03:00
|
|
|
:: ex from https://stackoverflow.com/a/19855935
|
2018-05-16 22:38:50 +03:00
|
|
|
=/ k1=key:rsa
|
|
|
|
:- [`@ux`187 `@ux`7]
|
|
|
|
[~ `@ux`23 `@ux`17 `@ux`11]
|
2018-05-08 03:50:00 +03:00
|
|
|
=/ kpem1=wain
|
2018-05-01 05:15:57 +03:00
|
|
|
:~ '-----BEGIN RSA PRIVATE KEY-----'
|
|
|
|
'MBwCAQACAgC7AgEHAgEXAgERAgELAgEHAgEDAgEO'
|
|
|
|
'-----END RSA PRIVATE KEY-----'
|
|
|
|
==
|
2018-05-08 03:50:00 +03:00
|
|
|
=/ k2=key:rsa
|
2018-05-16 22:38:50 +03:00
|
|
|
:* [n=`@ux`16.238.973.331.713.186.433 e=`@ux`65.537]
|
|
|
|
~
|
2018-05-08 03:50:00 +03:00
|
|
|
d=`@ux`3.298.243.342.098.580.397
|
2018-05-16 22:38:50 +03:00
|
|
|
p=`@ux`4.140.273.707
|
|
|
|
q=`@ux`3.922.198.019
|
2018-05-08 03:50:00 +03:00
|
|
|
==
|
2018-05-09 02:56:56 +03:00
|
|
|
:: openssl genrsa -out private.pem 64
|
2018-05-08 03:50:00 +03:00
|
|
|
=/ kpem2=wain
|
|
|
|
:~ '-----BEGIN RSA PRIVATE KEY-----'
|
|
|
|
'MEACAQACCQDhXGw1Gc5agQIDAQABAggtxbbYRJVDrQIFAPbHkCsCBQDpx/4DAgUA'
|
|
|
|
'23X55QIFAIpPROsCBQC56nYF'
|
|
|
|
'-----END RSA PRIVATE KEY-----'
|
|
|
|
==
|
2018-05-09 02:56:56 +03:00
|
|
|
:: openssl genrsa -out private.pem 2048
|
2018-05-08 03:50:00 +03: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w+s06qeb8QIKRvkZaIwnA3Lz5UUrxgh96sezdXCCSG'
|
|
|
|
'7FndIFskcT+zG00JL+fPRdlPjt1Vg2b3kneo5aAKMIPyOTzcY590UTc+luQ3HhgS'
|
|
|
|
'iNF3n5YQh24d3kS2YOUoSXQ13+YRljxNfBgXbV+C7/gO8mFxpkafhmgkIGNeWlqT'
|
|
|
|
'9oAIRa+gOx13uPAg+Jb/8lPV9bGaFqGvxvBMp3xUASlzYHiDntcB5MiOPRW6BoIG'
|
|
|
|
'I5qDFSYRZBky9crE7WAYgqtPtg21zvxwFwIDAQAB'
|
|
|
|
'-----END RSA PUBLIC KEY-----'
|
|
|
|
==
|
2018-05-08 03:50:00 +03:00
|
|
|
=/ k3=key:rsa
|
2018-05-17 08:40:22 +03:00
|
|
|
(need (ring:de:pem:pkcs1 kpem3))
|
|
|
|
=/ k3-pub=key:rsa
|
|
|
|
(need (pass:de:pem:pkcs1 kpem3-pub))
|
2018-05-01 06:37:58 +03:00
|
|
|
;: weld
|
|
|
|
%- expect-eq !>
|
2018-05-17 08:40:22 +03:00
|
|
|
[kpem1 (ring:en:pem:pkcs1 k1)]
|
|
|
|
%- expect-eq !>
|
|
|
|
[k1 (need (ring:de:pem:pkcs1 kpem1))]
|
|
|
|
%- expect-eq !>
|
|
|
|
[kpem2 (ring:en:pem:pkcs1 k2)]
|
2018-05-08 03:50:00 +03:00
|
|
|
%- expect-eq !>
|
2018-05-17 08:40:22 +03:00
|
|
|
[k2 (need (ring:de:pem:pkcs1 kpem2))]
|
2018-05-08 03:50:00 +03:00
|
|
|
%- expect-eq !>
|
2018-05-17 08:40:22 +03:00
|
|
|
[kpem3 (ring:en:pem:pkcs1 k3)]
|
2018-05-01 06:37:58 +03:00
|
|
|
%- expect-eq !>
|
2018-05-17 08:40:22 +03:00
|
|
|
[kpem3-pub (pass:en:pem:pkcs1 k3)]
|
2018-05-08 03:50:00 +03:00
|
|
|
%- expect-eq !>
|
2018-05-17 08:40:22 +03:00
|
|
|
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Bi/HgSrZRG0ej'
|
|
|
|
'tBqt9kj5niFurTrkNY3oXVzaGoftNhE8as/bhOVEgn3sf69202XFLsnigBEpQ1mA'
|
|
|
|
'Jk5rWkqrhTOfCB8KTIR0dBTNv9VyMR/cwhkMgqXzAoGAGuwiOIO+mR+emZDt96EQ'
|
|
|
|
'kiL5XhIayQvEUfdlO+eAUWhivLd0vmBDqYWwN+ufiKAhwTLpsyklDeVvBK3LNxZk'
|
|
|
|
'swmB0jbcVOU9dMQbs9yVlK7EGlCm+DcyJU7OpVOuGdj5N6ZxJxLHk7p/fZoN85RZ'
|
|
|
|
'YLObD+DO8nFRiUmqOp3t2VM='
|
2018-06-27 08:15:35 +03:00
|
|
|
'-----END PRIVATE KEY-----'
|
|
|
|
==
|
2018-05-11 06:13:30 +03:00
|
|
|
=/ k=key:rsa
|
2018-05-17 08:40:22 +03:00
|
|
|
(need (ring:de:pem:pkcs1 kpem))
|
2018-06-27 08:15:35 +03:00
|
|
|
;: weld
|
|
|
|
%- expect-eq !>
|
|
|
|
[pub (pass:en:pem:pkcs8 k)]
|
|
|
|
%- expect-eq !>
|
|
|
|
[`k(sek ~) (pass:de:pem:pkcs8 pub)]
|
|
|
|
%- expect-eq !>
|
|
|
|
[pri (ring:en:pem:pkcs8 k)]
|
|
|
|
%- expect-eq !>
|
|
|
|
[`k (ring:de:pem:pkcs8 pri)]
|
|
|
|
==
|
2018-05-11 06:13:30 +03:00
|
|
|
::
|
2018-06-26 21:29:42 +03:00
|
|
|
++ test-rsa-pem-zero
|
|
|
|
:: intentional bad values to test significant trailing zeros
|
|
|
|
=/ k=key:rsa [[n=(bex 16) e=(bex 16)] ~]
|
|
|
|
:: pkcs1
|
|
|
|
=/ kpem=wain
|
|
|
|
:~ '-----BEGIN RSA PUBLIC KEY-----'
|
|
|
|
'MAoCAwEAAAIDAQAA'
|
|
|
|
'-----END RSA PUBLIC KEY-----'
|
|
|
|
==
|
|
|
|
:: pkcs8
|
|
|
|
=/ kpem2=wain
|
|
|
|
:~ '-----BEGIN PUBLIC KEY-----'
|
|
|
|
'MB4wDQYJKoZIhvcNAQEBBQADDQAwCgIDAQAAAgMBAAA='
|
|
|
|
'-----END PUBLIC KEY-----'
|
|
|
|
==
|
|
|
|
;: weld
|
|
|
|
%- expect-eq !>
|
|
|
|
[kpem (pass:en:pem:pkcs1 k)]
|
|
|
|
%- expect-eq !>
|
|
|
|
[`k (pass:de:pem:pkcs1 kpem)]
|
|
|
|
%- expect-eq !>
|
|
|
|
[kpem2 (pass:en:pem:pkcs8 k)]
|
|
|
|
%- expect-eq !>
|
|
|
|
[`k (pass:de:pem:pkcs8 kpem2)]
|
|
|
|
==
|
|
|
|
::
|
2018-05-09 02:56:56 +03:00
|
|
|
++ test-rsa
|
2018-04-30 21:51:56 +03:00
|
|
|
=/ k1=key:rsa
|
|
|
|
=/ p `@ux`61
|
|
|
|
=/ q `@ux`53
|
|
|
|
=/ e `@ux`17
|
2018-04-19 09:27:55 +03:00
|
|
|
=/ n (mul p q)
|
|
|
|
=/ d (~(inv fo (elcm:rsa (dec p) (dec q))) e)
|
2018-05-16 22:38:50 +03:00
|
|
|
[[n e] `[d p q]]
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
2018-05-16 22:38:50 +03:00
|
|
|
=/ k2=key:rsa
|
|
|
|
:- [`@ux`143 `@ux`7]
|
|
|
|
[~ `@ux`103 `@ux`11 `@ux`13]
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
2018-05-09 02:56:56 +03:00
|
|
|
:: ex from http://doctrina.org/How-RSA-Works-With-Examples.html
|
2018-04-30 21:51:56 +03:00
|
|
|
=/ k3=key:rsa
|
2018-04-19 09:27:55 +03:00
|
|
|
=/ p
|
|
|
|
12.131.072.439.211.271.897.323.671.531.612.440.428.472.427.633.701.410.
|
|
|
|
925.634.549.312.301.964.373.042.085.619.324.197.365.322.416.866.541.
|
|
|
|
017.057.361.365.214.171.711.713.797.974.299.334.871.062.829.803.541
|
|
|
|
=/ q
|
|
|
|
12.027.524.255.478.748.885.956.220.793.734.512.128.733.387.803.682.075.
|
|
|
|
433.653.899.983.955.179.850.988.797.899.869.146.900.809.131.611.153.
|
|
|
|
346.817.050.832.096.022.160.146.366.346.391.812.470.987.105.415.233
|
|
|
|
=/ n (mul p q)
|
|
|
|
=/ e 65.537
|
|
|
|
=/ d (~(inv fo (elcm:rsa (dec p) (dec q))) e)
|
2018-05-16 22:38:50 +03:00
|
|
|
[[`@ux`n `@ux`e] `[`@ux`d `@ux`p `@ux`q]]
|
2018-04-19 09:27:55 +03:00
|
|
|
=/ m3 (swp 3 'attack at dawn')
|
|
|
|
=/ c3
|
|
|
|
35.052.111.338.673.026.690.212.423.937.053.328.511.880.760.811.579.981.
|
|
|
|
620.642.802.346.685.810.623.109.850.235.943.049.080.973.386.241.113.
|
|
|
|
784.040.794.704.193.978.215.378.499.765.413.083.646.438.784.740.952.
|
|
|
|
306.932.534.945.195.080.183.861.574.225.226.218.879.827.232.453.912.
|
|
|
|
820.596.886.440.377.536.082.465.681.750.074.417.459.151.485.407.445.
|
|
|
|
862.511.023.472.235.560.823.053.497.791.518.928.820.272.257.787.786
|
|
|
|
::
|
2018-05-16 22:38:50 +03:00
|
|
|
?> ?=(^ sek.k1)
|
2018-04-19 09:27:55 +03:00
|
|
|
;: weld
|
|
|
|
%- expect-eq !>
|
2018-05-16 22:38:50 +03:00
|
|
|
[413 d.u.sek.k1]
|
2018-04-19 09:27:55 +03:00
|
|
|
%- expect-eq !>
|
|
|
|
[2.790 (en:rsa 65 k1)]
|
|
|
|
%- expect-eq !>
|
|
|
|
[65 (de:rsa 2.790 k1)]
|
|
|
|
::
|
|
|
|
%- expect-eq !>
|
|
|
|
[48 (en:rsa 9 k2)]
|
|
|
|
%- expect-eq !>
|
|
|
|
[9 (de:rsa 48 k2)]
|
|
|
|
::
|
|
|
|
%- expect-eq !>
|
|
|
|
[c3 (en:rsa m3 k3)]
|
|
|
|
%- expect-eq !>
|
|
|
|
[m3 (de:rsa c3 k3)]
|
|
|
|
==
|
2018-04-27 23:31:18 +03:00
|
|
|
::
|
2018-05-08 03:50:00 +03:00
|
|
|
++ test-rs256
|
2018-05-09 02:56:56 +03:00
|
|
|
:: ex from https://stackoverflow.com/a/41448118
|
2018-05-08 21:02:56 +03:00
|
|
|
=/ k1=key:rsa
|
2018-05-16 22:38:50 +03:00
|
|
|
:* :- n=0xc231.1fc5.fa31.d333.a409.bb4c.e95b.20d2.1cfc.e375.3871.7256.53a2.
|
2018-05-08 21:02:56 +03:00
|
|
|
8425.af6d.e97d.f202.0b23.633f.458d.f12a.6362.7121.bff4.e23c.e578.
|
|
|
|
7e07.7898.0578.61d1.ae60.ac2f
|
2018-05-16 22:38:50 +03:00
|
|
|
e=0x1.0001
|
|
|
|
~
|
|
|
|
d=0xd91.6719.eb10.3e24.768a.a386.8d2b.6bd0.a26b.dcec.9cc3.f86c.25ad.
|
2018-05-08 21:02:56 +03:00
|
|
|
ce33.dfdc.fb1a.4d50.3e07.3d7f.f5fd.748e.43f8.df02.a60e.d730.5314.
|
|
|
|
3e59.1e70.8df7.2c27.93e2.2b69
|
2018-05-16 22:38:50 +03:00
|
|
|
p=0xf7ef.37e6.7fa6.685a.c178.8b01.cf38.da20.ca4b.de5d.8b01.a71b.d28c.
|
|
|
|
65b4.09c3.6e4d
|
|
|
|
q=0xc882.5760.3fb8.a5e2.5e9d.db55.3a73.b647.a3ec.a6e9.abc6.c440.dbc7.
|
|
|
|
05f8.2ed4.da6b
|
2018-05-08 21:02:56 +03:00
|
|
|
==
|
|
|
|
=/ inp1 0x302.0101
|
|
|
|
=/ exp1
|
|
|
|
0x575c.8a41.09ed.6ea2.a708.6338.d150.a5bb.8205.142e.7785.47b5.0cc6.0198.
|
|
|
|
6807.0243.bf49.de7c.6039.0160.e392.faca.18f4.a05d.3a7a.88a4.de86.dd99.
|
|
|
|
f030.eb4a.a755.d7ce
|
2018-05-09 02:56:56 +03:00
|
|
|
=/ emsa1
|
|
|
|
0x1.ffff.ffff.ffff.ffff.ffff.0030.3130.0d06.0960.8648.0165.0304.0201.0500.
|
|
|
|
0420.9184.abd2.bb31.8731.d717.e972.0572.40ea.e26c.ca20.2a8d.35db.e9d2.
|
|
|
|
176f.5268.86a0
|
2018-05-08 21:02:56 +03:00
|
|
|
=/ kpem2=wain
|
|
|
|
:~ '-----BEGIN RSA PRIVATE KEY-----'
|
|
|
|
'MIIEowIBAAKCAQEA2jJp8dgAKy5cSzDE4D+aUbKZsQoMhIWI2IFlE+AO0GCBMig5'
|
|
|
|
'qxx2IIAPVIcSi5fjOLtTHnuIZYw+s06qeb8QIKRvkZaIwnA3Lz5UUrxgh96sezdX'
|
|
|
|
'CCSG7FndIFskcT+zG00JL+fPRdlPjt1Vg2b3kneo5aAKMIPyOTzcY590UTc+luQ3'
|
|
|
|
'HhgSiNF3n5YQh24d3kS2YOUoSXQ13+YRljxNfBgXbV+C7/gO8mFxpkafhmgkIGNe'
|
|
|
|
'WlqT9oAIRa+gOx13uPAg+Jb/8lPV9bGaFqGvxvBMp3xUASlzYHiDntcB5MiOPRW6'
|
|
|
|
'BoIGI5qDFSYRZBky9crE7WAYgqtPtg21zvxwFwIDAQABAoIBAH0q7GGisj4TIziy'
|
|
|
|
'6k1lzwXMuaO4iwO+gokIeU5UessIgTSfpK1G73CnZaPstDPF1r/lncHfxZfTQuij'
|
|
|
|
'WOHsO7kt+x5+R0ebDd0ZGVA45fsrPrCUR2XRZmDRECuOfTJGA13G7F1B0kJUbfIb'
|
|
|
|
'gAGYIK8x236WNyIrntk804SGpTgstCsZ51rK5GL6diZVQbeU806oP1Zhx/ye//NR'
|
|
|
|
'mS5G0iil//H41pV5WGomOX0mq9/HYBZqCncqzLki6FFdmXykjz8snvXUR40S8B+a'
|
|
|
|
'0F/LN+549PSe2dp9h0Hx4HCJOsL9CyCQimqqqE8KPQ4BUz8q3+Mhx1xEyaxIlNH9'
|
|
|
|
'ECgo1CECgYEA+mi7vQRzstYJerbhCtaeFrOR/n8Dft7FyFN+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|
|
(need (ring:de:pem:pkcs1 kpem2))
|
2018-05-08 21:02:56 +03:00
|
|
|
=/ inp2=cord 'hello\0a'
|
|
|
|
=/ exp2=@ux
|
|
|
|
0x2920.bba3.cb38.bca6.3768.6345.c95e.0717.81bf.6c61.4006.6070.a7b5.e609.
|
|
|
|
f3b4.7f48.878b.d1f8.1882.8852.1db6.b6b5.a5fd.c23b.e764.b910.5a3f.fda9.
|
|
|
|
9d3a.e8bd.060a.ac06.58f1.487a.b50d.dee2.e161.0b74.4d3b.e6e3.7004.c721.
|
|
|
|
4f32.5c95.ce68.a008.b1e9.788b.375f.d389.0fa4.4012.c07a.8319.a183.02d5.
|
|
|
|
e2b8.10df.6ff7.f64a.6b85.3c7d.de80.19cf.ab6d.e588.40cb.0ea4.c436.8d8b.
|
|
|
|
47f7.cce6.b9bf.097d.3275.c128.147a.628d.2b7c.3912.3950.ef68.87b2.180d.
|
|
|
|
ba01.3b05.285d.3dfd.09ee.2f38.3111.9e4c.92c6.bf66.a91b.5762.3cdf.f8b7.
|
|
|
|
8281.81a2.8324.5330.43c1.035a.56c3.71b8.eb85.e660.c3a4.28b4.8af7.c16f.
|
|
|
|
7d7d.87cc.036d.aeb2.c757.30f5.f194.c90d.6bb4.5e5c.f95f.8e28.0fbc.5fb4.
|
|
|
|
b21a.e6fe
|
|
|
|
=/ exp2b64=cord
|
|
|
|
%+ rap 3
|
|
|
|
:~ 'KSC7o8s4vKY3aGNFyV4HF4G/bGFABmBwp7XmCfO0f0iHi9H4GIKIUh22trWl/cI752S5'
|
|
|
|
'EFo//amdOui9BgqsBljxSHq1Dd7i4WELdE075uNwBMchTzJclc5ooAix6XiLN1/TiQ+k'
|
|
|
|
'QBLAeoMZoYMC1eK4EN9v9/ZKa4U8fd6AGc+rbeWIQMsOpMQ2jYtH98zmub8JfTJ1wSgU'
|
|
|
|
'emKNK3w5EjlQ72iHshgNugE7BShdPf0J7i84MRGeTJLGv2apG1diPN/4t4KBgaKDJFMw'
|
|
|
|
'Q8EDWlbDcbjrheZgw6QotIr3wW99fYfMA22ussdXMPXxlMkNa7ReXPlfjigPvF+0shrm'
|
|
|
|
'/g=='
|
|
|
|
==
|
|
|
|
=/ sig=@ux (~(sign rs256 k2) inp2)
|
|
|
|
;: weld
|
|
|
|
%- expect-eq !>
|
|
|
|
[exp1 (~(sign rs256 k1) inp1)]
|
|
|
|
%- expect-eq !>
|
|
|
|
[& (~(verify rs256 k1) exp1 inp1)]
|
2018-05-09 02:56:56 +03:00
|
|
|
%- expect-eq !>
|
|
|
|
[emsa1 `@ux`(~(emsa rs256 k1) inp1)]
|
2018-05-08 21:02:56 +03:00
|
|
|
%- expect-eq !>
|
2018-05-11 18:03:56 +03:00
|
|
|
[& (~(verify rs256 k2) sig inp2)]
|
2018-05-08 21:02:56 +03:00
|
|
|
%- expect-eq !>
|
|
|
|
[exp2 sig]
|
|
|
|
:: save kpem2 to private.pem
|
|
|
|
:: echo "hello" | openssl dgst -sha256 -sign private.pem | base64
|
|
|
|
%- expect-eq !>
|
2018-06-26 08:10:19 +03:00
|
|
|
[exp2b64 (en:base64 (met 3 sig) (swp 3 sig))]
|
2018-05-08 21:02:56 +03:00
|
|
|
==
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
2018-05-09 07:03:51 +03:00
|
|
|
++ test-jwk
|
2018-05-09 02:56:56 +03:00
|
|
|
:: rfc7638 section 3.1
|
2018-04-24 08:49:21 +03:00
|
|
|
=/ n
|
2018-04-19 09:27:55 +03:00
|
|
|
:~ '0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2'
|
|
|
|
'aiAFbWhM78LhWx4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCi'
|
|
|
|
'FV4n3oknjhMstn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65Y'
|
|
|
|
'GjQR0_FDW2QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n'
|
|
|
|
'91CbOpbISD08qNLyrdkt-bFTWhAI4vMQFh6WeZu0fM4lFd2NcRwr3XPksINHaQ-G_x'
|
|
|
|
'BniIqbw0Ls1jF44-csFCur-kEgU8awapJzKnqDKgw'
|
|
|
|
==
|
2018-05-09 07:03:51 +03:00
|
|
|
=/ jk=json
|
2018-04-19 09:27:55 +03:00
|
|
|
:- %o %- my :~
|
|
|
|
kty+s+'RSA'
|
2018-04-24 08:49:21 +03:00
|
|
|
n+s+(rap 3 n)
|
2018-05-09 20:45:39 +03:00
|
|
|
e+s+'AQAB'
|
2018-04-19 09:27:55 +03:00
|
|
|
==
|
2018-05-09 07:03:51 +03:00
|
|
|
=/ k (need (pass:de:jwk jk))
|
|
|
|
;: weld
|
|
|
|
%- expect-eq !>
|
|
|
|
:- jk
|
2018-05-16 22:38:50 +03:00
|
|
|
(pass:en:jwk k)
|
2018-05-09 07:03:51 +03:00
|
|
|
%- expect-eq !>
|
|
|
|
:- 'NzbLsXh8uDCcd-6MNwXF4W_7noWXFZAfHkxZsRGC9Xs'
|
2018-05-17 19:36:29 +03:00
|
|
|
(pass:thumb:jwk k)
|
2018-05-09 07:03:51 +03:00
|
|
|
==
|
2018-04-24 08:49:21 +03:00
|
|
|
::
|
2018-05-09 02:56:56 +03:00
|
|
|
++ test-jws
|
2018-05-09 20:45:39 +03:00
|
|
|
:: rfc7515 appendix 2
|
2018-04-19 09:27:55 +03:00
|
|
|
=/ pt=@t
|
2018-04-24 08:49:21 +03:00
|
|
|
%+ rap 3
|
|
|
|
:~ '4BzEEOtIpmVdVEZNCqS7baC4crd0pqnRH_5IB3jw3bcxGn6QLvnEtfdUdi'
|
|
|
|
'YrqBdss1l58BQ3KhooKeQTa9AB0Hw_Py5PJdTJNPY8cQn7ouZ2KKDcmnPG'
|
|
|
|
'BY5t7yLc1QlQ5xHdwW1VhvKn-nXqhJTBgIPgtldC-KDV5z-y2XDwGUc'
|
|
|
|
==
|
2018-04-19 09:27:55 +03:00
|
|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pRLI9JYanrC4D4qAdGcopV_0ZHHzQlBjudU2QvXt4ehNYT'
|
|
|
|
'CBr6XCLQUShb1juUO1ZdiYoFaFQT5Tw8bGUl_x_jTj3ccPDVZFD9pIuhLh'
|
|
|
|
'BOneufuBiB4cS98l2SR_RQyGWSeWjnczT0QU91p1DhOVRuOopznQ'
|
|
|
|
==
|
2018-05-09 20:45:39 +03:00
|
|
|
=/ jk=json
|
|
|
|
:- %o %- my :~
|
|
|
|
kty+s+'RSA'
|
|
|
|
n+s+nt
|
|
|
|
e+s+'AQAB'
|
|
|
|
d+s+dt
|
|
|
|
p+s+pt
|
|
|
|
q+s+qt
|
|
|
|
==
|
|
|
|
=/ k=key:rsa (need (ring:de:jwk jk))
|
2018-04-19 09:27:55 +03:00
|
|
|
=/ hed=json o+(my alg+s+'RS256' ~)
|
2018-05-09 20:45:39 +03:00
|
|
|
=/ hedt=@t 'eyJhbGciOiJSUzI1NiJ9'
|
2018-04-19 09:27:55 +03:00
|
|
|
=/ lod=json
|
|
|
|
:- %o %- my :~
|
|
|
|
iss+s+'joe'
|
|
|
|
exp+n+'1300819380'
|
|
|
|
['http://example.com/is_root' %b &]
|
|
|
|
==
|
2018-05-09 20:45:39 +03:00
|
|
|
=/ lodt=@t
|
|
|
|
%+ rap 3
|
|
|
|
:~ 'eyJpc3MiOiJqb2UiLCJleHAiOjEzMDA4MTkzODAsImh0dHA'
|
|
|
|
'6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ'
|
2018-04-24 08:49:21 +03:00
|
|
|
==
|
2018-05-09 20:45:39 +03:00
|
|
|
:: rfc example includes whitespace in json serialization
|
|
|
|
=/ lodt-ws=@t
|
|
|
|
%+ rap 3
|
|
|
|
:~ 'eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQo'
|
|
|
|
'gImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ'
|
|
|
|
==
|
|
|
|
=/ inp-ws=@t
|
|
|
|
(rap 3 [hedt '.' lodt-ws ~])
|
|
|
|
=/ exp-ws=@t
|
2018-04-24 08:49:21 +03:00
|
|
|
%+ rap 3
|
|
|
|
:~ 'cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7'
|
|
|
|
'AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4'
|
|
|
|
'BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K'
|
|
|
|
'0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqv'
|
|
|
|
'hJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrB'
|
|
|
|
'p0igcN_IoypGlUPQGe77Rw'
|
|
|
|
==
|
2018-05-09 20:45:39 +03:00
|
|
|
=/ lod-order=(list @t) ['iss' 'exp' 'http://example.com/is_root' ~]
|
2018-05-16 22:38:50 +03:00
|
|
|
?> ?=(^ sek.k)
|
2018-04-19 09:27:55 +03:00
|
|
|
;: weld
|
|
|
|
%- expect-eq !>
|
2018-05-09 20:45:39 +03:00
|
|
|
[jk (ring:en:jwk k)]
|
2018-04-24 08:49:21 +03:00
|
|
|
%- expect-eq !>
|
2018-05-16 22:38:50 +03:00
|
|
|
[n.pub.k `@ux`(mul p.u.sek.k q.u.sek.k)]
|
2018-04-24 08:49:21 +03:00
|
|
|
%- expect-eq !>
|
2018-05-16 22:38:50 +03:00
|
|
|
:- d.u.sek.k
|
|
|
|
`@ux`(~(inv fo (elcm:rsa (dec p.u.sek.k) (dec q.u.sek.k))) e.pub.k)
|
2018-04-24 08:49:21 +03:00
|
|
|
%- expect-eq !>
|
2018-05-09 20:45:39 +03:00
|
|
|
:- hedt
|
2018-06-26 08:10:19 +03:00
|
|
|
(en-base64url (as-octt:mimes:html (en-json-sort aor hed)))
|
2018-04-24 08:49:21 +03:00
|
|
|
%- expect-eq !>
|
2018-05-09 20:45:39 +03:00
|
|
|
:- lodt
|
2018-06-26 08:10:19 +03:00
|
|
|
(en-base64url (as-octt:mimes:html (en-json-sort (eor lte lod-order) lod)))
|
2018-04-24 08:49:21 +03:00
|
|
|
%- expect-eq !>
|
2018-05-09 20:45:39 +03:00
|
|
|
:- exp-ws
|
2018-06-26 08:10:19 +03:00
|
|
|
(en-base64url (en:octn (~(sign rs256 k) inp-ws)))
|
2018-04-19 09:27:55 +03:00
|
|
|
==
|
2018-06-24 07:45:20 +03:00
|
|
|
::
|
2018-06-25 21:07:48 +03:00
|
|
|
++ test-jws-2
|
|
|
|
:: captured from an in-the-wild failure
|
|
|
|
:: relevant sha-256 has a significant leading zero
|
|
|
|
:: which was not being captured in the asn.1 digest ...
|
2018-06-24 07:45:20 +03:00
|
|
|
=/ kpem=wain
|
|
|
|
:~ '-----BEGIN RSA PRIVATE KEY-----'
|
|
|
|
'MIIEogIBAAKCAQEAkmWLu+9gyzCbrGAHTFE6Hs7CtVQofONmpnhmE7JQkmdS+aph'
|
|
|
|
'WwZQfp9p6RU6vSoBaPXD96uqMXhvoOXz9/Ub5TRwLmQzfHZdksfU3pEZ8qFMikZU'
|
|
|
|
'p5v+CyBnLq9YR0VXN+/JVatmYb1hhC1k101X9m+IU3DR3U+kyCZnXuOd10xVX05H'
|
|
|
|
'0pXl+nI25bZyMJFnz1Xfw1rTnhtU/w7bgCWYdMii5jLkl5zfoY2gulpPu7QeYa4K'
|
|
|
|
'3fTqklDNFK7kQQ1l4O3461fbSO0cnG4t8Vk3026ageA54+Qx8O8UDi8k18Z1NF+B'
|
|
|
|
'pbPUZn55/InuZ8iGyHBZ4GRFIPG0iOdWM7gHCwIDAQABAoIBAAMQN/9SS6MJMULq'
|
|
|
|
'CsXHxyl5sHtXa/BgWLHP+j2/FtRX++EkR0s+ln2FobZa+l5Q9m4Ljn5PbqSMAFfM'
|
|
|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uk6/IZ0nZV1X9RHuS4w6U6xCsiJbwH1D'
|
|
|
|
'r/bvAoGAV/Vx+Z2BD7QhmHofu98OMW6EGSjWMgOI4iXdcQ80Urz9akHkOM4KGojq'
|
|
|
|
'UDobbxxkJt1K5Dzux+vnp1siiIkcLdVdtMzqo7KcKYWonMqZmppNqIFCXQHscCRD'
|
|
|
|
'r6f1TIjlurYrazLAkRsmjE5uYM13/E1UdxplWSkdCbivIWqoqTM='
|
|
|
|
'-----END RSA PRIVATE KEY-----'
|
|
|
|
==
|
|
|
|
=/ k=key:rsa
|
|
|
|
(need (ring:de:pem:pkcs1 kpem))
|
|
|
|
=/ kid=@t
|
|
|
|
'https://acme-staging-v02.api.letsencrypt.org/acme/acct/6336694'
|
|
|
|
=/ non=@t
|
|
|
|
'a5Pwh6GcuqRSvHTQouW96XNg3iiMORMkBf_wSLOf0M4'
|
|
|
|
=/ url=purl
|
|
|
|
:- [sec=%.y por=~ hot=[%.y p=/org/letsencrypt/api/acme-staging-v02]]
|
|
|
|
:_ query=~
|
|
|
|
:- ext=~
|
|
|
|
%+ weld
|
|
|
|
/acme/challenge
|
|
|
|
/'efJn0ywfjIi3M7yT-6H8Mdq85R2LnI8XsTG3DaaY8Gc'/'138087558'
|
|
|
|
=/ protected-header=json
|
|
|
|
:- %o %- my :~
|
|
|
|
nonce+s+non
|
|
|
|
url+s+(crip (en-purl:html url))
|
|
|
|
kid+s+kid
|
|
|
|
==
|
|
|
|
=/ bod=json
|
|
|
|
[%o ~]
|
|
|
|
=/ exp=json
|
|
|
|
=/ payload=@t 'e30'
|
|
|
|
=/ protected=@t
|
|
|
|
%+ rap 3
|
|
|
|
:~ 'eyJhbGci'
|
|
|
|
'OiJSUzI1NiIsImtpZCI6Imh0dHBzOi8vYWNtZS1zdGFnaW5nLXYwMi5hcGkubGV0c2'
|
|
|
|
'VuY3J5cHQub3JnL2FjbWUvYWNjdC82MzM2Njk0Iiwibm9uY2UiOiJhNVB3aDZHY3Vx'
|
|
|
|
'UlN2SFRRb3VXOTZYTmczaWlNT1JNa0JmX3dTTE9mME00IiwidXJsIjoiaHR0cHM6Ly'
|
|
|
|
'9hY21lLXN0YWdpbmctdjAyLmFwaS5sZXRzZW5jcnlwdC5vcmcvYWNtZS9jaGFsbGVu'
|
|
|
|
'Z2UvZWZKbjB5d2ZqSWkzTTd5VC02SDhNZHE4NVIyTG5JOFhzVEczRGFhWThHYy8xMz'
|
|
|
|
'gwODc1NTgifQ'
|
|
|
|
==
|
|
|
|
=/ signature=@t
|
|
|
|
%+ rap 3
|
2018-06-25 21:07:48 +03:00
|
|
|
:~ 'cukOS_KIWTolvORyJoIu5eejdLoFi6xpd06Y6nW565zFMKZi44BepsWIZXw4yxYjxs'
|
|
|
|
'8xFdoKOxtXhBS5BT0mbkHSUGokAPTUiF5b1wjm00ZiKRYwnIotizsLPzHAJKwhMlFs'
|
|
|
|
'x6oAu25mmremBgnNtVD_cskQBbkTBgiTL6alrkrmwxlP2gSqyX6uEO-UCY71QB_xYj'
|
|
|
|
'4IOoX2k0jdXJevXDAJSUWfs5cZkm8Ug_q4GVTRWhZmFHMnMzonmCC4Ui7nDa9oKJH5'
|
|
|
|
'Npyn74FCcqbz111AK-Aul1dNhz3ojE1VOk3eVjH69lSGsaMleYR5fi60Jdc5ZbpPPy'
|
|
|
|
't-CZRp1F0k6w'
|
2018-06-24 07:45:20 +03:00
|
|
|
==
|
|
|
|
[%o (my payload+s+payload protected+s+protected signature+s+signature ~)]
|
|
|
|
%- expect-eq !>
|
|
|
|
:- exp
|
|
|
|
(sign:jws k protected-header bod)
|
2018-05-11 07:53:10 +03:00
|
|
|
::
|
|
|
|
++ test-csr
|
|
|
|
=/ kpem=wain
|
|
|
|
:~ '-----BEGIN RSA PRIVATE KEY-----'
|
|
|
|
'MIIEowIBAAKCAQEA2jJp8dgAKy5cSzDE4D+aUbKZsQoMhIWI2IFlE+AO0GCBMig5'
|
|
|
|
'qxx2IIAPVIcSi5fjOLtTHnuIZYw+s06qeb8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
|
|
|
|
'mFl3DRBFutFQ2YxddqHbE3Ds96Y/uRXhqj7I16cCgYEA1AVNwHM+i1OS3yZtUUH6'
|
|
|
|
'xPnySWu9x/RTvpSDwnYKk8TLaHDH0Y//6y3Y7RqK6Utjmv1E+54/0d/B3imyrsG/'
|
|
|
|
'wWrj+SQdPO9VJ/is8XZQapnU4cs7Q19b+AhqJq58un2n+1e81J0oGPC47X3BHZTc'
|
|
|
|
'5VSyMpvwiqu0WmTMQT37cCECgYACMEbt8XY6bjotz13FIemERNNwXdPUe1XFR61P'
|
|
|
|
'ze9lmavj1GD7JIY2wYvx4Eq2URtHo7QarfZI+Z4hbq065DWN6F1c2hqH7TYRPGrP'
|
|
|
|
'24TlRIJ97H+vdtNlxS7J4oARKUNZgCZOa1pKq4UznwgfCkyEdHQUzb/VcjEf3MIZ'
|
|
|
|
'DIKl8wKBgBrsIjiDvpkfnpmQ7fehEJIi+V4SGskLxFH3ZTvngFFoYry3dL5gQ6mF'
|
|
|
|
'sDfrn4igIcEy6bMpJQ3lbwStyzcWZLMJgdI23FTlPXTEG7PclZSuxBpQpvg3MiVO'
|
|
|
|
'zqVTrhnY+TemcScSx5O6f32aDfOUWWCzmw/gzvJxUYlJqjqd7dlT'
|
|
|
|
'-----END RSA PRIVATE KEY-----'
|
|
|
|
==
|
|
|
|
=/ k=key:rsa
|
2018-05-17 08:40:22 +03:00
|
|
|
(need (ring:de:pem:pkcs1 kpem))
|
2018-05-11 07:53:10 +03:00
|
|
|
:: generated with openssl, certbot style
|
|
|
|
=/ csr-pem=wain
|
|
|
|
:~ '-----BEGIN CERTIFICATE REQUEST-----'
|
|
|
|
'MIICezCCAWMCAQAwADCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANoy'
|
|
|
|
'afHYACsuXEswxOA/mlGymbEKDISFiNiBZRPgDtBggTIoOascdiCAD1SHEouX4zi7'
|
|
|
|
'Ux57iGWMPrNOqnm/ECCkb5GWiMJwNy8+VFK8YIferHs3Vwgk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