aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Vartanian <flooey@google.com>2017-11-16 15:07:22 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-12-14 21:10:04 +0000
commitc98b32605b210d3239c74d346d0938e509b943d6 (patch)
tree51bd017df5656cc0f9d7fcf1d62a23bcefeb763c
parentdb517b15f873efb9f2b65ef938858610b610f00e (diff)
downloadconscrypt-c98b32605b210d3239c74d346d0938e509b943d6.tar.gz
Allow parsing RSA keys from buffers with extra space at the end.
This was allowed in releases before O MR1, and some apps depend on the ability to do so. Bug: 69349260 Test: vogar libcore.javax.crypto.spec.KeyFactoryTestRSA Change-Id: Iede92e8974bf34577d80fea81a5944082d216081 (cherry picked from commit c99560e778b8913ac49b81f9fb7571cf2ad999fa)
-rw-r--r--common/src/jni/main/cpp/NativeCrypto.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/common/src/jni/main/cpp/NativeCrypto.cpp b/common/src/jni/main/cpp/NativeCrypto.cpp
index 521295fa..06b439b1 100644
--- a/common/src/jni/main/cpp/NativeCrypto.cpp
+++ b/common/src/jni/main/cpp/NativeCrypto.cpp
@@ -1098,7 +1098,7 @@ static jlong NativeCrypto_EVP_parse_private_key(JNIEnv* env, jclass, jbyteArray
CBS cbs;
CBS_init(&cbs, reinterpret_cast<const uint8_t*>(bytes.get()), bytes.size());
bssl::UniquePtr<EVP_PKEY> pkey(EVP_parse_private_key(&cbs));
- if (!pkey || CBS_len(&cbs) != 0) {
+ if (!pkey) {
Errors::throwParsingException(env, "Error parsing private key");
JNI_TRACE("bytes=%p EVP_parse_private_key => threw exception", keyJavaBytes);
return 0;
@@ -1150,7 +1150,7 @@ static jlong NativeCrypto_EVP_parse_public_key(JNIEnv* env, jclass, jbyteArray k
CBS cbs;
CBS_init(&cbs, reinterpret_cast<const uint8_t*>(bytes.get()), bytes.size());
bssl::UniquePtr<EVP_PKEY> pkey(EVP_parse_public_key(&cbs));
- if (!pkey || CBS_len(&cbs) != 0) {
+ if (!pkey) {
Errors::throwParsingException(env, "Error parsing public key");
JNI_TRACE("bytes=%p EVP_parse_public_key => threw exception", keyJavaBytes);
return 0;