Skip to content

Commit 17ff217

Browse files
committed
NetBSD src for "user", checkout.sh rev a687b901ceba0f25422bc0f358cc763e72e6c70e
1 parent 02ab553 commit 17ff217

27 files changed

+12288
-89
lines changed
Lines changed: 63 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,78 @@
11
#ifndef __ARM_ARCH_H__
2-
#define __ARM_ARCH_H__
2+
# define __ARM_ARCH_H__
33

4-
#if !defined(__ARM_ARCH__)
5-
# if defined(__CC_ARM)
6-
# define __ARM_ARCH__ __TARGET_ARCH_ARM
7-
# if defined(__BIG_ENDIAN)
8-
# define __ARMEB__
9-
# else
10-
# define __ARMEL__
11-
# endif
12-
# elif defined(__GNUC__)
4+
# if !defined(__ARM_ARCH__)
5+
# if defined(__CC_ARM)
6+
# define __ARM_ARCH__ __TARGET_ARCH_ARM
7+
# if defined(__BIG_ENDIAN)
8+
# define __ARMEB__
9+
# else
10+
# define __ARMEL__
11+
# endif
12+
# elif defined(__GNUC__)
13+
# if defined(__aarch64__)
14+
# define __ARM_ARCH__ 8
15+
# if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__
16+
# define __ARMEB__
17+
# else
18+
# define __ARMEL__
19+
# endif
1320
/*
1421
* Why doesn't gcc define __ARM_ARCH__? Instead it defines
1522
* bunch of below macros. See all_architectires[] table in
1623
* gcc/config/arm/arm.c. On a side note it defines
1724
* __ARMEL__/__ARMEB__ for little-/big-endian.
1825
*/
19-
# if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
20-
defined(__ARM_ARCH_7R__)|| defined(__ARM_ARCH_7M__) || \
21-
defined(__ARM_ARCH_7EM__)
22-
# define __ARM_ARCH__ 7
23-
# elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
24-
defined(__ARM_ARCH_6K__)|| defined(__ARM_ARCH_6M__) || \
25-
defined(__ARM_ARCH_6Z__)|| defined(__ARM_ARCH_6ZK__) || \
26-
defined(__ARM_ARCH_6T2__)
27-
# define __ARM_ARCH__ 6
28-
# elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \
29-
defined(__ARM_ARCH_5E__)|| defined(__ARM_ARCH_5TE__) || \
30-
defined(__ARM_ARCH_5TEJ__)
31-
# define __ARM_ARCH__ 5
32-
# elif defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
33-
# define __ARM_ARCH__ 4
34-
# else
35-
# error "unsupported ARM architecture"
26+
# elif defined(__ARM_ARCH)
27+
# define __ARM_ARCH__ __ARM_ARCH
28+
# elif defined(__ARM_ARCH_8A__)
29+
# define __ARM_ARCH__ 8
30+
# elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
31+
defined(__ARM_ARCH_7R__)|| defined(__ARM_ARCH_7M__) || \
32+
defined(__ARM_ARCH_7EM__)
33+
# define __ARM_ARCH__ 7
34+
# elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
35+
defined(__ARM_ARCH_6K__)|| defined(__ARM_ARCH_6M__) || \
36+
defined(__ARM_ARCH_6Z__)|| defined(__ARM_ARCH_6ZK__) || \
37+
defined(__ARM_ARCH_6T2__)
38+
# define __ARM_ARCH__ 6
39+
# elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \
40+
defined(__ARM_ARCH_5E__)|| defined(__ARM_ARCH_5TE__) || \
41+
defined(__ARM_ARCH_5TEJ__)
42+
# define __ARM_ARCH__ 5
43+
# elif defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
44+
# define __ARM_ARCH__ 4
45+
# else
46+
# error "unsupported ARM architecture"
47+
# endif
3648
# endif
3749
# endif
38-
#endif
3950

40-
#ifdef OPENSSL_FIPSCANISTER
41-
#include <openssl/fipssyms.h>
42-
#endif
51+
# ifdef OPENSSL_FIPSCANISTER
52+
# include <openssl/fipssyms.h>
53+
# endif
54+
55+
# if !defined(__ARM_MAX_ARCH__)
56+
# define __ARM_MAX_ARCH__ __ARM_ARCH__
57+
# endif
4358

