| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/crypto/signature_creator.h" | 5 #include "base/crypto/signature_creator.h" |
| 6 | 6 |
| 7 #include <cryptohi.h> | 7 #include <cryptohi.h> |
| 8 #include <keyhi.h> | 8 #include <keyhi.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 | 41 |
| 42 SignatureCreator::~SignatureCreator() { | 42 SignatureCreator::~SignatureCreator() { |
| 43 if (sign_context_) { | 43 if (sign_context_) { |
| 44 SGN_DestroyContext(sign_context_, PR_TRUE); | 44 SGN_DestroyContext(sign_context_, PR_TRUE); |
| 45 sign_context_ = NULL; | 45 sign_context_ = NULL; |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool SignatureCreator::Update(const uint8* data_part, int data_part_len) { | 49 bool SignatureCreator::Update(const uint8* data_part, int data_part_len) { |
| 50 // TODO(wtc): Remove this const_cast when we require NSS 3.12.5. |
| 51 // See NSS bug https://bugzilla.mozilla.org/show_bug.cgi?id=518255 |
| 50 SECStatus rv = SGN_Update(sign_context_, | 52 SECStatus rv = SGN_Update(sign_context_, |
| 51 const_cast<unsigned char*>(data_part), | 53 const_cast<unsigned char*>(data_part), |
| 52 data_part_len); | 54 data_part_len); |
| 53 if (rv != SECSuccess) { | 55 if (rv != SECSuccess) { |
| 54 NOTREACHED(); | 56 NOTREACHED(); |
| 55 return false; | 57 return false; |
| 56 } | 58 } |
| 57 | 59 |
| 58 return true; | 60 return true; |
| 59 } | 61 } |
| 60 | 62 |
| 61 bool SignatureCreator::Final(std::vector<uint8>* signature) { | 63 bool SignatureCreator::Final(std::vector<uint8>* signature) { |
| 62 SECItem signature_item; | 64 SECItem signature_item; |
| 63 SECStatus rv = SGN_End(sign_context_, &signature_item); | 65 SECStatus rv = SGN_End(sign_context_, &signature_item); |
| 64 if (rv != SECSuccess) { | 66 if (rv != SECSuccess) { |
| 65 NOTREACHED(); | 67 NOTREACHED(); |
| 66 return false; | 68 return false; |
| 67 } | 69 } |
| 68 signature->assign(signature_item.data, | 70 signature->assign(signature_item.data, |
| 69 signature_item.data + signature_item.len); | 71 signature_item.data + signature_item.len); |
| 70 SECITEM_FreeItem(&signature_item, PR_FALSE); | 72 SECITEM_FreeItem(&signature_item, PR_FALSE); |
| 71 return true; | 73 return true; |
| 72 } | 74 } |
| 73 | 75 |
| 74 } // namespace base | 76 } // namespace base |
| OLD | NEW |