Create a new embeddedSCTs1 that's signed using SHA256
authorKurt Roeckx <kurt@roeckx.be>
Wed, 22 Jan 2020 23:24:35 +0000 (00:24 +0100)
committerKurt Roeckx <kurt@roeckx.be>
Wed, 5 Feb 2020 21:04:37 +0000 (22:04 +0100)
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
GH: #10786

test/certs/ct-server-key-public.pem [new file with mode: 0644]
test/certs/ct-server-key.pem [new file with mode: 0644]
test/certs/embeddedSCTs1-key.pem
test/certs/embeddedSCTs1.pem
test/certs/embeddedSCTs1.sct
test/certs/embeddedSCTs1.tlssct [new file with mode: 0644]
test/certs/embeddedSCTs1_issuer-key.pem [new file with mode: 0644]
test/certs/embeddedSCTs3.sct
test/certs/mkcert.sh
test/certs/setup.sh
test/ct_test.c

diff --git a/test/certs/ct-server-key-public.pem b/test/certs/ct-server-key-public.pem
new file mode 100644 (file)
index 0000000..c35ce3f
--- /dev/null
@@ -0,0 +1,4 @@
+-----BEGIN PUBLIC KEY-----
+MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEmXg8sUUzwBYaWrRb+V0IopzQ6o3U
+yEJ04r5ZrRXGdpYM8K+hB0pXrGRLI0eeWz+3skXrS0IO83AhA3GpRL6s6w==
+-----END PUBLIC KEY-----
diff --git a/test/certs/ct-server-key.pem b/test/certs/ct-server-key.pem
new file mode 100644 (file)
index 0000000..ab6a557
--- /dev/null
@@ -0,0 +1,5 @@
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIFLw4uhuCruGKjrS9MoNeXFbypqZe+Sgh+EL1gnRn1d4oAoGCCqGSM49
+AwEHoUQDQgAEmXg8sUUzwBYaWrRb+V0IopzQ6o3UyEJ04r5ZrRXGdpYM8K+hB0pX
+rGRLI0eeWz+3skXrS0IO83AhA3GpRL6s6w==
+-----END EC PRIVATE KEY-----
index e3e66d55c51060f7772b13ca408807baab06a9b9..28dd206dbe8dd50a045e1337171a834c43baa683 100644 (file)
@@ -1,15 +1,27 @@
 -----B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3hLgt6i45KhYvVWQR8mzzu8bgbnGhfDco4fKK55BRSUye7yn4HHTE9Uo8S
+wuN7dH2TSsZrlxrt1cCf1TKkoqnbnHg1emeMZfm3FURh82+pAgMBAAGjggEMMIIB
+CDAdBgNVHQ4EFgQUtMa8XD5ylrF9AqCdnPEhXa63H2owHwYDVR0jBBgwFoAUX52I
+Dchz5lTU+A3Y5rDBJLRHw1UwCQYDVR0TBAIwADATBgNVHSUEDDAKBggrBgEFBQcD
+ATCBigYKKwYBBAHWeQIEAgR8BHoAeAB2AN8cLsEVAJRSR6lhaDJd3Fx5Wej3xtOI
+/AAuC70/dNdkAAABb15m6AAAAAQDAEcwRQIgfDPo8RArm/vcSEZ608Q1u+XQ55QB
+u67SZEuZxLpbUM0CIQDRsgcTud4PDy8Cgg+lHeAS7UxgSKBbWAznYOuorwNewzAZ
+BgNVHREEEjAQgg5zZXJ2ZXIuZXhhbXBsZTANBgkqhkiG9w0BAQsFAAOBgQCWFKKR
+RNkDRzB25NK07OLkbzebhnpKtbP4i3blRx1HAvTSamf/3uuHI7kfiPJorJymJpT1
+IuJvSVKyMu1qONWBimiBfiyGL7+le1izHEJIP5lVTbddfzSIBIvrlHHcWIOL3H+W
+YT6yTEIzJuO07Xp61qnB1CE2TrinUWlyC46Zkw==
 -----END CERTIFICATE-----
index 59362dcee1f46b0f9b0951a9fa3949c78e83916f..9e413e3dc7b987aa1281e6bfe42937d87111a357 100644 (file)
@@ -2,11 +2,11 @@ Signed Certificate Timestamp:
     Version   : v1 (0x0)
     Log ID    : DF:1C:2E:C1:15:00:94:52:47:A9:61:68:32:5D:DC:5C:
                 79:59:E8:F7:C6:D3:88:FC:00:2E:0B:BD:3F:74:D7:64
-    Timestamp : Apr  5 17:04:16.275 2013 GMT
+    Timestamp : Jan  1 00:00:00.000 2020 GMT
     Extensions: none
     Signature : ecdsa-with-SHA256
