OLD | NEW |
| (Empty) |
1 /* | |
2 * crypto.h - public data structures and prototypes for the crypto library | |
3 * | |
4 * This Source Code Form is subject to the terms of the Mozilla Public | |
5 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
7 /* $Id: secdig.h,v 1.10 2012/04/25 14:50:16 gerv%gerv.net Exp $ */ | |
8 | |
9 #ifndef _SECDIG_H_ | |
10 #define _SECDIG_H_ | |
11 | |
12 #include "utilrename.h" | |
13 #include "secdigt.h" | |
14 | |
15 #include "seccomon.h" | |
16 #include "secasn1t.h" | |
17 #include "secdert.h" | |
18 | |
19 SEC_BEGIN_PROTOS | |
20 | |
21 | |
22 extern const SEC_ASN1Template sgn_DigestInfoTemplate[]; | |
23 | |
24 SEC_ASN1_CHOOSER_DECLARE(sgn_DigestInfoTemplate) | |
25 | |
26 /****************************************/ | |
27 /* | |
28 ** Digest-info functions | |
29 */ | |
30 | |
31 /* | |
32 ** Create a new digest-info object | |
33 ** "algorithm" one of SEC_OID_MD2, SEC_OID_MD5, or SEC_OID_SHA1 | |
34 ** "sig" the raw signature data (from MD2 or MD5) | |
35 ** "sigLen" the length of the signature data | |
36 ** | |
37 ** NOTE: this is a low level routine used to prepare some data for PKCS#1 | |
38 ** digital signature formatting. | |
39 ** | |
40 ** XXX It might be nice to combine the create and encode functions. | |
41 ** I think that is all anybody ever wants to do anyway. | |
42 */ | |
43 extern SGNDigestInfo *SGN_CreateDigestInfo(SECOidTag algorithm, | |
44 unsigned char *sig, | |
45 unsigned int sigLen); | |
46 | |
47 /* | |
48 ** Destroy a digest-info object | |
49 */ | |
50 extern void SGN_DestroyDigestInfo(SGNDigestInfo *info); | |
51 | |
52 /* | |
53 ** Encode a digest-info object | |
54 ** "poolp" is where to allocate the result from; it can be NULL in | |
55 ** which case generic heap allocation (XP_ALLOC) will be used | |
56 ** "dest" is where to store the result; it can be NULL, in which case | |
57 ** it will be allocated (from poolp or heap, as explained above) | |
58 ** "diginfo" is the object to be encoded | |
59 ** The return value is NULL if any error occurred, otherwise it is the | |
60 ** resulting SECItem (either allocated or the same as the "dest" parameter). | |
61 ** | |
62 ** XXX It might be nice to combine the create and encode functions. | |
63 ** I think that is all anybody ever wants to do anyway. | |
64 */ | |
65 extern SECItem *SGN_EncodeDigestInfo(PLArenaPool *poolp, SECItem *dest, | |
66 SGNDigestInfo *diginfo); | |
67 | |
68 /* | |
69 ** Decode a DER encoded digest info objct. | |
70 ** didata is thr source of the encoded digest. | |
71 ** The return value is NULL if an error occurs. Otherwise, a | |
72 ** digest info object which is allocated within it's own | |
73 ** pool is returned. The digest info should be deleted | |
74 ** by later calling SGN_DestroyDigestInfo. | |
75 */ | |
76 extern SGNDigestInfo *SGN_DecodeDigestInfo(SECItem *didata); | |
77 | |
78 | |
79 /* | |
80 ** Copy digest info. | |
81 ** poolp is the arena to which the digest will be copied. | |
82 ** a is the destination digest, it must be non-NULL. | |
83 ** b is the source digest | |
84 ** This function is for copying digests. It allows digests | |
85 ** to be copied into a specified pool. If the digest is in | |
86 ** the same pool as other data, you do not want to delete | |
87 ** the digest by calling SGN_DestroyDigestInfo. | |
88 ** A return value of SECFailure indicates an error. A return | |
89 ** of SECSuccess indicates no error occurred. | |
90 */ | |
91 extern SECStatus SGN_CopyDigestInfo(PLArenaPool *poolp, | |
92 SGNDigestInfo *a, | |
93 SGNDigestInfo *b); | |
94 | |
95 /* | |
96 ** Compare two digest-info objects, returning the difference between | |
97 ** them. | |
98 */ | |
99 extern SECComparison SGN_CompareDigestInfo(SGNDigestInfo *a, SGNDigestInfo *b); | |
100 | |
101 | |
102 SEC_END_PROTOS | |
103 | |
104 #endif /* _SECDIG_H_ */ | |
OLD | NEW |