summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2021-12-24 14:12:26 +0000
committerjsing <>2021-12-24 14:12:26 +0000
commitac23186da5d268f74aad9527b2bf5525a7b8132d (patch)
tree67d65f47e3c741e5941297b3bd640b64ec282fb9 /src
parentafae39318f95385b7a568b4c829e791b7a34867c (diff)
downloadopenbsd-ac23186da5d268f74aad9527b2bf5525a7b8132d.tar.gz
openbsd-ac23186da5d268f74aad9527b2bf5525a7b8132d.tar.bz2
openbsd-ac23186da5d268f74aad9527b2bf5525a7b8132d.zip
Reorder some functions.
No functional change.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/asn1/a_string.c92
1 files changed, 46 insertions, 46 deletions
diff --git a/src/lib/libcrypto/asn1/a_string.c b/src/lib/libcrypto/asn1/a_string.c
index b3a1323a54..e7e75ff9d3 100644
--- a/src/lib/libcrypto/asn1/a_string.c
+++ b/src/lib/libcrypto/asn1/a_string.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_string.c,v 1.1 2021/12/15 18:00:31 jsing Exp $ */ 1/* $OpenBSD: a_string.c,v 1.2 2021/12/24 14:12:26 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -63,6 +63,51 @@
63#include <openssl/buffer.h> 63#include <openssl/buffer.h>
64#include <openssl/err.h> 64#include <openssl/err.h>
65 65
66ASN1_STRING *
67ASN1_STRING_new(void)
68{
69 return (ASN1_STRING_type_new(V_ASN1_OCTET_STRING));
70}
71
72ASN1_STRING *
73ASN1_STRING_type_new(int type)
74{
75 ASN1_STRING *a;
76
77 if ((a = calloc(1, sizeof(ASN1_STRING))) == NULL) {
78 ASN1error(ERR_R_MALLOC_FAILURE);
79 return NULL;
80 }
81 a->type = type;
82
83 return a;
84}
85
86void
87ASN1_STRING_free(ASN1_STRING *a)
88{
89 if (a == NULL)
90 return;
91 if (a->data != NULL && !(a->flags & ASN1_STRING_FLAG_NDEF))
92 freezero(a->data, a->length);
93 free(a);
94}
95
96int
97ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
98{
99 int cmp;
100
101 if (a == NULL || b == NULL)
102 return -1;
103 if ((cmp = (a->length - b->length)) != 0)
104 return cmp;
105 if ((cmp = memcmp(a->data, b->data, a->length)) != 0)
106 return cmp;
107
108 return (a->type - b->type);
109}
110
66int 111int
67ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str) 112ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str)
68{ 113{
@@ -128,51 +173,6 @@ ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)
128 str->length = len; 173 str->length = len;
129} 174}
130 175
131ASN1_STRING *
132ASN1_STRING_new(void)
133{
134 return (ASN1_STRING_type_new(V_ASN1_OCTET_STRING));
135}
136
137ASN1_STRING *
138ASN1_STRING_type_new(int type)
139{
140 ASN1_STRING *a;
141
142 if ((a = calloc(1, sizeof(ASN1_STRING))) == NULL) {
143 ASN1error(ERR_R_MALLOC_FAILURE);
144 return NULL;
145 }
146 a->type = type;
147
148 return a;
149}
150
151void
152ASN1_STRING_free(ASN1_STRING *a)
153{
154 if (a == NULL)
155 return;
156 if (a->data != NULL && !(a->flags & ASN1_STRING_FLAG_NDEF))
157 freezero(a->data, a->length);
158 free(a);
159}
160
161int
162ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
163{
164 int cmp;
165
166 if (a == NULL || b == NULL)
167 return -1;
168 if ((cmp = (a->length - b->length)) != 0)
169 return cmp;
170 if ((cmp = memcmp(a->data, b->data, a->length)) != 0)
171 return cmp;
172
173 return (a->type - b->type);
174}
175
176void 176void
177asn1_add_error(const unsigned char *address, int offset) 177asn1_add_error(const unsigned char *address, int offset)
178{ 178{