44-
#if !__ASSEMBLER__
59+
# if __ARM_MAX_ARCH__<__ARM_ARCH__
60+
# error "__ARM_MAX_ARCH__ can't be less than __ARM_ARCH__"
61+
# elif __ARM_MAX_ARCH__!=__ARM_ARCH__
62+
# if __ARM_ARCH__<7 && __ARM_MAX_ARCH__>=7 && defined(__ARMEB__)
63+
# error "can't build universal big-endian binary"
64+
# endif
65+
# endif
66+
67+
# if !__ASSEMBLER__
4568
extern unsigned int OPENSSL_armcap_P;
46-
47-
#define ARMV7_NEON (1<<0)
48-
#define ARMV7_TICK (1<<1)
49-
#endif
69+
# endif
70+
71+
# define ARMV7_NEON (1<<0)
72+
# define ARMV7_TICK (1<<1)
73+
# define ARMV8_AES (1<<2)
74+
# define ARMV8_SHA1 (1<<3)
75+
# define ARMV8_SHA256 (1<<4)
76+
# define ARMV8_PMULL (1<<5)
5077

5178
#endif

crypto/external/bsd/openssl/dist/crypto/armcap.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ static void ill_handler (int sig) { siglongjmp(ill_jmp,sig); }
1818
* Following subroutines could have been inlined, but it's not all
1919
* ARM compilers support inline assembler...
2020
*/
21+
#if __ARM_MAX_ARCH__>=7
2122
void _armv7_neon_probe(void);
2223
unsigned int _armv7_tick(void);
24+
#endif
2325

2426
unsigned int OPENSSL_rdtsc(void)
2527
{
28+
#if __ARM_MAX_ARCH__>=7
2629
if (OPENSSL_armcap_P & ARMV7_TICK)
2730
return _armv7_tick();
2831
else
32+
#endif
2933
return 0;
3034
}
3135

@@ -64,6 +68,7 @@ void OPENSSL_cpuid_setup(void)
6468
sigprocmask(SIG_SETMASK,&ill_act.sa_mask,&oset);
6569
sigaction(SIGILL,&ill_act,&ill_oact);
6670

71+
#if __ARM_MAX_ARCH__>=7
6772
if (sigsetjmp(ill_jmp,1) == 0)
6873
{
6974
_armv7_neon_probe();
@@ -74,6 +79,7 @@ void OPENSSL_cpuid_setup(void)
7479
_armv7_tick();
7580
OPENSSL_armcap_P |= ARMV7_TICK;
7681
}
82+
#endif
7783

7884
sigaction (SIGILL,&ill_oact,NULL);
7985
sigprocmask(SIG_SETMASK,&oset,NULL);

crypto/external/bsd/openssl/dist/crypto/asn1/a_type.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b)
124124
case V_ASN1_OBJECT:
125125
result = OBJ_cmp(a->value.object, b->value.object);
126126
break;
127+
case V_ASN1_BOOLEAN:
128+
result = a->value.boolean - b->value.boolean;
129+
break;
127130
case V_ASN1_NULL:
128131
result = 0; /* They do not have content. */
129132
break;

crypto/external/bsd/openssl/dist/crypto/asn1/tasn_dec.c

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,22 @@ unsigned long ASN1_tag2bit(int tag)
127127

128128
ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **pval,
129129
const unsigned char **in, long len, const ASN1_ITEM *it)
130-
{
130+
{
131131
ASN1_TLC c;
132132
ASN1_VALUE *ptmpval = NULL;
133-
if (!pval)
134-
pval = &ptmpval;
135133
asn1_tlc_clear_nc(&c);
136-
if (ASN1_item_ex_d2i(pval, in, len, it, -1, 0, 0, &c) > 0)
137-
return *pval;
138-
return NULL;
134+
if (pval && *pval && it->itype == ASN1_ITYPE_PRIMITIVE)
135+
ptmpval = *pval;
136+
if (ASN1_item_ex_d2i(&ptmpval, in, len, it, -1, 0, 0, &c) > 0) {
137+
if (pval && it->itype != ASN1_ITYPE_PRIMITIVE) {
138+
if (*pval)
139+
ASN1_item_free(*pval, it);
140+
*pval = ptmpval;
141+
}
142+
return ptmpval;
139143
}
144+
return NULL;
145+
}
140146

141147
int ASN1_template_d2i(ASN1_VALUE **pval,
142148
const unsigned char **in, long len, const ASN1_TEMPLATE *tt)
@@ -310,10 +316,16 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
310316
case ASN1_ITYPE_CHOICE:
311317
if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))
312318
goto auxerr;
313-
314-
/* Allocate structure */
315-
if (!*pval && !ASN1_item_ex_new(pval, it))
316-
{
319+
if (*pval) {
320+
/* Free up and zero CHOICE value if initialised */
321+
i = asn1_get_choice_selector(pval, it);
322+
if ((i >= 0) && (i < it->tcount)) {
323+
tt = it->templates + i;
324+
pchptr = asn1_get_field_ptr(pval, tt);
325+
ASN1_template_free(pchptr, tt);
326+
asn1_set_choice_selector(pval, -1, it);
327+
}
328+
} else if (!ASN1_item_ex_new(pval, it)) {
317329
ASN1err(ASN1_F_ASN1_ITEM_EX_D2I,
318330
ERR_R_NESTED_ASN1_ERROR);
319331
goto err;
@@ -407,6 +419,17 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
407419
if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))
408420
goto auxerr;
409421

