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