-                30:45:02:20:48:2F:67:51:AF:35:DB:A6:54:36:BE:1F:
-                D6:64:0F:3D:BF:9A:41:42:94:95:92:45:30:28:8F:A3:
-                E5:E2:3E:06:02:21:00:E4:ED:C0:DB:3A:C5:72:B1:E2:
-                F5:E8:AB:6A:68:06:53:98:7D:CF:41:02:7D:FE:FF:A1:
-                05:51:9D:89:ED:BF:08
\ No newline at end of file
+                30:45:02:20:7C:33:E8:F1:10:2B:9B:FB:DC:48:46:7A:
+                D3:C4:35:BB:E5:D0:E7:94:01:BB:AE:D2:64:4B:99:C4:
+                BA:5B:50:CD:02:21:00:D1:B2:07:13:B9:DE:0F:0F:2F:
+                02:82:0F:A5:1D:E0:12:ED:4C:60:48:A0:5B:58:0C:E7:
+                60:EB:A8:AF:03:5E:C3
diff --git a/test/certs/embeddedSCTs1.tlssct b/test/certs/embeddedSCTs1.tlssct
new file mode 100644 (file)
index 0000000..0586c94
Binary files /dev/null and b/test/certs/embeddedSCTs1.tlssct differ
diff --git a/test/certs/embeddedSCTs1_issuer-key.pem b/test/certs/embeddedSCTs1_issuer-key.pem
new file mode 100644 (file)
index 0000000..9326e38
--- /dev/null
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXAIBAAKBgQDVimhTYhCicRmTbneDIRgcKkATxtB7jHbrkVfT0PtLO1FuzsvR
+yY2RxS90P6tjXVUJnNE6uvMa5UFEJFGnTHgW8iQ8+EjPKDHM5nugSlojgZ88ujfm
+JNnDvbKZuDnd/iYx0ss6hPx7srXFL8/BT/9Ab1zURmnLsvfP34b7arnRsQIDAQAB
+AoGAJLR6xEJp+5IXRFlLn7WTkFvO0ddtxJ7bXhiIkTctyruyfqp7LF9Jv1G2m3PK
+QPUtBc73w/GYkfnwIwdfJbOmPHL7XyEGHZYmEXgIgEtw6LXvAv0G5JpUnNwsSBfL
+GfSQqI5Z5ytyzlJXkMcTGA2kTgNAYc73h4EnU+pwUnDPdAECQQD2aj+4LtYk1XPq
+r3gjgI6MoGvgYJfPmAtZhxxVbhXQKciFUCAcBiwlQdHIdLWE9j65ctmZRWidKifr
+4O4nz+TBAkEA3djNW/rTQq5fKZy+mCF1WYnIU/3yhJaptzRqLm7AHqe7+hdrGXJw
++mCtU8T3L/Ms8bH1yFBZhmkp1PbR8gl48QJAQo70YyWThiN5yfxXcQ96cZWrTdIJ
+b3NcLXSHPLQdhDqlBQ1dfvRT3ERpC8IqfZ2d162kBPhwh3MpkVcSPQK0gQJAC/dY
+xGBYKt2a9nSk9zG+0bCT5Kvq++ngh6hFHfINXNnxUsEWns3EeEzkrIMQTj7QqszN
+lBt5aL2dawZRNrv6EQJBAOo4STF9KEwQG0HLC/ryh1FeB0OBA5yIepXze+eJVKei
+T0cCECOQJKfWHEzYJYDJhyEFF/sYp9TXwKSDjOifrsU=
+-----END RSA PRIVATE KEY-----
index ad1ccf0ffc38a8e9b1437bd90bac2ec29ff84a56..579a890a9a8ab4ccc22169953a24e4d5f650b276 100644 (file)
@@ -33,4 +33,4 @@ Signed Certificate Timestamp:
                 55:83:D2:9D:E5:A1:8D:B6:3D:A6:73:89:42:32:9C:91:
                 0F:3B:6A:74:02:21:00:86:EE:10:F9:10:E6:7B:17:65:
                 D9:2D:37:53:4A:3B:F0:AE:03:E4:21:76:37:EF:AF:B4:
-                44:2E:2B:F5:5C:C6:91
\ No newline at end of file
+                44:2E:2B:F5:5C:C6:91
index e03b19014ea64351697a822abe3d2e033a916c3e..7a2092aa8b2f58bf0d08e2c52b1e59391c79146d 100755 (executable)
@@ -288,4 +288,56 @@ gennocn() {
        cert "$cert" "" -signkey "${key}.pem" -set_serial 1 -days -1 "$@"
 }
 