422+
/* Free up and zero any ADB found */
423+
for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
424+
if (tt->flags & ASN1_TFLG_ADB_MASK) {
425+
const ASN1_TEMPLATE *seqtt;
426+
ASN1_VALUE **pseqval;
427+
seqtt = asn1_do_adb(pval, tt, 1);
428+
pseqval = asn1_get_field_ptr(pval, seqtt);
429+
ASN1_template_free(pseqval, seqtt);
430+
}
431+
}
432+
410433
/* Get each field entry */
411434
for (i = 0, tt = it->templates; i < it->tcount; i++, tt++)
412435
{

crypto/external/bsd/openssl/dist/crypto/pkcs7/pk7_doit.c

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,25 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
272272
PKCS7_RECIP_INFO *ri=NULL;
273273
ASN1_OCTET_STRING *os=NULL;
274274

275+
if (p7 == NULL) {
276+
PKCS7err(PKCS7_F_PKCS7_DATAINIT, PKCS7_R_INVALID_NULL_POINTER);
277+
return NULL;
278+
}
279+
/*
280+
* The content field in the PKCS7 ContentInfo is optional, but that really
281+
* only applies to inner content (precisely, detached signatures).
282+
*
283+
* When reading content, missing outer content is therefore treated as an
284+
* error.
285+
*
286+
* When creating content, PKCS7_content_new() must be called before
287+
* calling this method, so a NULL p7->d is always an error.
288+
*/
289+
if (p7->d.ptr == NULL) {
290+
PKCS7err(PKCS7_F_PKCS7_DATAINIT, PKCS7_R_NO_CONTENT);
291+
return NULL;
292+
}
293+
275294
i=OBJ_obj2nid(p7->type);
276295
p7->state=PKCS7_S_HEADER;
277296

@@ -430,8 +449,18 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
430449
STACK_OF(X509_ALGOR) *md_sk=NULL;
431450
STACK_OF(PKCS7_RECIP_INFO) *rsk=NULL;
432451
PKCS7_RECIP_INFO *ri=NULL;
433-
unsigned char *ek = NULL, *tkey = NULL;
434-
int eklen = 0, tkeylen = 0;
452+
unsigned char *ek = NULL, *tkey = NULL;
453+
int eklen = 0, tkeylen = 0;
454+
455+
if (p7 == NULL) {
456+
PKCS7err(PKCS7_F_PKCS7_DATADECODE, PKCS7_R_INVALID_NULL_POINTER);
457+
return NULL;
458+
}
459+
460+
if (p7->d.ptr == NULL) {
461+
PKCS7err(PKCS7_F_PKCS7_DATADECODE, PKCS7_R_NO_CONTENT);
462+
return NULL;
463+
}
435464

436465
i=OBJ_obj2nid(p7->type);
437466
p7->state=PKCS7_S_HEADER;
@@ -796,6 +825,7 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
796825
/* If detached data then the content is excluded */
797826
if(PKCS7_type_is_data(p7->d.sign->contents) && p7->detached) {
798827
M_ASN1_OCTET_STRING_free(os);
828+
os = NULL;
799829
p7->d.sign->contents->d.data = NULL;
800830
}
801831
break;
@@ -806,6 +836,7 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
806836
if(PKCS7_type_is_data(p7->d.digest->contents) && p7->detached)
807837
{
808838
M_ASN1_OCTET_STRING_free(os);
839+
os = NULL;
809840
p7->d.digest->contents->d.data = NULL;
810841
}
811842
break;
@@ -878,24 +909,30 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
878909
M_ASN1_OCTET_STRING_set(p7->d.digest->digest, md_data, md_len);
879910
}
880911

