[rs-dev] Draft RFC: Signed Public Key and Challenge
Dirk-Willem van Gulik
dirkx at webweaving.org
Thu Mar 5 15:13:44 CET 2020
On 5 Mar 2020, at 14:52, Graham Leggett <minfrin at redwax.eu> wrote:
> On 05 Mar 2020, at 14:47, Dirk-Willem van Gulik <dirkx at webweaving.org <mailto:dirkx at webweaving.org>> wrote:
>
>>> I eventually had luck with the OSS Nokalva using a trial license:
>>
>> Spendid !
>>
>>> The updated draft looks like this:
>>>
>>> https://source.redwax.eu/svn/redwax/std/spkac/trunk/draft-leggett-spkac-00.txt <https://source.redwax.eu/svn/redwax/std/spkac/trunk/draft-leggett-spkac-00.txt>
> Using the following openssl patch:
>
> Little-Net:openssl-spkac-md minfrin$ svn diff
> Index: apps/spkac.c
> ===================================================================
> --- apps/spkac.c (revision 40679)
> +++ apps/spkac.c (working copy)
> @@ -23,7 +23,7 @@
> typedef enum OPTION_choice {
> OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
> OPT_NOOUT, OPT_PUBKEY, OPT_VERIFY, OPT_IN, OPT_OUT,
> - OPT_ENGINE, OPT_KEY, OPT_CHALLENGE, OPT_PASSIN, OPT_SPKAC,
> + OPT_ENGINE, OPT_KEY, OPT_CHALLENGE, OPT_MD, OPT_PASSIN, OPT_SPKAC,
> OPT_SPKSECT, OPT_KEYFORM
> } OPTION_CHOICE;
>
> @@ -42,6 +42,7 @@
> {"keyform", OPT_KEYFORM, 'f', "Private key file format - default PEM (PEM, DER, or ENGINE)"},
> {"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
> {"challenge", OPT_CHALLENGE, 's', "Challenge string"},
> + {"md", OPT_MD, 's', "Digest algorithm to use when signing - default MD5, SHA256 recommended"},
> {"spkac", OPT_SPKAC, 's', "Alternative SPKAC name"},
>
> OPT_SECTION("Output"),
> @@ -59,6 +60,7 @@
> ENGINE *e = NULL;
> EVP_PKEY *pkey = NULL;
> NETSCAPE_SPKI *spki = NULL;
> + const EVP_MD *sign_md = EVP_md5();
> char *challenge = NULL, *keyfile = NULL;
> char *infile = NULL, *outfile = NULL, *passinarg = NULL, *passin = NULL;
> char *spkstr = NULL, *prog;
> @@ -107,6 +109,10 @@
> case OPT_CHALLENGE:
> challenge = opt_arg();
> break;
> + case OPT_MD:
> + if (!opt_md(opt_arg(), &sign_md))
> + goto opthelp;
> + break;
> case OPT_SPKAC:
> spkac = opt_arg();
> break;
> @@ -139,7 +145,7 @@
> ASN1_STRING_set(spki->spkac->challenge,
> challenge, (int)strlen(challenge));
> NETSCAPE_SPKI_set_pubkey(spki, pkey);
> - NETSCAPE_SPKI_sign(spki, pkey, EVP_md5());
> + NETSCAPE_SPKI_sign(spki, pkey, sign_md);
> spkstr = NETSCAPE_SPKI_b64_encode(spki);
> if (spkstr == NULL)
> goto end;
> Index: doc/man1/openssl-spkac.pod.in
> ===================================================================
> --- doc/man1/openssl-spkac.pod.in (revision 40679)
> +++ doc/man1/openssl-spkac.pod.in (working copy)
> @@ -20,6 +20,7 @@
> [B<-passin> I<arg>]
> [B<-challenge> I<string>]
> [B<-pubkey>]
> +[B<-md>]
> [B<-spkac> I<spkacname>]
> [B<-spksect> I<section>]
> [B<-noout>]
> @@ -93,6 +94,11 @@
> Output the public key of an SPKAC (not used if an SPKAC is
> being created).
>
> +=item B<-md>
> +
> +The message digest used for signing. Historically the default value has
> +been MD5, but SHA256 is recommended.
> +
> =item B<-verify>
>
> Verifies the digital signature on the supplied SPKAC.
>
> We are able to generate and verify an SPKAC using SHA256 as a digest algorithm:
>
> Little-Net:openssl-spkac-md minfrin$ /tmp/httpd-trunk/bin/openssl spkac -challenge challenge -key ~/ca/pepperpot/pepperpot.media.key -md sha256
> SPKAC=MIIESTCCAjEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9wmyQidBwnIN308UwRlTX2mB9g1a05IR6l9TOGmSz6BV5YYbavXdq38EA7dw/44U/P9edRNIwFTMPLWIbhkDYMZkuziyovhBji8c5gUb09Flplc1aWO8V4u5kjEY6cl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PX0rdmvX7T85hwR7LXC5iUBs2xdahTfDgoZTZ/12fSoNwkdgmYURmy/fAEOnVHIn5Gj/LKu8ii2UOzWktbAnz4f30MeuFeaBx5h9ve/nELQnvsPiZgIDFdKYdXb8yJRTgg9ahYdPhEC/u1RIJFxs4sRmRfZwY7qATssLhnL9ZDtDuuZxJft+sn5swpiepSiekGvw20fsP6tRD4nu0
> Little-Net:openssl-spkac-md minfrin$ /tmp/httpd-trunk/bin/openssl spkac -challenge challenge -key ~/ca/pepperpot/pepperpot.media.key -md sha256 | /tmp/httpd-trunk/bin/openssl spkac -challenge challenge -verify
> Netscape SPKI:
> Public Key Algorithm: rsaEncryption
> RSA Public-Key: (4096 bit)
> Modulus:
> 00:bd:c2:6c:90:89:d0:70:9c:83:77:d3:c5:30:46:
> 54:d7:da:60:7d:83:56:b4:e4:84:7a:97:d4:ce:1a:
> 64:b3:e8:15:79:61:86:da:bd:77:6a:df:c1:00:ed:
> dc:3f:e3:85:3f:3f:d7:9d:44:d2:30:15:33:0f:2d:
> 62:1b:86:40:d8:31:99:2e:ce:2c:a8:be:10:63:8b:
> c7:39:81:46:f4:f4:59:69:95:cd:5a:58:ef:15:e2:
> ee:64:8c:46:3a:72:5b:ac:61:54:b1:2f:e8:f4:19:
> 4d:cd:5d:6d:a4:d8:00:b8:f9:3b:3c:63:fb:04:f6:
> 47:ea:59:be:50:cd:32:36:4f:3d:54:a9:1a:fa:a0:
> 4d:86:eb:92:e1:16:18:24:83:fc:9a:7e:7b:ce:b2:
> 1f:81:f2:73:70:75:c3:f0:6e:ac:cf:5b:ca:8d:16:
> b0:ea:a6:90:e0:f6:c9:b9:3d:ba:df:19:8f:71:4d:
> e0:58:2a:ad:00:56:ff:ff:ab:21:b9:62:0a:a3:35:
> 93:c8:3c:2e:26:45:07:f1:fc:83:db:70:c2:57:34:
> 87:fa:89:14:22:2e:78:80:c4:5b:81:98:ed:ce:86:
> 88:3c:ae:e7:d4:7b:35:ab:03:97:77:7f:5b:28:ad:
> 3a:33:90:ac:51:10:2c:27:ce:03:1c:2a:6c:dc:c9:
> 9b:44:35:b9:2b:36:e2:f5:05:b0:ea:87:00:ec:df:
> 17:fd:8a:56:f0:92:24:71:d4:13:96:ac:f0:84:5d:
> 99:de:4b:de:a2:15:19:04:32:4c:36:01:c2:10:22:
> a8:83:35:24:ad:a4:eb:7c:8f:22:97:e2:c4:5d:50:
> ed:ed:7d:a8:02:67:54:1c:2f:60:e6:c9:a6:f9:6b:
> 2a:53:af:f7:95:c7:fc:63:de:c6:6c:ad:00:b2:f3:
> d0:65:3a:c4:8d:f4:64:c1:6c:84:1e:ba:2f:7b:3e:
> 20:3a:86:65:45:51:66:c6:2d:ad:93:75:91:fe:06:
> 78:e3:73:c3:a2:64:f1:79:60:7f:6e:42:8d:59:f7:
> 10:fe:7f:17:0b:eb:13:90:5b:7e:7f:27:22:7b:02:
> d1:9a:d5:22:2e:b7:4a:b7:59:0e:12:f7:7c:00:07:
> f0:ce:00:37:3d:19:69:78:99:60:7f:da:0a:0b:0e:
> c0:94:59:74:87:62:cd:9c:cd:2f:f6:6b:f2:e1:f4:
> c2:90:b0:32:8b:41:b1:0c:9d:cc:5a:ab:74:d5:04:
> 6e:d4:ae:af:52:46:79:9e:9a:0b:9a:5a:3b:e8:9e:
> 2d:28:ef:6e:67:5a:2f:e3:e4:7e:80:b4:e6:58:a0:
> 51:a6:71:c8:f1:ad:a4:80:54:65:92:e2:bf:b4:5f:
> 7a:92:65
> Exponent: 65537 (0x10001)
> Challenge String: challenge
> Signature Algorithm: sha256WithRSAEncryption
> 92:60:98:11:4c:0f:ed:80:aa:44:29:0f:fd:80:80:27:28:28:
> d9:11:99:c0:fc:12:41:d0:63:ee:56:37:cd:3e:a2:06:96:7f:
> 95:5c:0d:4d:f2:70:fd:b9:e7:8c:7d:e4:43:cb:85:c9:6a:ad:
> 7f:71:6f:35:1e:9a:e5:28:36:24:7f:b0:fc:a1:c6:5d:0f:af:
> b3:8f:b4:aa:ae:95:6e:90:bd:3f:98:09:cc:ab:6c:82:d1:d6:
> 31:3c:96:15:52:10:d9:13:fd:f2:fa:53:d2:78:34:f7:7b:a8:
> 60:74:38:58:93:bf:db:40:4f:58:6e:cf:3b:97:83:1e:bb:e9:
> 3f:18:e6:66:fd:5d:59:34:0b:a0:82:18:4a:03:c5:22:88:da:
> 7d:ff:9d:b9:1d:cb:25:e5:ab:5b:85:a6:1c:15:09:71:01:52:
> fa:e7:74:3f:32:de:f2:9d:f2:b8:6d:1b:2b:f3:f1:c4:e0:da:
> af:e6:1e:64:87:95:dc:30:99:f9:2c:69:13:70:87:d9:b1:38:
> a7:ab:2d:44:39:a4:53:3a:f0:73:83:3a:72:47:16:cf:c3:db:
> a1:90:97:02:0d:7d:5a:ab:56:72:3e:a0:20:3f:54:51:73:fd:
> 03:b8:9a:29:d3:ef:3b:83:48:66:bf:70:57:62:3d:68:f7:77:
> ff:c6:cf:4d:a9:a5:42:07:93:c4:55:2a:b7:46:81:37:ff:79:
> f4:26:6c:fd:b3:2c:47:da:01:f4:d4:95:28:d5:96:25:43:ab:
> 0e:52:44:6e:90:25:8a:ef:cf:cd:29:7d:97:33:d7:70:58:de:
> 99:0d:e6:59:c0:72:e0:3c:2d:de:46:6f:f6:15:7e:22:64:89:
> e7:ef:32:df:6d:ef:9d:e9:7b:d6:31:bf:c8:94:e8:f2:9f:40:
> ef:14:6e:21:9b:3d:f1:03:3f:96:d0:d4:42:4f:5f:4a:dd:9a:
> f5:fb:4f:ce:61:c1:1e:cb:5c:2e:62:50:1b:36:c5:d6:a1:4d:
> f0:e0:a1:94:d9:ff:5d:9f:4a:83:70:91:d8:26:61:44:66:cb:
> f7:c0:10:e9:d5:1c:89:f9:1a:3f:cb:2a:ef:22:8b:65:0e:cd:
> 69:2d:6c:09:f3:e1:fd:f4:31:eb:85:79:a0:71:e6:1f:6f:7b:
> f9:c4:2d:09:ef:b0:f8:99:80:80:c5:74:a6:1d:5d:bf:32:25:
> 14:e0:83:d6:a1:61:d3:e1:10:2f:ee:d5:12:09:17:1b:38:b1:
> 19:91:7d:9c:18:ee:a0:13:b2:c2:e1:9c:bf:59:0e:d0:ee:b9:
> 9c:49:7e:df:ac:9f:9b:30:a6:27:a9:4a:27:a4:1a:fc:36:d1:
> fb:0f:ea:d4:43:e2:7b:b4
> Signature OK
Nice !
You push this to openssl ? Happy to do that too (their process is fairly simple).
Dw.
More information about the rs-dev
mailing list