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 28 matching lines...) Expand all Loading... | |
39 | 39 |
40 } // namespace | 40 } // namespace |
41 | 41 |
42 SignatureCreator::~SignatureCreator() { | 42 SignatureCreator::~SignatureCreator() { |
43 if (sign_context_) { | 43 if (sign_context_) { |
44 SGN_DestroyContext(sign_context_, PR_TRUE); | 44 SGN_DestroyContext(sign_context_, PR_TRUE); |
45 sign_context_ = NULL; | 45 sign_context_ = NULL; |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 SignatureCreator* SignatureCreator::Create(RSAPrivateKey* key, | |
50 HashAlgorithm hash_algm) { | |
davidben
2015/08/21 21:52:22
hash_alg, to match the others?
| |
51 return SignatureCreator::CreateImpl(key, hash_algm, false); | |
52 } | |
53 | |
54 SignatureCreator* SignatureCreator::CreatePSS(RSAPrivateKey* key, | |
55 HashAlgorithm hash_algm) { | |
56 return SignatureCreator::CreateImpl(key, hash_algm, true); | |
57 } | |
58 | |
49 // static | 59 // static |
50 SignatureCreator* SignatureCreator::Create(RSAPrivateKey* key, | 60 SignatureCreator* SignatureCreator::CreateImpl(RSAPrivateKey* key, |
51 HashAlgorithm hash_alg) { | 61 HashAlgorithm hash_alg, |
62 bool use_pss) { | |
63 if (use_pss) { | |
64 // TODO(rch): make this work :> | |
65 NOTREACHED(); | |
66 return NULL; | |
davidben
2015/08/21 21:52:22
Pfft. Judging by crypto/signature_verifier_nss.cc,
| |
67 } | |
52 scoped_ptr<SignatureCreator> result(new SignatureCreator); | 68 scoped_ptr<SignatureCreator> result(new SignatureCreator); |
53 result->sign_context_ = SGN_NewContext(ToNSSSigOid(hash_alg), key->key()); | 69 result->sign_context_ = SGN_NewContext(ToNSSSigOid(hash_alg), key->key()); |
54 if (!result->sign_context_) { | 70 if (!result->sign_context_) { |
55 NOTREACHED(); | 71 NOTREACHED(); |
56 return NULL; | 72 return NULL; |
57 } | 73 } |
58 | 74 |
59 SECStatus rv = SGN_Begin(result->sign_context_); | 75 SECStatus rv = SGN_Begin(result->sign_context_); |
60 if (rv != SECSuccess) { | 76 if (rv != SECSuccess) { |
61 NOTREACHED(); | 77 NOTREACHED(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 signature_item.data + signature_item.len); | 125 signature_item.data + signature_item.len); |
110 SECITEM_FreeItem(&signature_item, PR_FALSE); | 126 SECITEM_FreeItem(&signature_item, PR_FALSE); |
111 return true; | 127 return true; |
112 } | 128 } |
113 | 129 |
114 SignatureCreator::SignatureCreator() : sign_context_(NULL) { | 130 SignatureCreator::SignatureCreator() : sign_context_(NULL) { |
115 EnsureNSSInit(); | 131 EnsureNSSInit(); |
116 } | 132 } |
117 | 133 |
118 } // namespace crypto | 134 } // namespace crypto |
OLD | NEW |