| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/cert/jwk_serializer.h" | 5 #include "net/cert/jwk_serializer.h" |
| 6 | 6 |
| 7 #include <cert.h> | 7 #include <cert.h> |
| 8 #include <keyhi.h> | 8 #include <keyhi.h> |
| 9 #include <nss.h> | 9 #include <nss.h> |
| 10 | 10 |
| 11 #include "base/base64.h" | 11 #include "base/base64.h" |
| 12 #include "base/logging.h" |
| 12 #include "base/values.h" | 13 #include "base/values.h" |
| 13 #include "crypto/nss_util.h" | 14 #include "crypto/nss_util.h" |
| 14 #include "crypto/scoped_nss_types.h" | 15 #include "crypto/scoped_nss_types.h" |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 | 18 |
| 18 namespace JwkSerializer { | 19 namespace JwkSerializer { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 SECKEY_DestroySubjectPublicKeyInfo> > | 76 SECKEY_DestroySubjectPublicKeyInfo> > |
| 76 ScopedCERTSubjectPublicKeyInfo; | 77 ScopedCERTSubjectPublicKeyInfo; |
| 77 | 78 |
| 78 } // namespace | 79 } // namespace |
| 79 | 80 |
| 80 bool ConvertSpkiFromDerToJwk( | 81 bool ConvertSpkiFromDerToJwk( |
| 81 const base::StringPiece& spki_der, | 82 const base::StringPiece& spki_der, |
| 82 base::DictionaryValue* public_key_jwk) { | 83 base::DictionaryValue* public_key_jwk) { |
| 83 public_key_jwk->Clear(); | 84 public_key_jwk->Clear(); |
| 84 | 85 |
| 86 LOG(ERROR) << "HIIIIIIIIIIIIIIIIIIIIIIIIIII"; |
| 85 crypto::EnsureNSSInit(); | 87 crypto::EnsureNSSInit(); |
| 86 | 88 |
| 87 if (!NSS_IsInitialized()) | 89 if (!NSS_IsInitialized()) |
| 88 return false; | 90 return false; |
| 89 | 91 |
| 90 SECItem sec_item; | 92 SECItem sec_item; |
| 91 sec_item.data = const_cast<unsigned char*>( | 93 sec_item.data = const_cast<unsigned char*>( |
| 92 reinterpret_cast<const unsigned char*>(spki_der.data())); | 94 reinterpret_cast<const unsigned char*>(spki_der.data())); |
| 93 sec_item.len = spki_der.size(); | 95 sec_item.len = spki_der.size(); |
| 94 ScopedCERTSubjectPublicKeyInfo spki( | 96 ScopedCERTSubjectPublicKeyInfo spki( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 109 sizeof(kIdEcPublicKey))) { | 111 sizeof(kIdEcPublicKey))) { |
| 110 rv = ConvertEcPublicKeyInfoToJwk(spki.get(), public_key_jwk); | 112 rv = ConvertEcPublicKeyInfoToJwk(spki.get(), public_key_jwk); |
| 111 } | 113 } |
| 112 // TODO(juanlang): other algorithms | 114 // TODO(juanlang): other algorithms |
| 113 return rv; | 115 return rv; |
| 114 } | 116 } |
| 115 | 117 |
| 116 } // namespace JwkSerializer | 118 } // namespace JwkSerializer |
| 117 | 119 |
| 118 } // namespace net | 120 } // namespace net |
| OLD | NEW |