OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 #include "cryptohi.h" | 4 #include "cryptohi.h" |
5 #include "secasn1.h" | 5 #include "secasn1.h" |
6 #include "secitem.h" | 6 #include "secitem.h" |
7 #include "prerr.h" | 7 #include "prerr.h" |
8 | 8 |
9 #ifndef DSA1_SUBPRIME_LEN | 9 #ifndef DSA1_SUBPRIME_LEN |
10 #define DSA1_SUBPRIME_LEN 20 /* bytes */ | 10 #define DSA1_SUBPRIME_LEN 20 /* bytes */ |
11 #endif | 11 #endif |
12 | 12 |
13 typedef struct { | 13 typedef struct { |
14 SECItem r; | 14 SECItem r; |
15 SECItem s; | 15 SECItem s; |
16 } DSA_ASN1Signature; | 16 } DSA_ASN1Signature; |
17 | 17 |
18 const SEC_ASN1Template DSA_SignatureTemplate[] = | 18 const SEC_ASN1Template DSA_SignatureTemplate[] = |
19 { | 19 { |
20 { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(DSA_ASN1Signature) }, | 20 { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(DSA_ASN1Signature) }, |
21 { SEC_ASN1_INTEGER, offsetof(DSA_ASN1Signature,r) }, | 21 { SEC_ASN1_INTEGER, offsetof(DSA_ASN1Signature,r) }, |
22 { SEC_ASN1_INTEGER, offsetof(DSA_ASN1Signature,s) }, | 22 { SEC_ASN1_INTEGER, offsetof(DSA_ASN1Signature,s) }, |
23 { 0, } | 23 { 0 } |
24 }; | 24 }; |
25 | 25 |
26 /* Input is variable length multi-byte integer, MSB first (big endian). | 26 /* Input is variable length multi-byte integer, MSB first (big endian). |
27 ** Most signficant bit of first byte is NOT treated as a sign bit.· | 27 ** Most signficant bit of first byte is NOT treated as a sign bit.· |
28 ** May be one or more leading bytes of zeros.· | 28 ** May be one or more leading bytes of zeros.· |
29 ** Output is variable length multi-byte integer, MSB first (big endian). | 29 ** Output is variable length multi-byte integer, MSB first (big endian). |
30 ** Most significant bit of first byte will be zero (positive sign bit) | 30 ** Most significant bit of first byte will be zero (positive sign bit) |
31 ** No more than one leading zero byte. | 31 ** No more than one leading zero byte. |
32 ** Caller supplies dest buffer, and assures that it is long enough, | 32 ** Caller supplies dest buffer, and assures that it is long enough, |
33 ** e.g. at least one byte longer that src's buffer. | 33 ** e.g. at least one byte longer that src's buffer. |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 /* src is a DER-encoded ECDSA signature. | 258 /* src is a DER-encoded ECDSA signature. |
259 ** Returns a newly-allocated SECItem structure, pointing at a newly allocated | 259 ** Returns a newly-allocated SECItem structure, pointing at a newly allocated |
260 ** buffer containing the "raw" ECDSA signature of length len containing | 260 ** buffer containing the "raw" ECDSA signature of length len containing |
261 ** r followed by s (both padded to take up exactly len/2 bytes). | 261 ** r followed by s (both padded to take up exactly len/2 bytes). |
262 */ | 262 */ |
263 SECItem * | 263 SECItem * |
264 DSAU_DecodeDerSigToLen(const SECItem *item, unsigned int len) | 264 DSAU_DecodeDerSigToLen(const SECItem *item, unsigned int len) |
265 { | 265 { |
266 return common_DecodeDerSig(item, len/2); | 266 return common_DecodeDerSig(item, len/2); |
267 } | 267 } |
OLD | NEW |