diff options
author | tb <> | 2018-08-25 10:07:16 +0000 |
---|---|---|
committer | tb <> | 2018-08-25 10:07:16 +0000 |
commit | 9f692b0ee8ba05d706060427c4a23ccf83d0a3e6 (patch) | |
tree | 810933aa5d932259c300092c1f7f6a15857ec491 /src | |
parent | 44e0e86fdd58014515d79c61c8dbcfbe1d7c3076 (diff) | |
download | openbsd-9f692b0ee8ba05d706060427c4a23ccf83d0a3e6.tar.gz openbsd-9f692b0ee8ba05d706060427c4a23ccf83d0a3e6.tar.bz2 openbsd-9f692b0ee8ba05d706060427c4a23ccf83d0a3e6.zip |
Also run DSA tests with the PEM encoded public key.
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/wycheproof/wycheproof.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go index 5caee01181..ae9108407b 100644 --- a/src/regress/lib/libcrypto/wycheproof/wycheproof.go +++ b/src/regress/lib/libcrypto/wycheproof/wycheproof.go | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: wycheproof.go,v 1.19 2018/08/24 17:37:25 tb Exp $ */ | 1 | /* $OpenBSD: wycheproof.go,v 1.20 2018/08/25 10:07:16 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2018 Joel Sing <jsing@openbsd.org> |
4 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> |
@@ -24,6 +24,7 @@ package main | |||
24 | 24 | ||
25 | #include <string.h> | 25 | #include <string.h> |
26 | 26 | ||
27 | #include <openssl/bio.h> | ||
27 | #include <openssl/bn.h> | 28 | #include <openssl/bn.h> |
28 | #include <openssl/curve25519.h> | 29 | #include <openssl/curve25519.h> |
29 | #include <openssl/dsa.h> | 30 | #include <openssl/dsa.h> |
@@ -31,6 +32,7 @@ package main | |||
31 | #include <openssl/ecdsa.h> | 32 | #include <openssl/ecdsa.h> |
32 | #include <openssl/evp.h> | 33 | #include <openssl/evp.h> |
33 | #include <openssl/objects.h> | 34 | #include <openssl/objects.h> |
35 | #include <openssl/pem.h> | ||
34 | #include <openssl/x509.h> | 36 | #include <openssl/x509.h> |
35 | #include <openssl/rsa.h> | 37 | #include <openssl/rsa.h> |
36 | */ | 38 | */ |
@@ -453,6 +455,7 @@ func runDSATestGroup(wtg *wycheproofTestGroupDSA) bool { | |||
453 | log.Fatalf("Failed to get hash: %v", err) | 455 | log.Fatalf("Failed to get hash: %v", err) |
454 | } | 456 | } |
455 | 457 | ||
458 | |||
456 | der, err := hex.DecodeString(wtg.KeyDER) | 459 | der, err := hex.DecodeString(wtg.KeyDER) |
457 | if err != nil { | 460 | if err != nil { |
458 | log.Fatalf("Failed to decode DER encoded key: %v", err) | 461 | log.Fatalf("Failed to decode DER encoded key: %v", err) |
@@ -474,7 +477,21 @@ func runDSATestGroup(wtg *wycheproofTestGroupDSA) bool { | |||
474 | defer C.DSA_free(dsaDER) | 477 | defer C.DSA_free(dsaDER) |
475 | C.free(unsafe.Pointer(Cder)) | 478 | C.free(unsafe.Pointer(Cder)) |
476 | 479 | ||
477 | /// XXX audit acceptable cases | 480 | |
481 | keyPEM := C.CString(wtg.KeyPEM); | ||
482 | bio := C.BIO_new_mem_buf(unsafe.Pointer(keyPEM), C.int(len(wtg.KeyPEM))) | ||
483 | if bio == nil { | ||
484 | log.Fatal("BIO_new_mem_buf failed") | ||
485 | } | ||
486 | defer C.BIO_free(bio) | ||
487 | |||
488 | dsaPEM := C.PEM_read_bio_DSA_PUBKEY(bio, nil, nil, nil) | ||
489 | if dsaPEM == nil { | ||
490 | log.Fatal("PEM_read_bio_DSA_PUBKEY failed") | ||
491 | } | ||
492 | defer C.DSA_free(dsaPEM) | ||
493 | |||
494 | |||
478 | success := true | 495 | success := true |
479 | for _, wt := range wtg.Tests { | 496 | for _, wt := range wtg.Tests { |
480 | if !runDSATest(dsa, h, wt) { | 497 | if !runDSATest(dsa, h, wt) { |
@@ -483,6 +500,9 @@ func runDSATestGroup(wtg *wycheproofTestGroupDSA) bool { | |||
483 | if !runDSATest(dsaDER, h, wt) { | 500 | if !runDSATest(dsaDER, h, wt) { |
484 | success = false | 501 | success = false |
485 | } | 502 | } |
503 | if !runDSATest(dsaPEM, h, wt) { | ||
504 | success = false | ||
505 | } | ||
486 | } | 506 | } |
487 | return success | 507 | return success |
488 | } | 508 | } |