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 "crypto/signature_creator.h" | 5 #include "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 26 matching lines...) Expand all Loading... |
37 SECStatus rv = SGN_Begin(result->sign_context_); | 37 SECStatus rv = SGN_Begin(result->sign_context_); |
38 if (rv != SECSuccess) { | 38 if (rv != SECSuccess) { |
39 NOTREACHED(); | 39 NOTREACHED(); |
40 return NULL; | 40 return NULL; |
41 } | 41 } |
42 | 42 |
43 return result.release(); | 43 return result.release(); |
44 } | 44 } |
45 | 45 |
46 bool SignatureCreator::Update(const uint8* data_part, int data_part_len) { | 46 bool SignatureCreator::Update(const uint8* data_part, int data_part_len) { |
47 SECStatus rv = SGN_Update(sign_context_, data_part, data_part_len); | 47 // TODO(wtc): Remove this const_cast when we require NSS 3.12.5. |
| 48 // See NSS bug https://bugzilla.mozilla.org/show_bug.cgi?id=518255 |
| 49 SECStatus rv = SGN_Update(sign_context_, |
| 50 const_cast<unsigned char*>(data_part), |
| 51 data_part_len); |
48 if (rv != SECSuccess) { | 52 if (rv != SECSuccess) { |
49 NOTREACHED(); | 53 NOTREACHED(); |
50 return false; | 54 return false; |
51 } | 55 } |
52 | 56 |
53 return true; | 57 return true; |
54 } | 58 } |
55 | 59 |
56 bool SignatureCreator::Final(std::vector<uint8>* signature) { | 60 bool SignatureCreator::Final(std::vector<uint8>* signature) { |
57 SECItem signature_item; | 61 SECItem signature_item; |
58 SECStatus rv = SGN_End(sign_context_, &signature_item); | 62 SECStatus rv = SGN_End(sign_context_, &signature_item); |
59 if (rv != SECSuccess) { | 63 if (rv != SECSuccess) { |
60 NOTREACHED(); | 64 NOTREACHED(); |
61 return false; | 65 return false; |
62 } | 66 } |
63 signature->assign(signature_item.data, | 67 signature->assign(signature_item.data, |
64 signature_item.data + signature_item.len); | 68 signature_item.data + signature_item.len); |
65 SECITEM_FreeItem(&signature_item, PR_FALSE); | 69 SECITEM_FreeItem(&signature_item, PR_FALSE); |
66 return true; | 70 return true; |
67 } | 71 } |
68 | 72 |
69 SignatureCreator::SignatureCreator() | 73 SignatureCreator::SignatureCreator() |
70 : key_(NULL), | 74 : key_(NULL), |
71 sign_context_(NULL) { | 75 sign_context_(NULL) { |
72 EnsureNSSInit(); | 76 EnsureNSSInit(); |
73 } | 77 } |
74 | 78 |
75 } // namespace crypto | 79 } // namespace crypto |
OLD | NEW |