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

Side by Side Diff: base/hmac_nss.cc

Issue 6085015: Order function definitions in base/ according to the header. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: lrn2merge Created 9 years, 11 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/global_descriptors_posix.cc ('k') | base/json/json_reader.h » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/crypto/scoped_nss_types.h" 10 #include "base/crypto/scoped_nss_types.h"
(...skipping 18 matching lines...) Expand all
29 break; 29 break;
30 case SHA256: 30 case SHA256:
31 plat_->mechanism_ = CKM_SHA256_HMAC; 31 plat_->mechanism_ = CKM_SHA256_HMAC;
32 break; 32 break;
33 default: 33 default:
34 NOTREACHED() << "Unsupported hash algorithm"; 34 NOTREACHED() << "Unsupported hash algorithm";
35 break; 35 break;
36 } 36 }
37 } 37 }
38 38
39 HMAC::~HMAC() {
40 }
41
39 bool HMAC::Init(const unsigned char *key, int key_length) { 42 bool HMAC::Init(const unsigned char *key, int key_length) {
40 base::EnsureNSSInit(); 43 base::EnsureNSSInit();
41 44
42 if (plat_->slot_.get()) { 45 if (plat_->slot_.get()) {
43 // Init must not be called more than twice on the same HMAC object. 46 // Init must not be called more than twice on the same HMAC object.
44 NOTREACHED(); 47 NOTREACHED();
45 return false; 48 return false;
46 } 49 }
47 50
48 plat_->slot_.reset(PK11_GetBestSlot(plat_->mechanism_, NULL)); 51 plat_->slot_.reset(PK11_GetBestSlot(plat_->mechanism_, NULL));
(...skipping 14 matching lines...) Expand all
63 &key_item, 66 &key_item,
64 NULL)); 67 NULL));
65 if (!plat_->sym_key_.get()) { 68 if (!plat_->sym_key_.get()) {
66 NOTREACHED(); 69 NOTREACHED();
67 return false; 70 return false;
68 } 71 }
69 72
70 return true; 73 return true;
71 } 74 }
72 75
73 HMAC::~HMAC() {
74 }
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) {
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 };
(...skipping 22 matching lines...) Expand all
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 base 117 } // namespace base
OLDNEW
« no previous file with comments | « base/global_descriptors_posix.cc ('k') | base/json/json_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698