Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Side by Side Diff: base/hmac_nss.cc

Issue 4273: Fix some issues found looking at the code. I have made two posts about it:... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/hmac_mac.cc ('k') | base/hmac_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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/hmac.h" 5 #include "base/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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 plat_->sym_key_.reset(PK11_ImportSymKey(plat_->slot_.get(), 59 plat_->sym_key_.reset(PK11_ImportSymKey(plat_->slot_.get(),
60 CKM_SHA_1_HMAC, 60 CKM_SHA_1_HMAC,
61 PK11_OriginUnwrap, 61 PK11_OriginUnwrap,
62 CKA_SIGN, 62 CKA_SIGN,
63 &key_item, 63 &key_item,
64 NULL)); 64 NULL));
65 CHECK(plat_->sym_key_.get()); 65 CHECK(plat_->sym_key_.get());
66 } 66 }
67 67
68 HMAC::~HMAC() { 68 HMAC::~HMAC() {
69 delete plat_;
70 } 69 }
71 70
72 bool HMAC::Sign(const std::string& data, 71 bool HMAC::Sign(const std::string& data,
73 unsigned char* digest, 72 unsigned char* digest,
74 int digest_length) { 73 int digest_length) {
75 SECItem param = { siBuffer, NULL, 0 }; 74 SECItem param = { siBuffer, NULL, 0 };
76 ScopedNSSContext context(PK11_CreateContextBySymKey(CKM_SHA_1_HMAC, 75 ScopedNSSContext context(PK11_CreateContextBySymKey(CKM_SHA_1_HMAC,
77 CKA_SIGN, 76 CKA_SIGN,
78 plat_->sym_key_.get(), 77 plat_->sym_key_.get(),
79 &param)); 78 &param));
(...skipping 18 matching lines...) Expand all
98 if (PK11_DigestFinal(context.get(), 97 if (PK11_DigestFinal(context.get(),
99 digest, &len, digest_length) != SECSuccess) { 98 digest, &len, digest_length) != SECSuccess) {
100 NOTREACHED(); 99 NOTREACHED();
101 return false; 100 return false;
102 } 101 }
103 102
104 return true; 103 return true;
105 } 104 }
106 105
107 } // namespace base 106 } // namespace base
OLDNEW
« no previous file with comments | « base/hmac_mac.cc ('k') | base/hmac_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698