diff options
author | tedu <> | 2014-04-18 01:59:00 +0000 |
---|---|---|
committer | tedu <> | 2014-04-18 01:59:00 +0000 |
commit | 513bec93d6747369737d3a618ef58a44410059f6 (patch) | |
tree | 88ee4831e2437f9075e786ffb662bb05fe0e3df6 /src/lib/libcrypto/x509/x509_set.c | |
parent | 1fca82b89342502ff32bda59bd067e303ff9d5ab (diff) | |
download | openbsd-513bec93d6747369737d3a618ef58a44410059f6.tar.gz openbsd-513bec93d6747369737d3a618ef58a44410059f6.tar.bz2 openbsd-513bec93d6747369737d3a618ef58a44410059f6.zip |
blunt force knf
Diffstat (limited to 'src/lib/libcrypto/x509/x509_set.c')
-rw-r--r-- | src/lib/libcrypto/x509/x509_set.c | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/src/lib/libcrypto/x509/x509_set.c b/src/lib/libcrypto/x509/x509_set.c index 4b94fc5847..dfe9eb68ff 100644 --- a/src/lib/libcrypto/x509/x509_set.c +++ b/src/lib/libcrypto/x509/x509_set.c | |||
@@ -64,87 +64,77 @@ | |||
64 | #include <openssl/x509.h> | 64 | #include <openssl/x509.h> |
65 | 65 | ||
66 | int X509_set_version(X509 *x, long version) | 66 | int X509_set_version(X509 *x, long version) |
67 | { | 67 | { |
68 | if (x == NULL) return(0); | 68 | if (x == NULL) return(0); |
69 | if (x->cert_info->version == NULL) | 69 | if (x->cert_info->version == NULL) { |
70 | { | ||
71 | if ((x->cert_info->version=M_ASN1_INTEGER_new()) == NULL) | 70 | if ((x->cert_info->version=M_ASN1_INTEGER_new()) == NULL) |
72 | return(0); | 71 | return(0); |
73 | } | ||
74 | return(ASN1_INTEGER_set(x->cert_info->version,version)); | ||
75 | } | 72 | } |
73 | return(ASN1_INTEGER_set(x->cert_info->version,version)); | ||
74 | } | ||
76 | 75 | ||
77 | int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial) | 76 | int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial) |
78 | { | 77 | { |
79 | ASN1_INTEGER *in; | 78 | ASN1_INTEGER *in; |
80 | 79 | ||
81 | if (x == NULL) return(0); | 80 | if (x == NULL) return(0); |
82 | in=x->cert_info->serialNumber; | 81 | in=x->cert_info->serialNumber; |
83 | if (in != serial) | 82 | if (in != serial) { |
84 | { | ||
85 | in=M_ASN1_INTEGER_dup(serial); | 83 | in=M_ASN1_INTEGER_dup(serial); |
86 | if (in != NULL) | 84 | if (in != NULL) { |
87 | { | ||
88 | M_ASN1_INTEGER_free(x->cert_info->serialNumber); | 85 | M_ASN1_INTEGER_free(x->cert_info->serialNumber); |
89 | x->cert_info->serialNumber=in; | 86 | x->cert_info->serialNumber=in; |
90 | } | ||
91 | } | 87 | } |
92 | return(in != NULL); | ||
93 | } | 88 | } |
89 | return(in != NULL); | ||
90 | } | ||
94 | 91 | ||
95 | int X509_set_issuer_name(X509 *x, X509_NAME *name) | 92 | int X509_set_issuer_name(X509 *x, X509_NAME *name) |
96 | { | 93 | { |
97 | if ((x == NULL) || (x->cert_info == NULL)) return(0); | 94 | if ((x == NULL) || (x->cert_info == NULL)) return(0); |
98 | return(X509_NAME_set(&x->cert_info->issuer,name)); | 95 | return(X509_NAME_set(&x->cert_info->issuer,name)); |
99 | } | 96 | } |
100 | 97 | ||
101 | int X509_set_subject_name(X509 *x, X509_NAME *name) | 98 | int X509_set_subject_name(X509 *x, X509_NAME *name) |
102 | { | 99 | { |
103 | if ((x == NULL) || (x->cert_info == NULL)) return(0); | 100 | if ((x == NULL) || (x->cert_info == NULL)) return(0); |
104 | return(X509_NAME_set(&x->cert_info->subject,name)); | 101 | return(X509_NAME_set(&x->cert_info->subject,name)); |
105 | } | 102 | } |
106 | 103 | ||
107 | int X509_set_notBefore(X509 *x, const ASN1_TIME *tm) | 104 | int X509_set_notBefore(X509 *x, const ASN1_TIME *tm) |
108 | { | 105 | { |
109 | ASN1_TIME *in; | 106 | ASN1_TIME *in; |
110 | 107 | ||
111 | if ((x == NULL) || (x->cert_info->validity == NULL)) return(0); | 108 | if ((x == NULL) || (x->cert_info->validity == NULL)) return(0); |
112 | in=x->cert_info->validity->notBefore; | 109 | in=x->cert_info->validity->notBefore; |
113 | if (in != tm) | 110 | if (in != tm) { |
114 | { | ||
115 | in=M_ASN1_TIME_dup(tm); | 111 | in=M_ASN1_TIME_dup(tm); |
116 | if (in != NULL) | 112 | if (in != NULL) { |
117 | { | ||
118 | M_ASN1_TIME_free(x->cert_info->validity->notBefore); | 113 | M_ASN1_TIME_free(x->cert_info->validity->notBefore); |
119 | x->cert_info->validity->notBefore=in; | 114 | x->cert_info->validity->notBefore=in; |
120 | } | ||
121 | } | 115 | } |
122 | return(in != NULL); | ||
123 | } | 116 | } |
117 | return(in != NULL); | ||
118 | } | ||
124 | 119 | ||
125 | int X509_set_notAfter(X509 *x, const ASN1_TIME *tm) | 120 | int X509_set_notAfter(X509 *x, const ASN1_TIME *tm) |
126 | { | 121 | { |
127 | ASN1_TIME *in; | 122 | ASN1_TIME *in; |
128 | 123 | ||
129 | if ((x == NULL) || (x->cert_info->validity == NULL)) return(0); | 124 | if ((x == NULL) || (x->cert_info->validity == NULL)) return(0); |
130 | in=x->cert_info->validity->notAfter; | 125 | in=x->cert_info->validity->notAfter; |
131 | if (in != tm) | 126 | if (in != tm) { |
132 | { | ||
133 | in=M_ASN1_TIME_dup(tm); | 127 | in=M_ASN1_TIME_dup(tm); |
134 | if (in != NULL) | 128 | if (in != NULL) { |
135 | { | ||
136 | M_ASN1_TIME_free(x->cert_info->validity->notAfter); | 129 | M_ASN1_TIME_free(x->cert_info->validity->notAfter); |
137 | x->cert_info->validity->notAfter=in; | 130 | x->cert_info->validity->notAfter=in; |
138 | } | ||
139 | } | 131 | } |
140 | return(in != NULL); | ||
141 | } | 132 | } |
133 | return(in != NULL); | ||
134 | } | ||
142 | 135 | ||
143 | int X509_set_pubkey(X509 *x, EVP_PKEY *pkey) | 136 | int X509_set_pubkey(X509 *x, EVP_PKEY *pkey) |
144 | { | 137 | { |
145 | if ((x == NULL) || (x->cert_info == NULL)) return(0); | 138 | if ((x == NULL) || (x->cert_info == NULL)) return(0); |
146 | return(X509_PUBKEY_set(&(x->cert_info->key),pkey)); | 139 | return(X509_PUBKEY_set(&(x->cert_info->key),pkey)); |
147 | } | 140 | } |
148 | |||
149 | |||
150 | |||