OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/base/openssl_private_key_store.h" | 5 #include "net/base/openssl_private_key_store.h" |
6 | 6 |
7 #include <openssl/evp.h> | 7 #include <openssl/evp.h> |
8 #include <openssl/mem.h> | 8 #include <openssl/mem.h> |
9 #include <openssl/x509.h> | 9 #include <openssl/x509.h> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 // in a format that is incompatible with what the platform expects. | 31 // in a format that is incompatible with what the platform expects. |
32 unsigned char* private_key = NULL; | 32 unsigned char* private_key = NULL; |
33 int private_len = 0; | 33 int private_len = 0; |
34 ScopedPKCS8_PRIV_KEY_INFO pkcs8(EVP_PKEY2PKCS8(pkey)); | 34 ScopedPKCS8_PRIV_KEY_INFO pkcs8(EVP_PKEY2PKCS8(pkey)); |
35 if (!pkcs8) { | 35 if (!pkcs8) { |
36 private_len = i2d_PKCS8_PRIV_KEY_INFO(pkcs8.get(), &private_key); | 36 private_len = i2d_PKCS8_PRIV_KEY_INFO(pkcs8.get(), &private_key); |
37 } | 37 } |
38 bool ret = false; | 38 bool ret = false; |
39 if (public_len > 0 && private_len > 0) { | 39 if (public_len > 0 && private_len > 0) { |
40 ret = android::StoreKeyPair( | 40 ret = android::StoreKeyPair( |
41 static_cast<const uint8*>(public_key), public_len, | 41 static_cast<const uint8_t*>(public_key), public_len, |
42 static_cast<const uint8*>(private_key), private_len); | 42 static_cast<const uint8_t*>(private_key), private_len); |
43 } | 43 } |
44 LOG_IF(ERROR, !ret) << "StoreKeyPair failed. pub len = " << public_len | 44 LOG_IF(ERROR, !ret) << "StoreKeyPair failed. pub len = " << public_len |
45 << " priv len = " << private_len; | 45 << " priv len = " << private_len; |
46 OPENSSL_free(public_key); | 46 OPENSSL_free(public_key); |
47 OPENSSL_free(private_key); | 47 OPENSSL_free(private_key); |
48 return ret; | 48 return ret; |
49 } | 49 } |
50 | 50 |
51 } // namespace net | 51 } // namespace net |
OLD | NEW |