881-
if (!PKCS7_is_detached(p7) && !(os->flags & ASN1_STRING_FLAG_NDEF))
882-
{
883-
char *cont;
884-
long contlen;
885-
btmp=BIO_find_type(bio,BIO_TYPE_MEM);
886-
if (btmp == NULL)
887-
{
888-
PKCS7err(PKCS7_F_PKCS7_DATAFINAL,PKCS7_R_UNABLE_TO_FIND_MEM_BIO);
912+
if (!PKCS7_is_detached(p7)) {
913+
/* NOTE(emilia): I think we only reach os == NULL here because detached
914+
* digested data support is broken.
915+
*/
916+
if (os == NULL)
889917
goto err;
918+
if (!(os->flags & ASN1_STRING_FLAG_NDEF)) {
919+
char *cont;
920+
long contlen;
921+
btmp = BIO_find_type(bio, BIO_TYPE_MEM);
922+
if (btmp == NULL) {
923+
PKCS7err(PKCS7_F_PKCS7_DATAFINAL, PKCS7_R_UNABLE_TO_FIND_MEM_BIO);
924+
goto err;
890925
}
891-
contlen = BIO_get_mem_data(btmp, &cont);
892-
/* Mark the BIO read only then we can use its copy of the data
893-
* instead of making an extra copy.
894-
*/
895-
BIO_set_flags(btmp, BIO_FLAGS_MEM_RDONLY);
896-
BIO_set_mem_eof_return(btmp, 0);
897-
ASN1_STRING_set0(os, (unsigned char *)cont, contlen);
926+
contlen = BIO_get_mem_data(btmp, &cont);
927+
/*
928+
* Mark the BIO read only then we can use its copy of the data
929+
* instead of making an extra copy.
930+
*/
931+
BIO_set_flags(btmp, BIO_FLAGS_MEM_RDONLY);
932+
BIO_set_mem_eof_return(btmp, 0);
933+
ASN1_STRING_set0(os, (unsigned char *)cont, contlen);
898934
}
935+
}
899936
ret=1;
900937
err:
901938
EVP_MD_CTX_cleanup(&ctx_tmp);
@@ -971,6 +1008,16 @@ int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, BIO *bio,
9711008
STACK_OF(X509) *cert;
9721009
X509 *x509;
9731010

1011+
if (p7 == NULL) {
1012+
PKCS7err(PKCS7_F_PKCS7_DATAVERIFY, PKCS7_R_INVALID_NULL_POINTER);
1013+
return 0;
1014+
}
1015+
1016+
if (p7->d.ptr == NULL) {
1017+
PKCS7err(PKCS7_F_PKCS7_DATAVERIFY, PKCS7_R_NO_CONTENT);
1018+
return 0;
1019+
}
1020+
9741021
if (PKCS7_type_is_signed(p7))
9751022
{
9761023
cert=p7->d.sign->cert;

crypto/external/bsd/openssl/dist/crypto/pkcs7/pk7_lib.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg)
7171

7272
switch (cmd)
7373
{
74+
/* NOTE(emilia): does not support detached digested data. */
7475
case PKCS7_OP_SET_DETACHED_SIGNATURE:
7576
if (nid == NID_pkcs7_signed)
7677
{
@@ -459,6 +460,8 @@ int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md)
459460

460461
STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7)
461462
{
463+
if (p7 == NULL || p7->d.ptr == NULL)
464+
return NULL;
462465
if (PKCS7_type_is_signed(p7))
463466
{
464467
return(p7->d.sign->signer_info);

crypto/external/bsd/openssl/dist/doc/crypto/d2i_X509.pod

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@ B<*px> is valid is broken and some parts of the reused structure may
199199
persist if they are not present in the new one. As a result the use
200200
of this "reuse" behaviour is strongly discouraged.
201201

202+
Current versions of OpenSSL will not modify B<*px> if an error occurs.
203+
If parsing succeeds then B<*px> is freed (if it is not NULL) and then
204+
set to the value of the newly decoded structure. As a result B<*px>
205+
B<must not> be allocated on the stack or an attempt will be made to
206+
free an invalid pointer.
207+
202208
i2d_X509() will not return an error in many versions of OpenSSL,
203209
if mandatory fields are not initialized due to a programming error
204210
then the encoded structure may contain invalid data or omit the
@@ -210,7 +216,9 @@ always succeed.
210216

211217
d2i_X509(), d2i_X509_bio() and d2i_X509_fp() return a valid B<X509> structure
212218
or B<NULL> if an error occurs. The error code that can be obtained by
213-
L<ERR_get_error(3)|ERR_get_error(3)>.
219+
L<ERR_get_error(3)|ERR_get_error(3)>. If the "reuse" capability has been used
220+
with a valid X509 structure being passed in via B<px> then the object is not
221+
modified in the event of error.
214222

215223
i2d_X509() returns the number of bytes successfully encoded or a negative
216224
value if an error occurs. The error code can be obtained by

0 commit comments

Comments
 (0)