p12_init.c (302408) | p12_init.c (340704) |
---|---|
1/* p12_init.c */ 2/* 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project 4 * 1999. 5 */ 6/* ==================================================================== | 1/* p12_init.c */ 2/* 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project 4 * 1999. 5 */ 6/* ==================================================================== |
7 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | 7 * Copyright (c) 1999-2018 The OpenSSL Project. All rights reserved. |
8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * --- 49 unchanged lines hidden (view full) --- 65 66PKCS12 *PKCS12_init(int mode) 67{ 68 PKCS12 *pkcs12; 69 if (!(pkcs12 = PKCS12_new())) { 70 PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE); 71 return NULL; 72 } | 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * --- 49 unchanged lines hidden (view full) --- 65 66PKCS12 *PKCS12_init(int mode) 67{ 68 PKCS12 *pkcs12; 69 if (!(pkcs12 = PKCS12_new())) { 70 PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE); 71 return NULL; 72 } |
73 ASN1_INTEGER_set(pkcs12->version, 3); | 73 if (!ASN1_INTEGER_set(pkcs12->version, 3)) 74 goto err; |
74 pkcs12->authsafes->type = OBJ_nid2obj(mode); 75 switch (mode) { 76 case NID_pkcs7_data: 77 if (!(pkcs12->authsafes->d.data = M_ASN1_OCTET_STRING_new())) { 78 PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE); 79 goto err; 80 } 81 break; 82 default: 83 PKCS12err(PKCS12_F_PKCS12_INIT, PKCS12_R_UNSUPPORTED_PKCS12_MODE); 84 goto err; 85 } 86 87 return pkcs12; 88 err: 89 if (pkcs12 != NULL) 90 PKCS12_free(pkcs12); 91 return NULL; 92} | 75 pkcs12->authsafes->type = OBJ_nid2obj(mode); 76 switch (mode) { 77 case NID_pkcs7_data: 78 if (!(pkcs12->authsafes->d.data = M_ASN1_OCTET_STRING_new())) { 79 PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE); 80 goto err; 81 } 82 break; 83 default: 84 PKCS12err(PKCS12_F_PKCS12_INIT, PKCS12_R_UNSUPPORTED_PKCS12_MODE); 85 goto err; 86 } 87 88 return pkcs12; 89 err: 90 if (pkcs12 != NULL) 91 PKCS12_free(pkcs12); 92 return NULL; 93} |