summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2018-11-07 22:51:17 +0000
committertb <>2018-11-07 22:51:17 +0000
commit547ee025b296edecfcade4d07226265b54a6cfed (patch)
treeddb48a58deedd0c488ae4f8e4ce6809bd9783b7e
parentc114d2b36597e7c5aa670267f5b94ace23f20123 (diff)
downloadopenbsd-547ee025b296edecfcade4d07226265b54a6cfed.tar.gz
openbsd-547ee025b296edecfcade4d07226265b54a6cfed.tar.bz2
openbsd-547ee025b296edecfcade4d07226265b54a6cfed.zip
Use in-place (un)wrapping in the keywrap tests.
-rw-r--r--src/regress/lib/libcrypto/wycheproof/wycheproof.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go
index 9bc4e5fd8b..af4f18b38b 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.86 2018/10/20 16:02:05 tb Exp $ */ 1/* $OpenBSD: wycheproof.go,v 1.87 2018/11/07 22:51:17 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>
@@ -1701,11 +1701,13 @@ func runKWTestWrap(keySize int, key []byte, keyLen int, msg []byte, msgLen int,
1701 return false 1701 return false
1702 } 1702 }
1703 1703
1704 outLen := msgLen + 8 1704 outLen := msgLen
1705 out := make([]byte, outLen) 1705 out := make([]byte, outLen)
1706 ret = C.AES_wrap_key((*C.AES_KEY)(unsafe.Pointer(&aesKey)), nil, (*C.uchar)(unsafe.Pointer(&out[0])), (*C.uchar)(unsafe.Pointer(&msg[0])), (C.uint)(msgLen)) 1706 copy(out, msg)
1707 out = append(out, make([]byte, 8)...)
1708 ret = C.AES_wrap_key((*C.AES_KEY)(unsafe.Pointer(&aesKey)), nil, (*C.uchar)(unsafe.Pointer(&out[0])), (*C.uchar)(unsafe.Pointer(&out[0])), (C.uint)(msgLen))
1707 success := false 1709 success := false
1708 if ret == C.int(outLen) && bytes.Equal(out, ct) { 1710 if ret == C.int(len(out)) && bytes.Equal(out, ct) {
1709 if acceptableAudit && wt.Result == "acceptable" { 1711 if acceptableAudit && wt.Result == "acceptable" {
1710 gatherAcceptableStatistics(wt.TCID, wt.Comment, wt.Flags) 1712 gatherAcceptableStatistics(wt.TCID, wt.Comment, wt.Flags)
1711 } 1713 }
@@ -1733,10 +1735,11 @@ func runKWTestUnWrap(keySize int, key []byte, keyLen int, msg []byte, msgLen int
1733 } 1735 }
1734 1736
1735 out := make([]byte, ctLen) 1737 out := make([]byte, ctLen)
1738 copy(out, ct)
1736 if ctLen == 0 { 1739 if ctLen == 0 {
1737 out = append(out, 0) 1740 out = append(out, 0)
1738 } 1741 }
1739 ret = C.AES_unwrap_key((*C.AES_KEY)(unsafe.Pointer(&aesKey)), nil, (*C.uchar)(unsafe.Pointer(&out[0])), (*C.uchar)(unsafe.Pointer(&ct[0])), (C.uint)(ctLen)) 1742 ret = C.AES_unwrap_key((*C.AES_KEY)(unsafe.Pointer(&aesKey)), nil, (*C.uchar)(unsafe.Pointer(&out[0])), (*C.uchar)(unsafe.Pointer(&out[0])), (C.uint)(ctLen))
1740 success := false 1743 success := false
1741 if ret == C.int(ctLen - 8) && bytes.Equal(out[0:ret], msg[0:ret]) { 1744 if ret == C.int(ctLen - 8) && bytes.Equal(out[0:ret], msg[0:ret]) {
1742 if acceptableAudit && wt.Result == "acceptable" { 1745 if acceptableAudit && wt.Result == "acceptable" {