OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/hmac.h" | 5 #include "crypto/hmac.h" |
6 | 6 |
7 #include <nss.h> | 7 #include <nss.h> |
8 #include <pk11pub.h> | 8 #include <pk11pub.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 if (!plat_->sym_key_.get()) { | 68 if (!plat_->sym_key_.get()) { |
69 NOTREACHED(); | 69 NOTREACHED(); |
70 return false; | 70 return false; |
71 } | 71 } |
72 | 72 |
73 return true; | 73 return true; |
74 } | 74 } |
75 | 75 |
76 bool HMAC::Sign(const std::string& data, | 76 bool HMAC::Sign(const std::string& data, |
77 unsigned char* digest, | 77 unsigned char* digest, |
78 int digest_length) { | 78 int digest_length) const { |
79 if (!plat_->sym_key_.get()) { | 79 if (!plat_->sym_key_.get()) { |
80 // Init has not been called before Sign. | 80 // Init has not been called before Sign. |
81 NOTREACHED(); | 81 NOTREACHED(); |
82 return false; | 82 return false; |
83 } | 83 } |
84 | 84 |
85 SECItem param = { siBuffer, NULL, 0 }; | 85 SECItem param = { siBuffer, NULL, 0 }; |
86 ScopedPK11Context context(PK11_CreateContextBySymKey(plat_->mechanism_, | 86 ScopedPK11Context context(PK11_CreateContextBySymKey(plat_->mechanism_, |
87 CKA_SIGN, | 87 CKA_SIGN, |
88 plat_->sym_key_.get(), | 88 plat_->sym_key_.get(), |
(...skipping 19 matching lines...) Expand all Loading... |
108 if (PK11_DigestFinal(context.get(), | 108 if (PK11_DigestFinal(context.get(), |
109 digest, &len, digest_length) != SECSuccess) { | 109 digest, &len, digest_length) != SECSuccess) { |
110 NOTREACHED(); | 110 NOTREACHED(); |
111 return false; | 111 return false; |
112 } | 112 } |
113 | 113 |
114 return true; | 114 return true; |
115 } | 115 } |
116 | 116 |
117 } // namespace crypto | 117 } // namespace crypto |
OLD | NEW |