Chromium Code Reviews| Index: net/base/openssl_private_key_store_android.cc |
| diff --git a/net/base/openssl_private_key_store_android.cc b/net/base/openssl_private_key_store_android.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2013ce2fa3ca2851861babb5593be9f44bb9a7c4 |
| --- /dev/null |
| +++ b/net/base/openssl_private_key_store_android.cc |
| @@ -0,0 +1,72 @@ |
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <openssl/evp.h> |
| + |
| +#include "net/base/openssl_private_key_store.h" |
|
wtc
2011/08/09 18:47:22
This header probably should be listed first.
michaelbai
2011/08/11 16:10:18
Done.
|
| + |
| +#include "base/logging.h" |
| +#include "base/memory/singleton.h" |
| +#include "crypto/openssl_util.h" |
| +#include "net/android/network_library.h" |
| + |
| +namespace net { |
| + |
| +namespace { |
| + |
| +class OpenSSLKeyStoreAndroid : public OpenSSLPrivateKeyStore { |
| + public: |
| + ~OpenSSLKeyStoreAndroid() {} |
| + |
| + // TODO(joth): Use the |url| to help identify this key to the user. |
| + // Currently Android has no UI to list these stored private keys (and no |
| + // API to associate a name with them), so this is a non-issue. |
| + virtual bool StorePrivateKey(const GURL& url, EVP_PKEY* pkey) { |
| + uint8* public_key = NULL; |
| + int public_len = i2d_PublicKey(pkey, &public_key); |
| + uint8* private_key = NULL; |
| + int private_len = i2d_PrivateKey(pkey, &private_key); |
| + |
| + bool ret = false; |
| + if (public_len && private_len) { |
| + ret = net::android::StoreKeyPair(public_key, public_len, |
| + private_key, private_len); |
|
wtc
2011/08/09 18:47:22
Fix argument indentation.
michaelbai
2011/08/11 16:10:18
Done.
|
| + } |
| + LOG_IF(ERROR, !ret) << "StorePrivateKey failed. pub len = " << public_len |
| + << " priv len = " << private_len; |
| + OPENSSL_free(public_key); |
| + OPENSSL_free(private_key); |
| + return ret; |
| + } |
| + |
| + virtual EVP_PKEY* FetchPrivateKey(EVP_PKEY* pkey) { |
| + // TODO(joth): Implement when client authentication is required. |
| + NOTIMPLEMENTED(); |
| + return NULL; |
| + } |
| + |
| + static OpenSSLKeyStoreAndroid* GetInstance(); |
| + |
| + private: |
| + OpenSSLKeyStoreAndroid() {} |
| + friend struct DefaultSingletonTraits<OpenSSLKeyStoreAndroid>; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(OpenSSLKeyStoreAndroid); |
| +}; |
| + |
| +} // namespace |
| + |
| +// static |
| +OpenSSLKeyStoreAndroid* OpenSSLKeyStoreAndroid::GetInstance() { |
| + return Singleton<OpenSSLKeyStoreAndroid>::get(); |
| +} |
| + |
| +/* |
| +// static |
| +// TODO(MERGE): Conflict with openssl_memory_private_key_store.cc |
| +OpenSSLPrivateKeyStore* OpenSSLPrivateKeyStore::GetInstance() { |
| + return OpenSSLKeyStoreAndroid::GetInstance(); |
| +} |
| +*/ |
|
wtc
2011/08/09 18:47:22
Please use
#if 0
...
#endif
to comment out a bloc
michaelbai
2011/08/11 16:10:18
Fixed, This introduced in the merge and fixed in g
|
| +} // namespace net |