Move PKCS#12 samples to embed_test_data.

pkcs12_test.cc was getting a bit long. Along the way, embed_test_data.go
needed a fix to work around a syntax quirk of C++.

Change-Id: Ic4a19f77d177ebd607918feb253a08f1f9037981
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/46044
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
This commit is contained in:
David Benjamin 2021-02-27 11:31:39 -05:00 committed by CQ bot account: commit-bot@chromium.org
parent a1d1a67589
commit 84c0c900fc
12 changed files with 83 additions and 1462 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

BIN
crypto/pkcs8/test/nss.p12 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -59,6 +59,15 @@ set(
crypto/fipsmodule/rand/ctrdrbg_vectors.txt
crypto/hmac_extra/hmac_tests.txt
crypto/hpke/hpke_test_vectors.txt
crypto/pkcs8/test/empty_password.p12
crypto/pkcs8/test/no_encryption.p12
crypto/pkcs8/test/nss.p12
crypto/pkcs8/test/null_password.p12
crypto/pkcs8/test/openssl.p12
crypto/pkcs8/test/pbes2_sha1.p12
crypto/pkcs8/test/pbes2_sha256.p12
crypto/pkcs8/test/unicode_password.p12
crypto/pkcs8/test/windows.p12
crypto/poly1305/poly1305_tests.txt
crypto/siphash/siphash_tests.txt
crypto/x509/test/basic_constraints_ca.pem

View File

@ -28,9 +28,11 @@ import (
var fileList = flag.String("file-list", "", "if not empty, the path to a file containing a newline-separated list of files, to work around Windows command-line limits")
func quote(in []byte) string {
var lastWasHex bool
var buf bytes.Buffer
buf.WriteByte('"')
for _, b := range in {
var wasHex bool
switch b {
case '\a':
buf.WriteString(`\a`)
@ -51,13 +53,20 @@ func quote(in []byte) string {
case '\\':
buf.WriteString(`\\`)
default:
// printable ascii code [32, 126]
if 32 <= b && b <= 126 {
// Emit printable ASCII characters, [32, 126], as-is to minimize
// file size. However, if the previous character used a hex escape
// sequence, do not emit 0-9 and a-f as-is. C++ interprets "\x123"
// as a single (overflowing) escape sequence, rather than '\x12'
// followed by '3'.
isHexDigit := ('0' <= b && b <= '9') || ('a' <= b && b <= 'f') || ('A' <= b && b <= 'F')
if 32 <= b && b <= 126 && !(lastWasHex && isHexDigit) {
buf.WriteByte(b)
} else {
fmt.Fprintf(&buf, "\\x%02x", b)
wasHex = true
}
}
lastWasHex = wasHex
}
buf.WriteByte('"')
return buf.String()