summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto
diff options
context:
space:
mode:
authormiod <>2014-05-12 19:14:14 +0000
committermiod <>2014-05-12 19:14:14 +0000
commitbb1f78b0976389edbc302ea662b80029cbf5ce5a (patch)
treef99b0c7d57d24dcda17ac624bffd72e594930568 /src/lib/libcrypto
parent9d93f27329372e68682819911c1e89467694ad93 (diff)
downloadopenbsd-bb1f78b0976389edbc302ea662b80029cbf5ce5a.tar.gz
openbsd-bb1f78b0976389edbc302ea662b80029cbf5ce5a.tar.bz2
openbsd-bb1f78b0976389edbc302ea662b80029cbf5ce5a.zip
Move the `pqueue' part of libcrypto, which is a glorified sorted linked list
of 64-bit data, and only used by DTLS, to libssl where it belongs. Remove pqueue_print() which is a debugging interface and serves no useful purpose, except for the regress test, which grows its own pqueue_print() routine. Bump libcrypto major and libssl minor. WARNING: do not update your tree right now, more changes are coming, which will ride the libcrypto major bump.
Diffstat (limited to 'src/lib/libcrypto')
-rw-r--r--src/lib/libcrypto/crypto/Makefile7
-rw-r--r--src/lib/libcrypto/crypto/shlib_version4
-rw-r--r--src/lib/libcrypto/pqueue/pqueue.c237
-rw-r--r--src/lib/libcrypto/pqueue/pqueue.h93
-rw-r--r--src/lib/libcrypto/shlib_version4
5 files changed, 5 insertions, 340 deletions
diff --git a/src/lib/libcrypto/crypto/Makefile b/src/lib/libcrypto/crypto/Makefile
index 5fefdb1cf0..ce04ac9e61 100644
--- a/src/lib/libcrypto/crypto/Makefile
+++ b/src/lib/libcrypto/crypto/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.31 2014/05/04 17:12:19 miod Exp $ 1# $OpenBSD: Makefile,v 1.32 2014/05/12 19:14:14 miod Exp $
2 2
3LIB= crypto 3LIB= crypto
4 4
@@ -198,9 +198,6 @@ SRCS+= p12_utl.c p12_npas.c pk12err.c p12_p8d.c p12_p8e.c
198SRCS+= pk7_asn1.c pk7_lib.c pkcs7err.c pk7_doit.c pk7_smime.c pk7_attr.c 198SRCS+= pk7_asn1.c pk7_lib.c pkcs7err.c pk7_doit.c pk7_smime.c pk7_attr.c
199SRCS+= pk7_mime.c bio_pk7.c 199SRCS+= pk7_mime.c bio_pk7.c
200 200
201# pqueue/
202SRCS+= pqueue.c
203
204# rand/ 201# rand/
205SRCS+= randfile.c rand_lib.c rand_err.c 202SRCS+= randfile.c rand_lib.c rand_err.c
206 203
@@ -304,7 +301,6 @@ SRCS+= v3_asid.c v3_addr.c
304 ${LCRYPTO_SRC}/perlasm \ 301 ${LCRYPTO_SRC}/perlasm \
305 ${LCRYPTO_SRC}/pkcs12 \ 302 ${LCRYPTO_SRC}/pkcs12 \
306 ${LCRYPTO_SRC}/pkcs7 \ 303 ${LCRYPTO_SRC}/pkcs7 \
307 ${LCRYPTO_SRC}/pqueue \
308 ${LCRYPTO_SRC}/rand \ 304 ${LCRYPTO_SRC}/rand \
309 ${LCRYPTO_SRC}/rc2 \ 305 ${LCRYPTO_SRC}/rc2 \
310 ${LCRYPTO_SRC}/rc4 \ 306 ${LCRYPTO_SRC}/rc4 \
@@ -367,7 +363,6 @@ HDRS=\
367 crypto/pem/pem2.h \ 363 crypto/pem/pem2.h \
368 crypto/pkcs12/pkcs12.h \ 364 crypto/pkcs12/pkcs12.h \
369 crypto/pkcs7/pkcs7.h \ 365 crypto/pkcs7/pkcs7.h \
370 crypto/pqueue/pqueue.h \
371 crypto/rand/rand.h \ 366 crypto/rand/rand.h \
372 crypto/rc2/rc2.h \ 367 crypto/rc2/rc2.h \
373 crypto/rc4/rc4.h \ 368 crypto/rc4/rc4.h \
diff --git a/src/lib/libcrypto/crypto/shlib_version b/src/lib/libcrypto/crypto/shlib_version
index 72168dfd16..54ef0c4cc0 100644
--- a/src/lib/libcrypto/crypto/shlib_version
+++ b/src/lib/libcrypto/crypto/shlib_version
@@ -1,2 +1,2 @@
1major=26 1major=27
2minor=1 2minor=0
diff --git a/src/lib/libcrypto/pqueue/pqueue.c b/src/lib/libcrypto/pqueue/pqueue.c
deleted file mode 100644
index fc68ae19c3..0000000000
--- a/src/lib/libcrypto/pqueue/pqueue.c
+++ /dev/null
@@ -1,237 +0,0 @@
1/* crypto/pqueue/pqueue.c */
2/*
3 * DTLS implementation written by Nagendra Modadugu
4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
5 */
6/* ====================================================================
7 * Copyright (c) 1999-2005 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 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgment:
23 * "This product includes software developed by the OpenSSL Project
24 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25 *
26 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27 * endorse or promote products derived from this software without
28 * prior written permission. For written permission, please contact
29 * openssl-core@OpenSSL.org.
30 *
31 * 5. Products derived from this software may not be called "OpenSSL"
32 * nor may "OpenSSL" appear in their names without prior written
33 * permission of the OpenSSL Project.
34 *
35 * 6. Redistributions of any form whatsoever must retain the following
36 * acknowledgment:
37 * "This product includes software developed by the OpenSSL Project
38 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 * ====================================================================
53 *
54 * This product includes cryptographic software written by Eric Young
55 * (eay@cryptsoft.com). This product includes software written by Tim
56 * Hudson (tjh@cryptsoft.com).
57 *
58 */
59
60#include "cryptlib.h"
61#include <openssl/bn.h>
62#include "pqueue.h"
63
64typedef struct _pqueue {
65 pitem *items;
66 int count;
67} pqueue_s;
68
69pitem *
70pitem_new(unsigned char *prio64be, void *data)
71{
72 pitem *item = (pitem *)malloc(sizeof(pitem));
73
74 if (item == NULL)
75 return NULL;
76
77 memcpy(item->priority, prio64be, sizeof(item->priority));
78
79 item->data = data;
80 item->next = NULL;
81
82 return item;
83}
84
85void
86pitem_free(pitem *item)
87{
88 if (item == NULL)
89 return;
90
91 free(item);
92}
93
94pqueue_s *
95pqueue_new(void)
96{
97 pqueue_s *pq = (pqueue_s *)malloc(sizeof(pqueue_s));
98
99 if (pq == NULL)
100 return NULL;
101
102 memset(pq, 0x00, sizeof(pqueue_s));
103 return pq;
104}
105
106void
107pqueue_free(pqueue_s *pq)
108{
109 if (pq == NULL)
110 return;
111
112 free(pq);
113}
114
115pitem *
116pqueue_insert(pqueue_s *pq, pitem *item)
117{
118 pitem *curr, *next;
119
120 if (pq->items == NULL) {
121 pq->items = item;
122 return item;
123 }
124
125 for (curr = NULL, next = pq->items; next != NULL;
126 curr = next, next = next->next) {
127 /* we can compare 64-bit value in big-endian encoding
128 * with memcmp:-) */
129 int cmp = memcmp(next->priority, item->priority,
130 sizeof(item->priority));
131 if (cmp > 0) /* next > item */
132 {
133 item->next = next;
134
135 if (curr == NULL)
136 pq->items = item;
137 else
138 curr->next = item;
139
140 return item;
141 } else if (cmp == 0) /* duplicates not allowed */
142 return NULL;
143 }
144
145 item->next = NULL;
146 curr->next = item;
147
148 return item;
149}
150
151pitem *
152pqueue_peek(pqueue_s *pq)
153{
154 return pq->items;
155}
156
157pitem *
158pqueue_pop(pqueue_s *pq)
159{
160 pitem *item = pq->items;
161
162 if (pq->items != NULL)
163 pq->items = pq->items->next;
164
165 return item;
166}
167
168pitem *
169pqueue_find(pqueue_s *pq, unsigned char *prio64be)
170{
171 pitem *next;
172 pitem *found = NULL;
173
174 if (pq->items == NULL)
175 return NULL;
176
177 for (next = pq->items; next != NULL; next = next->next) {
178 if (memcmp(next->priority, prio64be, 8) == 0) {
179 found = next;
180 break;
181 }
182 }
183
184 if (!found)
185 return NULL;
186
187 return found;
188}
189
190void
191pqueue_print(pqueue_s *pq)
192{
193 pitem *item = pq->items;
194
195 while (item != NULL) {
196 printf("item\t%02x%02x%02x%02x%02x%02x%02x%02x\n",
197 item->priority[0], item->priority[1],
198 item->priority[2], item->priority[3],
199 item->priority[4], item->priority[5],
200 item->priority[6], item->priority[7]);
201 item = item->next;
202 }
203}
204
205pitem *
206pqueue_iterator(pqueue_s *pq)
207{
208 return pqueue_peek(pq);
209}
210
211pitem *
212pqueue_next(pitem **item)
213{
214 pitem *ret;
215
216 if (item == NULL || *item == NULL)
217 return NULL;
218
219 /* *item != NULL */
220 ret = *item;
221 *item = (*item)->next;
222
223 return ret;
224}
225
226int
227pqueue_size(pqueue_s *pq)
228{
229 pitem *item = pq->items;
230 int count = 0;
231
232 while (item != NULL) {
233 count++;
234 item = item->next;
235 }
236 return count;
237}
diff --git a/src/lib/libcrypto/pqueue/pqueue.h b/src/lib/libcrypto/pqueue/pqueue.h
deleted file mode 100644
index 729e9abaf2..0000000000
--- a/src/lib/libcrypto/pqueue/pqueue.h
+++ /dev/null
@@ -1,93 +0,0 @@
1/* crypto/pqueue/pqueue.h */
2/*
3 * DTLS implementation written by Nagendra Modadugu
4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
5 */
6/* ====================================================================
7 * Copyright (c) 1999-2005 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 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgment:
23 * "This product includes software developed by the OpenSSL Project
24 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25 *
26 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27 * endorse or promote products derived from this software without
28 * prior written permission. For written permission, please contact
29 * openssl-core@OpenSSL.org.
30 *
31 * 5. Products derived from this software may not be called "OpenSSL"
32 * nor may "OpenSSL" appear in their names without prior written
33 * permission of the OpenSSL Project.
34 *
35 * 6. Redistributions of any form whatsoever must retain the following
36 * acknowledgment:
37 * "This product includes software developed by the OpenSSL Project
38 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 * ====================================================================
53 *
54 * This product includes cryptographic software written by Eric Young
55 * (eay@cryptsoft.com). This product includes software written by Tim
56 * Hudson (tjh@cryptsoft.com).
57 *
58 */
59
60#ifndef HEADER_PQUEUE_H
61#define HEADER_PQUEUE_H
62
63#include <stdio.h>
64#include <stdlib.h>
65#include <string.h>
66
67typedef struct _pqueue *pqueue;
68
69typedef struct _pitem {
70 unsigned char priority[8]; /* 64-bit value in big-endian encoding */
71 void *data;
72 struct _pitem *next;
73} pitem;
74
75typedef struct _pitem *piterator;
76
77pitem *pitem_new(unsigned char *prio64be, void *data);
78void pitem_free(pitem *item);
79
80pqueue pqueue_new(void);
81void pqueue_free(pqueue pq);
82
83pitem *pqueue_insert(pqueue pq, pitem *item);
84pitem *pqueue_peek(pqueue pq);
85pitem *pqueue_pop(pqueue pq);
86pitem *pqueue_find(pqueue pq, unsigned char *prio64be);
87pitem *pqueue_iterator(pqueue pq);
88pitem *pqueue_next(piterator *iter);
89
90void pqueue_print(pqueue pq);
91int pqueue_size(pqueue pq);
92
93#endif /* ! HEADER_PQUEUE_H */
diff --git a/src/lib/libcrypto/shlib_version b/src/lib/libcrypto/shlib_version
index 72168dfd16..54ef0c4cc0 100644
--- a/src/lib/libcrypto/shlib_version
+++ b/src/lib/libcrypto/shlib_version
@@ -1,2 +1,2 @@
1major=26 1major=27
2minor=1 2minor=0