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 | 4 |
5 /* | 5 /* |
6 * Support routines for PKCS7 implementation, none of which are exported. | 6 * Support routines for PKCS7 implementation, none of which are exported. |
7 * This file should only contain things that are needed by both the | 7 * This file should only contain things that are needed by both the |
8 * encoding/creation side *and* the decoding/decryption side. Anything | 8 * encoding/creation side *and* the decoding/decryption side. Anything |
9 * else should be static routines in the appropriate file. | 9 * else should be static routines in the appropriate file. |
10 */ | 10 */ |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 * | 133 * |
134 * XXX This interface, or one similar, would be really nice available | 134 * XXX This interface, or one similar, would be really nice available |
135 * in general... I tried to keep the pkcs7-specific stuff (mostly | 135 * in general... I tried to keep the pkcs7-specific stuff (mostly |
136 * having to do with padding) out of here. | 136 * having to do with padding) out of here. |
137 * | 137 * |
138 * XXX Once both are working, it might be nice to combine this and the | 138 * XXX Once both are working, it might be nice to combine this and the |
139 * function above (for starting up decryption) into one routine, and just | 139 * function above (for starting up decryption) into one routine, and just |
140 * have two simple cover functions which call it. | 140 * have two simple cover functions which call it. |
141 */ | 141 */ |
142 sec_PKCS7CipherObject * | 142 sec_PKCS7CipherObject * |
143 sec_PKCS7CreateEncryptObject (PRArenaPool *poolp, PK11SymKey *key, | 143 sec_PKCS7CreateEncryptObject (PLArenaPool *poolp, PK11SymKey *key, |
144 SECOidTag algtag, SECAlgorithmID *algid) | 144 SECOidTag algtag, SECAlgorithmID *algid) |
145 { | 145 { |
146 sec_PKCS7CipherObject *result; | 146 sec_PKCS7CipherObject *result; |
147 void *ciphercx; | 147 void *ciphercx; |
148 SECStatus rv; | 148 SECStatus rv; |
149 CK_MECHANISM_TYPE cryptoMechType; | 149 CK_MECHANISM_TYPE cryptoMechType; |
150 PK11SlotInfo *slot; | 150 PK11SlotInfo *slot; |
151 SECItem *param = NULL; | 151 SECItem *param = NULL; |
152 PRBool needToEncodeAlgid = PR_FALSE; | 152 PRBool needToEncodeAlgid = PR_FALSE; |
153 | 153 |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 }; | 916 }; |
917 | 917 |
918 /* | 918 /* |
919 * If you are wondering why this routine does not reorder the attributes | 919 * If you are wondering why this routine does not reorder the attributes |
920 * first, and might be tempted to make it do so, see the comment by the | 920 * first, and might be tempted to make it do so, see the comment by the |
921 * call to ReorderAttributes in p7encode.c. (Or, see who else calls this | 921 * call to ReorderAttributes in p7encode.c. (Or, see who else calls this |
922 * and think long and hard about the implications of making it always | 922 * and think long and hard about the implications of making it always |
923 * do the reordering.) | 923 * do the reordering.) |
924 */ | 924 */ |
925 SECItem * | 925 SECItem * |
926 sec_PKCS7EncodeAttributes (PRArenaPool *poolp, SECItem *dest, void *src) | 926 sec_PKCS7EncodeAttributes (PLArenaPool *poolp, SECItem *dest, void *src) |
927 { | 927 { |
928 return SEC_ASN1EncodeItem (poolp, dest, src, | 928 return SEC_ASN1EncodeItem (poolp, dest, src, |
929 sec_pkcs7_set_of_attribute_template); | 929 sec_pkcs7_set_of_attribute_template); |
930 } | 930 } |
931 | 931 |
932 /* | 932 /* |
933 * Make sure that the order of the attributes guarantees valid DER | 933 * Make sure that the order of the attributes guarantees valid DER |
934 * (which must be in lexigraphically ascending order for a SET OF); | 934 * (which must be in lexigraphically ascending order for a SET OF); |
935 * if reordering is necessary it will be done in place (in attrs). | 935 * if reordering is necessary it will be done in place (in attrs). |
936 */ | 936 */ |
937 SECStatus | 937 SECStatus |
938 sec_PKCS7ReorderAttributes (SEC_PKCS7Attribute **attrs) | 938 sec_PKCS7ReorderAttributes (SEC_PKCS7Attribute **attrs) |
939 { | 939 { |
940 PRArenaPool *poolp; | 940 PLArenaPool *poolp; |
941 int num_attrs, i, pass, besti; | 941 int num_attrs, i, pass, besti; |
942 unsigned int j; | 942 unsigned int j; |
943 SECItem **enc_attrs; | 943 SECItem **enc_attrs; |
944 SEC_PKCS7Attribute **new_attrs; | 944 SEC_PKCS7Attribute **new_attrs; |
945 | 945 |
946 /* | 946 /* |
947 * I think we should not be called with NULL. But if we are, | 947 * I think we should not be called with NULL. But if we are, |
948 * call it a success anyway, because the order *is* okay. | 948 * call it a success anyway, because the order *is* okay. |
949 */ | 949 */ |
950 PORT_Assert (attrs != NULL); | 950 PORT_Assert (attrs != NULL); |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 theTemplate = SEC_PointerToPKCS7EncryptedDataTemplate; | 1310 theTemplate = SEC_PointerToPKCS7EncryptedDataTemplate; |
1311 break; | 1311 break; |
1312 } | 1312 } |
1313 return theTemplate; | 1313 return theTemplate; |
1314 } | 1314 } |
1315 | 1315 |
1316 /* | 1316 /* |
1317 * End of templates. Do not add stuff after this; put new code | 1317 * End of templates. Do not add stuff after this; put new code |
1318 * up above the start of the template definitions. | 1318 * up above the start of the template definitions. |
1319 */ | 1319 */ |
OLD | NEW |