Gentoo Archives: gentoo-commits

From: Florian Schmaus <flow@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/guru:master commit in: dev-libs/rsaref/files/, dev-libs/rsaref/
Date: Thu, 30 Dec 2021 14:34:40
Message-Id: 1640777886.5bfe94c0f25f07c1f0ca2e371aa8cbe34d8aafb3.flow@gentoo
1 commit: 5bfe94c0f25f07c1f0ca2e371aa8cbe34d8aafb3
2 Author: Anna (cybertailor) Vyalkova <cyber+gentoo <AT> sysrq <DOT> in>
3 AuthorDate: Wed Dec 29 10:37:14 2021 +0000
4 Commit: Florian Schmaus <flow <AT> gentoo <DOT> org>
5 CommitDate: Wed Dec 29 11:38:06 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=5bfe94c0
7
8 dev-libs/rsaref: initial import
9
10 Signed-off-by: Anna (cybertailor) Vyalkova <cyber+gentoo <AT> sysrq.in>
11
12 dev-libs/rsaref/Manifest | 1 +
13 dev-libs/rsaref/files/rsaref-2.0-global.patch | 47 ++++++++++++++++
14 dev-libs/rsaref/files/rsaref-2.0-includes.patch | 72 ++++++++++++++++++++++++
15 dev-libs/rsaref/files/rsaref-2.0-libtool.patch | 44 +++++++++++++++
16 dev-libs/rsaref/files/rsaref-2.0-rsa.patch | 73 +++++++++++++++++++++++++
17 dev-libs/rsaref/metadata.xml | 30 ++++++++++
18 dev-libs/rsaref/rsaref-2.0.ebuild | 44 +++++++++++++++
19 7 files changed, 311 insertions(+)
20
21 diff --git a/dev-libs/rsaref/Manifest b/dev-libs/rsaref/Manifest
22 new file mode 100644
23 index 000000000..999cd5f16
24 --- /dev/null
25 +++ b/dev-libs/rsaref/Manifest
26 @@ -0,0 +1 @@
27 +DIST rsaref-2.0.tar.Z 144092 BLAKE2B 341dc102e01ffad31386e1a0f9a60bb20ced4cdf385faaff2fee3efbdc90721d2b1e17e045bb8ad2c1ac86d55ba28aafe2c94d9dbecf99dbef11724a6e5848e5 SHA512 70cf6fe7bbf91ab5b5e09af02e8a9b732d94f1126df720fcdf23fb6f5b4d46515573cb18241eb7354c9a40faadfcf30942044cd4a3a8507de6c783fadec03422
28
29 diff --git a/dev-libs/rsaref/files/rsaref-2.0-global.patch b/dev-libs/rsaref/files/rsaref-2.0-global.patch
30 new file mode 100644
31 index 000000000..30f35e9a3
32 --- /dev/null
33 +++ b/dev-libs/rsaref/files/rsaref-2.0-global.patch
34 @@ -0,0 +1,47 @@
35 +--- a/source/global.h
36 ++++ b/source/global.h
37 +@@ -7,23 +7,17 @@
38 + #ifndef _GLOBAL_H_
39 + #define _GLOBAL_H_ 1
40 +
41 +-/* PROTOTYPES should be set to one if and only if the compiler supports
42 +- function argument prototyping.
43 +- The following makes PROTOTYPES default to 1 if it has not already been
44 +- defined as 0 with C compiler flags.
45 +- */
46 +-#ifndef PROTOTYPES
47 +-#define PROTOTYPES 1
48 +-#endif
49 ++#include <sys/types.h>
50 ++#include <sys/cdefs.h>
51 +
52 + /* POINTER defines a generic pointer type */
53 +-typedef unsigned char *POINTER;
54 ++typedef caddr_t POINTER;
55 +
56 + /* UINT2 defines a two byte word */
57 +-typedef unsigned short int UINT2;
58 ++typedef u_int16_t UINT2;
59 +
60 + /* UINT4 defines a four byte word */
61 +-typedef unsigned long int UINT4;
62 ++typedef u_int32_t UINT4;
63 +
64 + #ifndef NULL_PTR
65 + #define NULL_PTR ((POINTER)0)
66 +@@ -33,14 +27,6 @@
67 + #define UNUSED_ARG(x) x = *(&x);
68 + #endif
69 +
70 +-/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
71 +- If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
72 +- returns an empty list.
73 +- */
74 +-#if PROTOTYPES
75 +-#define PROTO_LIST(list) list
76 +-#else
77 +-#define PROTO_LIST(list) ()
78 +-#endif
79 ++#define PROTO_LIST(x) __P(x)
80 +
81 + #endif /* end _GLOBAL_H_ */
82
83 diff --git a/dev-libs/rsaref/files/rsaref-2.0-includes.patch b/dev-libs/rsaref/files/rsaref-2.0-includes.patch
84 new file mode 100644
85 index 000000000..1f6b6f008
86 --- /dev/null
87 +++ b/dev-libs/rsaref/files/rsaref-2.0-includes.patch
88 @@ -0,0 +1,72 @@
89 +--- a/source/des.h
90 ++++ b/source/des.h
91 +@@ -4,6 +4,8 @@
92 + #ifndef _DES_H_
93 + #define _DES_H_ 1
94 +
95 ++#include <rsaref/global.h>
96 ++
97 + #ifdef __cplusplus
98 + extern "C" {
99 + #endif
100 +
101 +--- a/source/md2.h
102 ++++ b/source/md2.h
103 +@@ -22,6 +22,8 @@
104 + #ifndef _MD2_H_
105 + #define _MD2_H_ 1
106 +
107 ++#include <rsaref/global.h>
108 ++
109 + #ifdef __cplusplus
110 + extern "C" {
111 + #endif
112 +
113 +--- a/source/r_random.c
114 ++++ b/source/r_random.c
115 +@@ -8,7 +8,7 @@
116 + #include "global.h"
117 + #include "rsaref.h"
118 + #include "r_random.h"
119 +-#include "md5.h"
120 ++#include <rsaref/md5.h>
121 +
122 + #define RANDOM_BYTES_NEEDED 256
123 +
124 +--- a/source/rsa.h
125 ++++ b/source/rsa.h
126 +@@ -5,6 +5,11 @@
127 + Inc., created 1991. All rights reserved.
128 + */
129 +
130 ++#ifndef _RSA_H_
131 ++#define _RSA_H_ 1
132 ++
133 ++#include <rsaref/global.h>
134 ++
135 + int RSAPublicEncrypt PROTO_LIST
136 + ((unsigned char *, unsigned int *, unsigned char *, unsigned int,
137 + R_RSA_PUBLIC_KEY *, R_RANDOM_STRUCT *));
138 +@@ -17,3 +22,5 @@
139 + int RSAPrivateDecrypt PROTO_LIST
140 + ((unsigned char *, unsigned int *, unsigned char *, unsigned int,
141 + R_RSA_PRIVATE_KEY *));
142 ++
143 ++#endif
144 +$NetBSD: patch-af,v 1.2 1998/08/07 11:13:48 agc Exp $
145 +
146 +--- a/source/rsaref.h
147 ++++ b/source/rsaref.h
148 +@@ -8,9 +8,9 @@
149 + #ifndef _RSAREF_H_
150 + #define _RSAREF_H_ 1
151 +
152 +-#include "md2.h"
153 +-#include "md5.h"
154 +-#include "des.h"
155 ++#include <rsaref/md2.h>
156 ++#include <rsaref/md5.h>
157 ++#include <rsaref/des.h>
158 +
159 + #ifdef __cplusplus
160 + extern "C" {
161
162 diff --git a/dev-libs/rsaref/files/rsaref-2.0-libtool.patch b/dev-libs/rsaref/files/rsaref-2.0-libtool.patch
163 new file mode 100644
164 index 000000000..ab0798241
165 --- /dev/null
166 +++ b/dev-libs/rsaref/files/rsaref-2.0-libtool.patch
167 @@ -0,0 +1,44 @@
168 +--- a/install/unix/makefile
169 ++++ b/install/unix/makefile
170 +@@ -4,8 +4,7 @@
171 + O = o
172 +
173 + # commands
174 +-CC = cc
175 +-LIB = ar
176 ++CC := ${LIBTOOL} --tag=CC --mode=compile ${CC}
177 +
178 + # name of temporary library script
179 + TEMPFILE = $(TEMP)/temp.mak
180 +@@ -14,18 +13,18 @@
181 + STDINCDIR=/usr/include
182 +
183 + # The places to look for include files (in order).
184 +-INCL = -I. -I$(RSAREFDIR) -I$(STDINCDIR)
185 ++INCL = -I. -I$(RSAREFDIR)
186 +
187 + # name of main executable to build
188 + PROG = all
189 +
190 + # Normal C flags.
191 +-CFLAGS = $(INCL) -O -c -DPROTOTYPES=1
192 ++CFLAGS += $(INCL) -c -DPROTOTYPES=1
193 + MFLAGS = -I. -I$(RSAREFDIR)
194 +
195 + # The location of the common source directory.
196 + RSAREFDIR = ../source/
197 +-RSAREFLIB = rsaref.a
198 ++RSAREFLIB = librsaref.la
199 +
200 + # The location of the demo source directory.
201 + RDEMODIR = ../rdemo/
202 +@@ -41,8 +40,7 @@
203 + $(RSAREFLIB) : desc.$(O) digit.$(O) md2c.$(O) md5c.$(O) nn.$(O) prime.$(O)\
204 + rsa.$(O) r_encode.$(O) r_dh.$(O) r_enhanc.$(O) r_keygen.$(O) r_random.$(O)\
205 + r_stdlib.$(O)
206 +- $(LIB) r $@ $?
207 +- ranlib $@
208 ++ ${LIBTOOL} --tag=CC --mode=link cc -o $@ ${?:.o=.lo} -rpath ${LIBDIR} -version-info 3:0 ${LDFLAGS}
209 +
210 + rdemo.$(O) : $(RDEMODIR)rdemo.c $(RSAREFDIR)global.h $(RSAREFDIR)rsaref.h
211 + $(CC) $(CFLAGS) $(RDEMODIR)rdemo.c
212
213 diff --git a/dev-libs/rsaref/files/rsaref-2.0-rsa.patch b/dev-libs/rsaref/files/rsaref-2.0-rsa.patch
214 new file mode 100644
215 index 000000000..1f31080c8
216 --- /dev/null
217 +++ b/dev-libs/rsaref/files/rsaref-2.0-rsa.patch
218 @@ -0,0 +1,73 @@
219 +--- a/source/rsa.c
220 ++++ b/source/rsa.c
221 +@@ -11,10 +11,10 @@
222 + #include "rsa.h"
223 + #include "nn.h"
224 +
225 +-static int RSAPublicBlock PROTO_LIST
226 ++int RSAPublicBlock PROTO_LIST
227 + ((unsigned char *, unsigned int *, unsigned char *, unsigned int,
228 + R_RSA_PUBLIC_KEY *));
229 +-static int RSAPrivateBlock PROTO_LIST
230 ++int RSAPrivateBlock PROTO_LIST
231 + ((unsigned char *, unsigned int *, unsigned char *, unsigned int,
232 + R_RSA_PRIVATE_KEY *));
233 +
234 +@@ -33,6 +33,9 @@
235 + unsigned char byte, pkcsBlock[MAX_RSA_MODULUS_LEN];
236 + unsigned int i, modulusLen;
237 +
238 ++ if (inputLen+3>MAX_RSA_MODULUS_LEN) return (RE_LEN);
239 ++ if (publicKey->bits > MAX_RSA_MODULUS_BITS) return (RE_LEN);
240 ++
241 + modulusLen = (publicKey->bits + 7) / 8;
242 + if (inputLen + 11 > modulusLen)
243 + return (RE_LEN);
244 +@@ -78,6 +81,9 @@
245 + unsigned char pkcsBlock[MAX_RSA_MODULUS_LEN];
246 + unsigned int i, modulusLen, pkcsBlockLen;
247 +
248 ++ if (inputLen>MAX_RSA_MODULUS_LEN) return (RE_LEN);
249 ++ if (publicKey->bits > MAX_RSA_MODULUS_BITS) return (RE_LEN);
250 ++
251 + modulusLen = (publicKey->bits + 7) / 8;
252 + if (inputLen > modulusLen)
253 + return (RE_LEN);
254 +@@ -129,6 +135,9 @@
255 + unsigned char pkcsBlock[MAX_RSA_MODULUS_LEN];
256 + unsigned int i, modulusLen;
257 +
258 ++ if (inputLen+3>MAX_RSA_MODULUS_LEN) return (RE_LEN);
259 ++ if (privateKey->bits > MAX_RSA_MODULUS_BITS) return (RE_LEN);
260 ++
261 + modulusLen = (privateKey->bits + 7) / 8;
262 + if (inputLen + 11 > modulusLen)
263 + return (RE_LEN);
264 +@@ -168,6 +177,9 @@
265 + unsigned char pkcsBlock[MAX_RSA_MODULUS_LEN];
266 + unsigned int i, modulusLen, pkcsBlockLen;
267 +
268 ++ if (inputLen>MAX_RSA_MODULUS_LEN) return (RE_LEN);
269 ++ if (privateKey->bits > MAX_RSA_MODULUS_BITS) return (RE_LEN);
270 ++
271 + modulusLen = (privateKey->bits + 7) / 8;
272 + if (inputLen > modulusLen)
273 + return (RE_LEN);
274 +@@ -212,7 +224,7 @@
275 + Assumes inputLen < length of modulus.
276 + Requires input < modulus.
277 + */
278 +-static int RSAPublicBlock (output, outputLen, input, inputLen, publicKey)
279 ++int RSAPublicBlock (output, outputLen, input, inputLen, publicKey)
280 + unsigned char *output; /* output block */
281 + unsigned int *outputLen; /* length of output block */
282 + unsigned char *input; /* input block */
283 +@@ -252,7 +264,7 @@
284 + Assumes inputLen < length of modulus.
285 + Requires input < modulus.
286 + */
287 +-static int RSAPrivateBlock (output, outputLen, input, inputLen, privateKey)
288 ++int RSAPrivateBlock (output, outputLen, input, inputLen, privateKey)
289 + unsigned char *output; /* output block */
290 + unsigned int *outputLen; /* length of output block */
291 + unsigned char *input; /* input block */
292
293 diff --git a/dev-libs/rsaref/metadata.xml b/dev-libs/rsaref/metadata.xml
294 new file mode 100644
295 index 000000000..496077d78
296 --- /dev/null
297 +++ b/dev-libs/rsaref/metadata.xml
298 @@ -0,0 +1,30 @@
299 +<?xml version="1.0" encoding="UTF-8"?>
300 +<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
301 +<pkgmetadata>
302 +<maintainer type="person">
303 + <email>cyber+gentoo@×××××.in</email>
304 + <name>Anna</name>
305 +</maintainer>
306 +<longdescription>
307 +RSAREF is a free, portable software developer's library of popular
308 +encryption and authentication algorithms. The name "RSAREF" means
309 +"RSA reference." RSA Laboratories intends RSAREF to serve as a free,
310 +educational reference implementation of modern public- and secret-key
311 +cryptography.
312 +
313 +RSAREF 2.0 supports the following algorithms:
314 +
315 + o RSA encryption and key generation, as defined by RSA
316 + Laboratories' Public-Key Cryptography Standards (PKCS)
317 +
318 + o MD2 and MD5 message digests
319 +
320 + o DES (Data Encryption Standard) in cipher-block chaining mode
321 +
322 + o Diffie-Hellman key agreement
323 +
324 + o DESX, RSA Data Security's efficient, secure DES enhancement
325 +
326 + o Triple-DES, for added security with three DES operations
327 +</longdescription>
328 +</pkgmetadata>
329
330 diff --git a/dev-libs/rsaref/rsaref-2.0.ebuild b/dev-libs/rsaref/rsaref-2.0.ebuild
331 new file mode 100644
332 index 000000000..621e794ce
333 --- /dev/null
334 +++ b/dev-libs/rsaref/rsaref-2.0.ebuild
335 @@ -0,0 +1,44 @@
336 +# Copyright 2021 Gentoo Authors
337 +# Distributed under the terms of the GNU General Public License v2
338 +
339 +EAPI=8
340 +
341 +DESCRIPTION="Encryption/authentication library, RSA/MDX/DES"
342 +HOMEPAGE="https://wiki.gentoo.org/wiki/No_homepage"
343 +SRC_URI="https://archive.netbsd.org/pub/pkgsrc-archive/distfiles/2021Q3/${PN}.tar.Z -> ${P}.tar.Z"
344 +S="${WORKDIR}"
345 +
346 +LICENSE="RSAREF"
347 +SLOT="0/3"
348 +KEYWORDS="~amd64"
349 +
350 +BDEPEND="sys-devel/libtool"
351 +
352 +PATCHES=(
353 + "${FILESDIR}"/${P}-global.patch
354 + "${FILESDIR}"/${P}-includes.patch
355 + "${FILESDIR}"/${P}-libtool.patch
356 + "${FILESDIR}"/${P}-rsa.patch
357 +)
358 +
359 +DOCS=( doc )
360 +
361 +src_unpack() {
362 + default
363 +
364 + cd "${S}"/source || die
365 + mkdir ${PN} || die
366 + cp *.h ${PN} || die
367 +}
368 +
369 +src_compile() {
370 + # XXX: fails with slibtool
371 + emake -C install -f unix/makefile librsaref.la \
372 + LIBTOOL=libtool LIBDIR="${EPREFIX}/usr/$(get_libdir)"
373 +}
374 +
375 +src_install() {
376 + dolib.so install/.libs/lib${PN}.so*
377 + doheader -r source/${PN}
378 + einstalldocs
379 +}