+genct() {
+    local OPTIND=1
+    local purpose=serverAuth
+
+    while getopts p: o
+    do
+        case $o in
+        p) purpose="$OPTARG";;
+        *) echo "Usage: $0 genct [-p EKU] cn keyname certname cakeyname cacertname ctlogkey" >&2
+           return 1;;
+        esac
+    done
+
+    shift $((OPTIND - 1))
+    local cn=$1; shift
+    local key=$1; shift
+    local cert=$1; shift
+    local cakey=$1; shift
+    local ca=$1; shift
+    local logkey=$1; shift
+
+    exts=$(printf "%s\n%s\n%s\n%s\n%s\n%s\n[alts]\n%s\n" \
+           "subjectKeyIdentifier = hash" \
+           "authorityKeyIdentifier = keyid, issuer" \
+           "basicConstraints = CA:false" \
+           "extendedKeyUsage = $purpose" \
+            "1.3.6.1.4.1.11129.2.4.3 = critical,ASN1:NULL"\
+           "subjectAltName = @alts" "DNS=${cn}")
+    csr=$(req "$key" "CN = $cn") || return 1
+    echo "$csr" |
+       cert "$cert" "$exts" -CA "${ca}.pem" -CAkey "${cakey}.pem" \
+           -set_serial 2 -days "${DAYS}" "$@"
+    cat ${cert}.pem ${ca}.pem > ${cert}-chain.pem
+    go run github.com/google/certificate-transparency-go/ctutil/sctgen \
+       --log_private_key ${logkey}.pem \
+       --timestamp="2020-01-01T00:00:00Z" \
+       --cert_chain ${cert}-chain.pem \
+       --tls_out ${cert}.tlssct
+    rm ${cert}-chain.pem
+    filesize=$(wc -c <${cert}.tlssct)
+    exts=$(printf "%s\n%s\n%s\n%s\n%s%04X%04X%s\n%s\n[alts]\n%s\n" \
+           "subjectKeyIdentifier = hash" \
+           "authorityKeyIdentifier = keyid, issuer" \
+           "basicConstraints = CA:false" \
+           "extendedKeyUsage = $purpose" \
+           "1.3.6.1.4.1.11129.2.4.2 = ASN1:FORMAT:HEX,OCT:" $((filesize+2)) $filesize `xxd -p ${cert}.tlssct | tr -d '\n'` \
+           "subjectAltName = @alts" "DNS=${cn}")
+    echo "$csr" |
+       cert "$cert" "$exts" -CA "${ca}.pem" -CAkey "${cakey}.pem" \
+           -set_serial 2 -days "${DAYS}" "$@"
+}
+
 "$@"
index 26b2f1ddfe02e7170fbe165365f6bc31e5bfdd8a..bd0b66394486457694e8b7df7be87ddedfdf72a2 100755 (executable)
@@ -375,3 +375,6 @@ openssl req -new -nodes -subj "/CN=localhost" \
     -pkeyopt rsa_pss_keygen_md:sha256 -pkeyopt rsa_pss_keygen_saltlen:32 | \
     ./mkcert.sh geneenocsr "Server RSA-PSS restricted cert" \
     server-pss-restrict-cert rootkey rootcert
+
+# CT entry
+./mkcert.sh genct server.example embeddedSCTs1-key embeddedSCTs1 embeddedSCTs1_issuer-key embeddedSCTs1_issuer ct-server-key
index e2f50efcf397cdedfee17696df76c0d419b750cb..c55fb7ca90d62dd0287cbc62666cf68cfbed19ab 100644 (file)
@@ -63,7 +63,7 @@ static CT_TEST_FIXTURE *set_up(const char *const test_case_name)
     if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture))))
         goto end;
     fixture->test_case_name = test_case_name;
-    fixture->epoch_time_in_ms = 1473269626000ULL; /* Sep 7 17:33:46 2016 GMT */
+    fixture->epoch_time_in_ms = 1580335307000ULL; /* Wed 29 Jan 2020 10:01:47 PM UTC */
     if (!TEST_ptr(fixture->ctlog_store = CTLOG_STORE_new())
             || !TEST_int_eq(
                     CTLOG_STORE_load_default_file(fixture->ctlog_store), 1))
@@ -160,6 +160,10 @@ static int compare_extension_printout(X509_EXTENSION *extension,
                                            X509V3_EXT_DEFAULT, 0)))
         goto end;
 
+    /* Append \n because it's easier to create files that end with one. */
+    if (!TEST_true(BIO_write(text_buffer, "\n", 1)))
+        goto end;
+
     /* Append \0 because we're about to use the buffer contents as a string. */
     if (!TEST_true(BIO_write(text_buffer, "\0", 1)))
         goto end;