boringssl/crypto
David Benjamin 8cd7bbf514 Push password encoding back into pkcs12_key_gen.
With PKCS8_encrypt_pbe and PKCS8_decrypt_pbe gone in
3e8b782c0c, we can restore the old
arrangement where the password encoding was handled in pkcs12_key_gen.
This simplifies the interface for the follow-up crypto/asn1 split.

Note this change is *not* a no-op for PKCS#12 files which use PBES2.
Before, we would perform the PKCS#12 password encoding for all parts of
PKCS#12 processing. The new behavior is we only perform it for the parts
that go through the PKCS#12 KDF. For such a file, it would only be the
MAC.

I believe the specification supports our new behavior. Although RFC 7292
B.1 says something which implies that the transformation is about
converting passwords to byte strings and would thus be universal,
appendix B itself is prefaced with:

   Note that this method for password privacy mode is not recommended
   and is deprecated for new usage.  The procedures and algorithms
   defined in PKCS #5 v2.1 [13] [22] should be used instead.
   Specifically, PBES2 should be used as encryption scheme, with PBKDF2
   as the key derivation function.

"This method" refers to the key derivation and not the password
formatting, but it does give support to the theory that password
formatting is tied to PKCS#12 key derivation.

(Of course, if one believes PKCS#12's assertion that their inane
encoding (NUL-terminated UTF-16!) is because PKCS#5 failed to talk about
passwords as Unicode strings, one would think that PBES2 (also in
PKCS#5) would have the same issue and thus need PKCS#12 to valiantly
save the day with an encoding...)

This matches OpenSSL's behavior and that of recent versions of NSS. See
https://bugzilla.mozilla.org/show_bug.cgi?id=1268141. I was unable to
figure out what variants, if any, macOS accepts.

BUG=54

Change-Id: I9a1bb4d5e168e6e76b82241e4634b1103e620b9b
Reviewed-on: https://boringssl-review.googlesource.com/14213
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-03-25 21:25:30 +00:00
..
aes x86_64 assembly pack: Win64 SEH face-lift. 2017-02-16 21:55:04 +00:00
asn1 Fix potential memory leak in ASN1_TIME_to_generalizedtime() 2017-03-21 18:10:51 +00:00
base64 Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
bio Convert bio_test to GTest. 2017-03-21 17:39:57 +00:00
bn Enable RSA AVX2 code. 2017-03-08 17:28:12 +00:00
buf Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
bytestring Correct a typo in ASN.1 type name. 2017-03-16 21:57:58 +00:00
chacha x86_64 assembly pack: Win64 SEH face-lift. 2017-02-16 21:55:04 +00:00
cipher Update AES-GCM-SIV to match revision four of the draft. 2017-02-26 18:37:53 +00:00
cmac Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
conf Fix out-of-memory condition in conf. 2017-03-21 16:19:22 +00:00
curve25519 Convert x25519_test to GTest. 2017-03-01 21:46:11 +00:00
des Fix up macros. 2016-10-18 18:28:23 +00:00
dh Remove direct calls to BN_mod_exp. 2017-02-28 18:00:02 +00:00
digest Decouple PKCS#12 hash lookup from the OID table. 2017-03-25 21:22:50 +00:00
dsa Add a common TestEventListener for the error queue. 2017-02-07 21:33:22 +00:00
ec Convert ec_test to GTest. 2017-02-16 23:33:48 +00:00
ecdh Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
ecdsa ECDSA: const EC_KEY* arguments where possible. 2017-02-18 06:22:01 +00:00
engine Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
err Decouple PKCS#12 hash lookup from the OID table. 2017-03-25 21:22:50 +00:00
evp Add some PSS test vectors with non-zero salt length. 2017-03-22 17:53:10 +00:00
hkdf Convert hkdf_test to C++. 2017-01-04 01:40:44 +00:00
hmac Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
lhash Remove lh_new's default hash and comparator. 2017-01-04 01:44:10 +00:00
md4 Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
md5 Remove trailing whitespace from Perl files. 2017-02-14 00:13:55 +00:00
modes x86_64 assembly pack: Win64 SEH face-lift. 2017-02-16 21:55:04 +00:00
obj Reimplement objects.pl in Go. 2016-12-21 22:14:13 +00:00
pem Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
perlasm perlasm/x86_64-xlate.pl: recognize even offset(%reg) in cfa_expression. 2017-02-16 22:21:25 +00:00
pkcs8 Push password encoding back into pkcs12_key_gen. 2017-03-25 21:25:30 +00:00
poly1305 Delete unused Poly1305 assembly. 2017-01-21 00:17:30 +00:00
pool Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
rand Remove TODO. 2017-03-25 16:29:04 +00:00
rc4 Simplify RC4 code and remove assembly. 2016-08-30 15:32:31 +00:00
rsa Tidy up error-handling around computing the hash in PSS. 2017-03-23 15:07:08 +00:00
sha x86_64 assembly pack: Win64 SEH face-lift. 2017-02-16 21:55:04 +00:00
stack Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
test Convert bio_test to GTest. 2017-03-21 17:39:57 +00:00
x509 Fix a memory leak in X509_STORE_add_cert/crl error handling. 2017-03-21 14:51:17 +00:00
x509v3 Fix a crash in print_notice. 2017-03-21 14:50:26 +00:00
CMakeLists.txt Convert bio_test to GTest. 2017-03-21 17:39:57 +00:00
constant_time_test.cc Convert constant_time_test and refcount_test to C++. 2017-01-04 01:36:49 +00:00
cpu-aarch64-linux.c
cpu-arm-linux.c Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
cpu-arm.c
cpu-intel.c Wrap MSVC-only warning pragmas in a macro. 2016-06-09 21:29:36 +00:00
cpu-ppc64le.c Add PPC64LE assembly for AES-GCM. 2016-09-27 18:43:20 +00:00
crypto.c Add PPC64LE assembly for AES-GCM. 2016-09-27 18:43:20 +00:00
ex_data.c Use C99 for size_t loops. 2016-09-12 19:44:24 +00:00
internal.h Fix comment on OPENSSL_memcmp, etc. 2016-12-21 21:47:24 +00:00
mem.c Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
refcount_c11.c
refcount_lock.c Split unlock functions into read/write variants. 2016-05-31 21:09:29 +00:00
refcount_test.cc Convert constant_time_test and refcount_test to C++. 2017-01-04 01:36:49 +00:00
thread_none.c Split unlock functions into read/write variants. 2016-05-31 21:09:29 +00:00
thread_pthread.c Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
thread_test.c Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
thread_win.c Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
thread.c Remove a bunch of unnecessary includes. 2016-06-28 20:31:14 +00:00