summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/x509/x509_set.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/x509/x509_set.c')
-rw-r--r--src/lib/libcrypto/x509/x509_set.c90
1 files changed, 52 insertions, 38 deletions
diff --git a/src/lib/libcrypto/x509/x509_set.c b/src/lib/libcrypto/x509/x509_set.c
index dfe9eb68ff..6fd2f85761 100644
--- a/src/lib/libcrypto/x509/x509_set.c
+++ b/src/lib/libcrypto/x509/x509_set.c
@@ -5,21 +5,21 @@
5 * This package is an SSL implementation written 5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com). 6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL. 7 * The implementation was written so as to conform with Netscapes SSL.
8 * 8 *
9 * This library is free for commercial and non-commercial use as long as 9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions 10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA, 11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation 12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms 13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com). 14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 * 15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in 16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed. 17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution 18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used. 19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or 20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package. 21 * in documentation (online or textual) provided with the package.
22 * 22 *
23 * Redistribution and use in source and binary forms, with or without 23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions 24 * modification, are permitted provided that the following conditions
25 * are met: 25 * are met:
@@ -34,10 +34,10 @@
34 * Eric Young (eay@cryptsoft.com)" 34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library 35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-). 36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from 37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement: 38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 * 40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE. 51 * SUCH DAMAGE.
52 * 52 *
53 * The licence and distribution terms for any publically available version or 53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be 54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
@@ -63,78 +63,92 @@
63#include <openssl/evp.h> 63#include <openssl/evp.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65 65
66int X509_set_version(X509 *x, long version) 66int
67X509_set_version(X509 *x, long version)
67{ 68{
68 if (x == NULL) return(0); 69 if (x == NULL)
70 return (0);
69 if (x->cert_info->version == NULL) { 71 if (x->cert_info->version == NULL) {
70 if ((x->cert_info->version=M_ASN1_INTEGER_new()) == NULL) 72 if ((x->cert_info->version = M_ASN1_INTEGER_new()) == NULL)
71 return(0); 73 return (0);
72 } 74 }
73 return(ASN1_INTEGER_set(x->cert_info->version,version)); 75 return (ASN1_INTEGER_set(x->cert_info->version, version));
74} 76}
75 77
76int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial) 78int
79X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial)
77{ 80{
78 ASN1_INTEGER *in; 81 ASN1_INTEGER *in;
79 82
80 if (x == NULL) return(0); 83 if (x == NULL)
81 in=x->cert_info->serialNumber; 84 return (0);
85 in = x->cert_info->serialNumber;
82 if (in != serial) { 86 if (in != serial) {
83 in=M_ASN1_INTEGER_dup(serial); 87 in = M_ASN1_INTEGER_dup(serial);
84 if (in != NULL) { 88 if (in != NULL) {
85 M_ASN1_INTEGER_free(x->cert_info->serialNumber); 89 M_ASN1_INTEGER_free(x->cert_info->serialNumber);
86 x->cert_info->serialNumber=in; 90 x->cert_info->serialNumber = in;
87 } 91 }
88 } 92 }
89 return(in != NULL); 93 return (in != NULL);
90} 94}
91 95
92int X509_set_issuer_name(X509 *x, X509_NAME *name) 96int
97X509_set_issuer_name(X509 *x, X509_NAME *name)
93{ 98{
94 if ((x == NULL) || (x->cert_info == NULL)) return(0); 99 if ((x == NULL) || (x->cert_info == NULL))
95 return(X509_NAME_set(&x->cert_info->issuer,name)); 100 return (0);
101 return (X509_NAME_set(&x->cert_info->issuer, name));
96} 102}
97 103
98int X509_set_subject_name(X509 *x, X509_NAME *name) 104int
105X509_set_subject_name(X509 *x, X509_NAME *name)
99{ 106{
100 if ((x == NULL) || (x->cert_info == NULL)) return(0); 107 if ((x == NULL) || (x->cert_info == NULL))
101 return(X509_NAME_set(&x->cert_info->subject,name)); 108 return (0);
109 return (X509_NAME_set(&x->cert_info->subject, name));
102} 110}
103 111
104int X509_set_notBefore(X509 *x, const ASN1_TIME *tm) 112int
113X509_set_notBefore(X509 *x, const ASN1_TIME *tm)
105{ 114{
106 ASN1_TIME *in; 115 ASN1_TIME *in;
107 116
108 if ((x == NULL) || (x->cert_info->validity == NULL)) return(0); 117 if ((x == NULL) || (x->cert_info->validity == NULL))
109 in=x->cert_info->validity->notBefore; 118 return (0);
119 in = x->cert_info->validity->notBefore;
110 if (in != tm) { 120 if (in != tm) {
111 in=M_ASN1_TIME_dup(tm); 121 in = M_ASN1_TIME_dup(tm);
112 if (in != NULL) { 122 if (in != NULL) {
113 M_ASN1_TIME_free(x->cert_info->validity->notBefore); 123 M_ASN1_TIME_free(x->cert_info->validity->notBefore);
114 x->cert_info->validity->notBefore=in; 124 x->cert_info->validity->notBefore = in;
115 } 125 }
116 } 126 }
117 return(in != NULL); 127 return (in != NULL);
118} 128}
119 129
120int X509_set_notAfter(X509 *x, const ASN1_TIME *tm) 130int
131X509_set_notAfter(X509 *x, const ASN1_TIME *tm)
121{ 132{
122 ASN1_TIME *in; 133 ASN1_TIME *in;
123 134
124 if ((x == NULL) || (x->cert_info->validity == NULL)) return(0); 135 if ((x == NULL) || (x->cert_info->validity == NULL))
125 in=x->cert_info->validity->notAfter; 136 return (0);
137 in = x->cert_info->validity->notAfter;
126 if (in != tm) { 138 if (in != tm) {
127 in=M_ASN1_TIME_dup(tm); 139 in = M_ASN1_TIME_dup(tm);
128 if (in != NULL) { 140 if (in != NULL) {
129 M_ASN1_TIME_free(x->cert_info->validity->notAfter); 141 M_ASN1_TIME_free(x->cert_info->validity->notAfter);
130 x->cert_info->validity->notAfter=in; 142 x->cert_info->validity->notAfter = in;
131 } 143 }
132 } 144 }
133 return(in != NULL); 145 return (in != NULL);
134} 146}
135 147
136int X509_set_pubkey(X509 *x, EVP_PKEY *pkey) 148int
149X509_set_pubkey(X509 *x, EVP_PKEY *pkey)
137{ 150{
138 if ((x == NULL) || (x->cert_info == NULL)) return(0); 151 if ((x == NULL) || (x->cert_info == NULL))
139 return(X509_PUBKEY_set(&(x->cert_info->key),pkey)); 152 return (0);
153 return (X509_PUBKEY_set(&(x->cert_info->key), pkey));
140} 154}