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

Side by Side Diff: base/crypto/signature_verifier_mac.cc

Issue 259026: Implement signature_creator_mac (Closed)
Patch Set: cr change Created 11 years, 2 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
« no previous file with comments | « base/crypto/signature_creator_mac.cc ('k') | no next file » | 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) 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_verifier.h" 5 #include "base/crypto/signature_verifier.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "base/crypto/cssm_init.h" 9 #include "base/crypto/cssm_init.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 11
12 namespace {
13
14 void* AppMalloc(CSSM_SIZE size, void *alloc_ref) {
15 return malloc(size);
16 }
17
18 void AppFree(void* mem_ptr, void* alloc_ref) {
19 free(mem_ptr);
20 }
21
22 void* AppRealloc(void* ptr, CSSM_SIZE size, void* alloc_ref) {
23 return realloc(ptr, size);
24 }
25
26 void* AppCalloc(uint32 num, CSSM_SIZE size, void* alloc_ref) {
27 return calloc(num, size);
28 }
29
30 const CSSM_API_MEMORY_FUNCS mem_funcs = {
31 AppMalloc,
32 AppFree,
33 AppRealloc,
34 AppCalloc,
35 NULL
36 };
37
38 } // namespace
39
40 namespace base { 12 namespace base {
41 13
42 SignatureVerifier::SignatureVerifier() : csp_handle_(0), sig_handle_(0) { 14 SignatureVerifier::SignatureVerifier() : csp_handle_(0), sig_handle_(0) {
43 EnsureCSSMInit(); 15 EnsureCSSMInit();
44 16
45 static CSSM_VERSION version = {2, 0}; 17 static CSSM_VERSION version = {2, 0};
46 CSSM_RETURN crtn; 18 CSSM_RETURN crtn;
47 crtn = CSSM_ModuleAttach(&gGuidAppleCSP, &version, &mem_funcs, 0, 19 crtn = CSSM_ModuleAttach(&gGuidAppleCSP, &version, &kCssmMemoryFunctions, 0,
48 CSSM_SERVICE_CSP, 0, CSSM_KEY_HIERARCHY_NONE, 20 CSSM_SERVICE_CSP, 0, CSSM_KEY_HIERARCHY_NONE,
49 NULL, 0, NULL, &csp_handle_); 21 NULL, 0, NULL, &csp_handle_);
50 DCHECK(crtn == CSSM_OK); 22 DCHECK(crtn == CSSM_OK);
51 } 23 }
52 24
53 SignatureVerifier::~SignatureVerifier() { 25 SignatureVerifier::~SignatureVerifier() {
54 Reset(); 26 Reset();
55 if (csp_handle_) { 27 if (csp_handle_) {
56 CSSM_RETURN crtn = CSSM_ModuleDetach(csp_handle_); 28 CSSM_RETURN crtn = CSSM_ModuleDetach(csp_handle_);
57 DCHECK(crtn == CSSM_OK); 29 DCHECK(crtn == CSSM_OK);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 sig_handle_ = 0; 106 sig_handle_ = 0;
135 } 107 }
136 signature_.clear(); 108 signature_.clear();
137 109
138 // Can't call CSSM_FreeKey on public_key_ because we constructed 110 // Can't call CSSM_FreeKey on public_key_ because we constructed
139 // public_key_ manually. 111 // public_key_ manually.
140 } 112 }
141 113
142 } // namespace base 114 } // namespace base
143 115
OLDNEW
« no previous file with comments | « base/crypto/signature_creator_mac.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698