| OLD | NEW |
| 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- | 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 * | 2 * |
| 3 * ***** BEGIN LICENSE BLOCK ***** | 3 * ***** BEGIN LICENSE BLOCK ***** |
| 4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 5 * | 5 * |
| 6 * The contents of this file are subject to the Mozilla Public License Version | 6 * The contents of this file are subject to the Mozilla Public License Version |
| 7 * 1.1 (the "License"); you may not use this file except in compliance with | 7 * 1.1 (the "License"); you may not use this file except in compliance with |
| 8 * the License. You may obtain a copy of the License at | 8 * the License. You may obtain a copy of the License at |
| 9 * http://www.mozilla.org/MPL/ | 9 * http://www.mozilla.org/MPL/ |
| 10 * | 10 * |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // Sign the DER encoded PublicKeyAndChallenge. | 208 // Sign the DER encoded PublicKeyAndChallenge. |
| 209 sec_rv = SEC_DerSignData(arena, &signedItem, pkacItem.data, pkacItem.len, | 209 sec_rv = SEC_DerSignData(arena, &signedItem, pkacItem.data, pkacItem.len, |
| 210 privateKey, algTag); | 210 privateKey, algTag); |
| 211 if (SECSuccess != sec_rv) { | 211 if (SECSuccess != sec_rv) { |
| 212 LOG(ERROR) << "Couldn't sign the DER encoded PublicKeyandChallenge"; | 212 LOG(ERROR) << "Couldn't sign the DER encoded PublicKeyandChallenge"; |
| 213 isSuccess = false; | 213 isSuccess = false; |
| 214 goto failure; | 214 goto failure; |
| 215 } | 215 } |
| 216 | 216 |
| 217 // Convert the signed public key and challenge into base64/ascii. | 217 // Convert the signed public key and challenge into base64/ascii. |
| 218 base::Base64Encode( | 218 if (!base::Base64Encode(std::string(reinterpret_cast<char*>(signedItem.data), |
| 219 std::string(reinterpret_cast<char*>(signedItem.data), signedItem.len), | 219 signedItem.len), |
| 220 &result_blob); | 220 &result_blob)) { |
| 221 LOG(ERROR) << "Couldn't convert signed public key into base64"; |
| 222 isSuccess = false; |
| 223 goto failure; |
| 224 } |
| 221 | 225 |
| 222 failure: | 226 failure: |
| 223 if (!isSuccess) { | 227 if (!isSuccess) { |
| 224 LOG(ERROR) << "SSL Keygen failed! (NSS error code " << PR_GetError() << ")"; | 228 LOG(ERROR) << "SSL Keygen failed! (NSS error code " << PR_GetError() << ")"; |
| 225 } else { | 229 } else { |
| 226 VLOG(1) << "SSL Keygen succeeded!"; | 230 VLOG(1) << "SSL Keygen succeeded!"; |
| 227 } | 231 } |
| 228 | 232 |
| 229 // Do cleanups | 233 // Do cleanups |
| 230 if (privateKey) { | 234 if (privateKey) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 248 SECKEY_DestroySubjectPublicKeyInfo(spkInfo); | 252 SECKEY_DestroySubjectPublicKeyInfo(spkInfo); |
| 249 } | 253 } |
| 250 if (arena) { | 254 if (arena) { |
| 251 PORT_FreeArena(arena, PR_TRUE); | 255 PORT_FreeArena(arena, PR_TRUE); |
| 252 } | 256 } |
| 253 | 257 |
| 254 return (isSuccess ? result_blob : std::string()); | 258 return (isSuccess ? result_blob : std::string()); |
| 255 } | 259 } |
| 256 | 260 |
| 257 } // namespace mozilla_security_manager | 261 } // namespace mozilla_security_manager |
| OLD | NEW |