sync with OpenBSD -current
This commit is contained in:
parent
037d9f0129
commit
c0a325cf3c
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: more.c,v 1.41 2019/06/28 13:32:52 deraadt Exp $ */
|
||||
/* $OpenBSD: more.c,v 1.42 2024/10/16 18:47:47 miod Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Todd C. Miller <millert@openbsd.org>
|
||||
@ -63,10 +63,10 @@
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/exec.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <a.out.h>
|
||||
#include <ctype.h>
|
||||
#include <curses.h>
|
||||
#include <errno.h>
|
||||
|
114
include/a.out.h
114
include/a.out.h
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: a.out.h,v 1.3 2003/06/02 19:34:12 millert Exp $ */
|
||||
/* $OpenBSD: a.out.h,v 1.4 2024/10/16 18:47:48 miod Exp $ */
|
||||
/* $NetBSD: a.out.h,v 1.15 1994/10/26 00:55:42 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
@ -36,6 +36,118 @@
|
||||
#ifndef _AOUT_H_
|
||||
#define _AOUT_H_
|
||||
|
||||
/*
|
||||
* Legacy a.out structures and defines.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Header prepended to each a.out file.
|
||||
* only manipulate the a_midmag field via the
|
||||
* N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros below.
|
||||
*/
|
||||
struct exec {
|
||||
u_int32_t a_midmag; /* htonl(flags<<26|mid<<16|magic) */
|
||||
u_int32_t a_text; /* text segment size */
|
||||
u_int32_t a_data; /* initialized data size */
|
||||
u_int32_t a_bss; /* uninitialized data size */
|
||||
u_int32_t a_syms; /* symbol table size */
|
||||
u_int32_t a_entry; /* entry point */
|
||||
u_int32_t a_trsize; /* text relocation size */
|
||||
u_int32_t a_drsize; /* data relocation size */
|
||||
};
|
||||
|
||||
/* a_magic */
|
||||
#define OMAGIC 0407 /* old impure format */
|
||||
#define NMAGIC 0410 /* read-only text */
|
||||
#define ZMAGIC 0413 /* demand load format */
|
||||
#define QMAGIC 0314 /* "compact" demand load format; deprecated */
|
||||
|
||||
/*
|
||||
* a_flags
|
||||
*/
|
||||
#define EX_DYNAMIC 0x20
|
||||
#define EX_PIC 0x10
|
||||
#define EX_DPMASK 0x30
|
||||
/*
|
||||
* Interpretation of the (a_flags & EX_DPMASK) bits:
|
||||
*
|
||||
* 00 traditional executable or object file
|
||||
* 01 object file contains PIC code (set by `as -k')
|
||||
* 10 dynamic executable
|
||||
* 11 position independent executable image
|
||||
* (eg. a shared library)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* The a.out structure's a_midmag field is a network-byteorder encoding
|
||||
* of this int
|
||||
* FFFFFFmmmmmmmmmmMMMMMMMMMMMMMMMM
|
||||
* Where `F' is 6 bits of flag like EX_DYNAMIC,
|
||||
* `m' is 10 bits of machine-id like MID_I386, and
|
||||
* `M' is 16 bits worth of magic number, ie. ZMAGIC.
|
||||
* The macros below will set/get the needed fields.
|
||||
*/
|
||||
#define N_GETMAGIC(ex) \
|
||||
( (((ex).a_midmag)&0xffff0000) ? (ntohl(((ex).a_midmag))&0xffff) : ((ex).a_midmag))
|
||||
#define N_GETMAGIC2(ex) \
|
||||
( (((ex).a_midmag)&0xffff0000) ? (ntohl(((ex).a_midmag))&0xffff) : \
|
||||
(((ex).a_midmag) | 0x10000) )
|
||||
#define N_GETMID(ex) \
|
||||
( (((ex).a_midmag)&0xffff0000) ? ((ntohl(((ex).a_midmag))>>16)&0x03ff) : MID_ZERO )
|
||||
#define N_GETFLAG(ex) \
|
||||
( (((ex).a_midmag)&0xffff0000) ? ((ntohl(((ex).a_midmag))>>26)&0x3f) : 0 )
|
||||
#define N_SETMAGIC(ex,mag,mid,flag) \
|
||||
( (ex).a_midmag = htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) | \
|
||||
(((mag)&0xffff)) ) )
|
||||
|
||||
#define N_ALIGN(ex,x) \
|
||||
(N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC ? \
|
||||
((x) + __LDPGSZ - 1) & ~(__LDPGSZ - 1) : (x))
|
||||
|
||||
/* Valid magic number check. */
|
||||
#define N_BADMAG(ex) \
|
||||
(N_GETMAGIC(ex) != NMAGIC && N_GETMAGIC(ex) != OMAGIC && \
|
||||
N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC)
|
||||
|
||||
/* Address of the bottom of the text segment. */
|
||||
#define N_TXTADDR(ex) (N_GETMAGIC2(ex) == (ZMAGIC|0x10000) ? 0 : __LDPGSZ)
|
||||
|
||||
/* Address of the bottom of the data segment. */
|
||||
#define N_DATADDR(ex) \
|
||||
(N_GETMAGIC(ex) == OMAGIC ? N_TXTADDR(ex) + (ex).a_text : \
|
||||
(N_TXTADDR(ex) + (ex).a_text + __LDPGSZ - 1) & ~(__LDPGSZ - 1))
|
||||
|
||||
/* Address of the bottom of the bss segment. */
|
||||
#define N_BSSADDR(ex) \
|
||||
(N_DATADDR(ex) + (ex).a_data)
|
||||
|
||||
/* Text segment offset. */
|
||||
#define N_TXTOFF(ex) \
|
||||
( N_GETMAGIC2(ex)==ZMAGIC || N_GETMAGIC2(ex)==(QMAGIC|0x10000) ? \
|
||||
0 : (N_GETMAGIC2(ex)==(ZMAGIC|0x10000) ? __LDPGSZ : \
|
||||
sizeof(struct exec)) )
|
||||
|
||||
/* Data segment offset. */
|
||||
#define N_DATOFF(ex) \
|
||||
N_ALIGN(ex, N_TXTOFF(ex) + (ex).a_text)
|
||||
|
||||
/* Text relocation table offset. */
|
||||
#define N_TRELOFF(ex) \
|
||||
(N_DATOFF(ex) + (ex).a_data)
|
||||
|
||||
/* Data relocation table offset. */
|
||||
#define N_DRELOFF(ex) \
|
||||
(N_TRELOFF(ex) + (ex).a_trsize)
|
||||
|
||||
/* Symbol table offset. */
|
||||
#define N_SYMOFF(ex) \
|
||||
(N_DRELOFF(ex) + (ex).a_drsize)
|
||||
|
||||
/* String table offset. */
|
||||
#define N_STROFF(ex) \
|
||||
(N_SYMOFF(ex) + (ex).a_syms)
|
||||
|
||||
#include <sys/exec.h>
|
||||
|
||||
#define _AOUT_INCLUDE_
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ec_asn1_test.c,v 1.4 2024/10/14 13:16:06 tb Exp $ */
|
||||
/* $OpenBSD: ec_asn1_test.c,v 1.6 2024/10/16 23:58:25 tb Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2017, 2021 Joel Sing <jsing@openbsd.org>
|
||||
* Copyright (c) 2024 Theo Buehler <tb@openbsd.org>
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/objects.h>
|
||||
|
||||
const uint8_t ec_secp256r1_pkparameters_named_curve[] = {
|
||||
@ -339,6 +340,291 @@ ec_group_roundtrip_builtin_curves(void)
|
||||
return failed;
|
||||
}
|
||||
|
||||
/*
|
||||
* From draft-ietf-lwig-curve-representation-23, Appendix E.3
|
||||
*/
|
||||
|
||||
static const struct {
|
||||
const char *oid;
|
||||
const char *sn;
|
||||
const char *ln;
|
||||
const char *p;
|
||||
const char *a;
|
||||
const char *b;
|
||||
const char *order;
|
||||
const char *cofactor;
|
||||
const char *x;
|
||||
const char *y;
|
||||
} wei25519 = {
|
||||
.oid = "1.3.101.108",
|
||||
.sn = "Wei25519",
|
||||
.p = "7fffffff" "ffffffff" "ffffffff" "ffffffff"
|
||||
"ffffffff" "ffffffff" "ffffffff" "ffffffed",
|
||||
.a = "2aaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
||||
"aaaaaaaa" "aaaaaaaa" "aaaaaa98" "4914a144",
|
||||
.b = "7b425ed0" "97b425ed" "097b425e" "d097b425"
|
||||
"ed097b42" "5ed097b4" "260b5e9c" "7710c864",
|
||||
.x = "2aaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
||||
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaad245a",
|
||||
.y = "20ae19a1" "b8a086b4" "e01edd2c" "7748d14c"
|
||||
"923d4d7e" "6d7c61b2" "29e9c5a2" "7eced3d9",
|
||||
.order = "10000000" "00000000" "00000000" "00000000"
|
||||
"14def9de" "a2f79cd6" "5812631a" "5cf5d3ed",
|
||||
.cofactor = "8",
|
||||
};
|
||||
|
||||
const uint8_t ec_wei25519_pkparameters_named_curve[] = {
|
||||
0x06, 0x03, 0x2b, 0x65, 0x6c,
|
||||
};
|
||||
|
||||
const uint8_t ec_wei25519_pkparameters_parameters[] = {
|
||||
0x30, 0x81, 0xde, 0x02, 0x01, 0x01, 0x30, 0x2b,
|
||||
0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01,
|
||||
0x01, 0x02, 0x20, 0x7f, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xed, 0x30, 0x44, 0x04, 0x20, 0x2a,
|
||||
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
|
||||
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
|
||||
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
|
||||
0xaa, 0xaa, 0x98, 0x49, 0x14, 0xa1, 0x44, 0x04,
|
||||
0x20, 0x7b, 0x42, 0x5e, 0xd0, 0x97, 0xb4, 0x25,
|
||||
0xed, 0x09, 0x7b, 0x42, 0x5e, 0xd0, 0x97, 0xb4,
|
||||
0x25, 0xed, 0x09, 0x7b, 0x42, 0x5e, 0xd0, 0x97,
|
||||
0xb4, 0x26, 0x0b, 0x5e, 0x9c, 0x77, 0x10, 0xc8,
|
||||
0x64, 0x04, 0x41, 0x04, 0x2a, 0xaa, 0xaa, 0xaa,
|
||||
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
|
||||
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
|
||||
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
|
||||
0xaa, 0xad, 0x24, 0x5a, 0x20, 0xae, 0x19, 0xa1,
|
||||
0xb8, 0xa0, 0x86, 0xb4, 0xe0, 0x1e, 0xdd, 0x2c,
|
||||
0x77, 0x48, 0xd1, 0x4c, 0x92, 0x3d, 0x4d, 0x7e,
|
||||
0x6d, 0x7c, 0x61, 0xb2, 0x29, 0xe9, 0xc5, 0xa2,
|
||||
0x7e, 0xce, 0xd3, 0xd9, 0x02, 0x20, 0x10, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0xde,
|
||||
0xf9, 0xde, 0xa2, 0xf7, 0x9c, 0xd6, 0x58, 0x12,
|
||||
0x63, 0x1a, 0x5c, 0xf5, 0xd3, 0xed, 0x02, 0x01,
|
||||
0x08,
|
||||
};
|
||||
|
||||
static int
|
||||
ec_weierstrass25519(void)
|
||||
{
|
||||
EC_GROUP *group = NULL, *new_group = NULL;
|
||||
EC_POINT *generator = NULL;
|
||||
BN_CTX *ctx = NULL;
|
||||
BIGNUM *p, *a, *b;
|
||||
BIGNUM *order, *cofactor, *guessed_cofactor, *x, *y;
|
||||
const unsigned char *pder;
|
||||
unsigned char *der = NULL;
|
||||
long error;
|
||||
int der_len = 0;
|
||||
int nid;
|
||||
int failed = 1;
|
||||
|
||||
ERR_clear_error();
|
||||
if ((ctx = BN_CTX_new()) == NULL)
|
||||
goto err;
|
||||
BN_CTX_start(ctx);
|
||||
|
||||
if ((nid = OBJ_create(wei25519.oid, wei25519.sn, NULL)) == NID_undef) {
|
||||
fprintf(stderr, "FAIL: %s OBJ_create(wei25519)\n", __func__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if ((p = BN_CTX_get(ctx)) == NULL)
|
||||
errx(1, "BN_CTX_get");
|
||||
if ((a = BN_CTX_get(ctx)) == NULL)
|
||||
errx(1, "BN_CTX_get");
|
||||
if ((b = BN_CTX_get(ctx)) == NULL)
|
||||
errx(1, "BN_CTX_get");
|
||||
if ((order = BN_CTX_get(ctx)) == NULL)
|
||||
errx(1, "BN_CTX_get");
|
||||
if ((cofactor = BN_CTX_get(ctx)) == NULL)
|
||||
errx(1, "BN_CTX_get");
|
||||
if ((guessed_cofactor = BN_CTX_get(ctx)) == NULL)
|
||||
errx(1, "BN_CTX_get");
|
||||
if ((x = BN_CTX_get(ctx)) == NULL)
|
||||
errx(1, "BN_CTX_get");
|
||||
if ((y = BN_CTX_get(ctx)) == NULL)
|
||||
errx(1, "BN_CTX_get");
|
||||
|
||||
if (BN_hex2bn(&p, wei25519.p) == 0)
|
||||
errx(1, "BN_hex2bn(p)");
|
||||
if (BN_hex2bn(&a, wei25519.a) == 0)
|
||||
errx(1, "BN_hex2bn(a)");
|
||||
if (BN_hex2bn(&b, wei25519.b) == 0)
|
||||
errx(1, "BN_hex2bn(b)");
|
||||
|
||||
/*
|
||||
* XXX - this uses the Montgomery method. Consider exercising the
|
||||
* simple method as well.
|
||||
*/
|
||||
if ((group = EC_GROUP_new_curve_GFp(p, a, b, ctx)) == NULL) {
|
||||
fprintf(stderr, "FAIL: %s EC_GROUP_new_curve_GFp", __func__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (BN_hex2bn(&x, wei25519.x) == 0)
|
||||
errx(1, "BN_hex2bn(x)");
|
||||
if (BN_hex2bn(&x, wei25519.x) == 0)
|
||||
errx(1, "BN_hex2bn(x)");
|
||||
if (BN_hex2bn(&y, wei25519.y) == 0)
|
||||
errx(1, "BN_hex2bn(y)");
|
||||
|
||||
if ((generator = EC_POINT_new(group)) == NULL)
|
||||
errx(1, "EC_POINT_new()");
|
||||
|
||||
if (!EC_POINT_set_affine_coordinates(group, generator, x, y, ctx)) {
|
||||
fprintf(stderr, "FAIL: %s EC_POINT_set_affine_coordinates", __func__);
|
||||
ERR_print_errors_fp(stderr);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (BN_hex2bn(&order, wei25519.order) == 0)
|
||||
errx(1, "BN_hex2bn(order)");
|
||||
if (BN_hex2bn(&cofactor, wei25519.cofactor) == 0)
|
||||
errx(1, "BN_hex2bn(cofactor)");
|
||||
|
||||
/* Don't set cofactor to exercise the cofactor guessing code. */
|
||||
if (!EC_GROUP_set_generator(group, generator, order, NULL)) {
|
||||
fprintf(stderr, "FAIL: %s EC_GROUP_set_generator\n", __func__);
|
||||
ERR_print_errors_fp(stderr);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!EC_GROUP_get_cofactor(group, guessed_cofactor, ctx)) {
|
||||
fprintf(stderr, "FAIL: %s EC_GROUP_get_cofactor\n", __func__);
|
||||
ERR_print_errors_fp(stderr);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (BN_cmp(cofactor, guessed_cofactor) != 0) {
|
||||
fprintf(stderr, "FAIL: %s cofactor: want ", __func__);
|
||||
BN_print_fp(stderr, cofactor);
|
||||
fprintf(stderr, ", got ");
|
||||
BN_print_fp(stderr, guessed_cofactor);
|
||||
fprintf(stderr, "\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!EC_GROUP_check(group, ctx)) {
|
||||
fprintf(stderr, "FAIL: %s EC_GROUP_check\n", __func__);
|
||||
ERR_print_errors_fp(stderr);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Explicit curve parameter encoding should work without NID set. */
|
||||
if (EC_GROUP_get_curve_name(group) != NID_undef) {
|
||||
fprintf(stderr, "FAIL: %s unexpected curve name %d\n", __func__,
|
||||
EC_GROUP_get_curve_name(group));
|
||||
ERR_print_errors_fp(stderr);
|
||||
goto err;
|
||||
}
|
||||
|
||||
EC_GROUP_set_asn1_flag(group, OPENSSL_EC_EXPLICIT_CURVE);
|
||||
|
||||
der = NULL;
|
||||
if ((der_len = i2d_ECPKParameters(group, &der)) <= 0) {
|
||||
fprintf(stderr, "FAIL: %s i2d_ECPKParameters (explicit)\n", __func__);
|
||||
ERR_print_errors_fp(stderr);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (compare_data("Weierstrass 25519 explicit", der, der_len,
|
||||
ec_wei25519_pkparameters_parameters,
|
||||
sizeof(ec_wei25519_pkparameters_parameters)) == -1)
|
||||
goto err;
|
||||
|
||||
freezero(der, der_len);
|
||||
der = NULL;
|
||||
|
||||
EC_GROUP_set_curve_name(group, nid);
|
||||
EC_GROUP_set_asn1_flag(group, OPENSSL_EC_NAMED_CURVE);
|
||||
|
||||
der = NULL;
|
||||
if ((der_len = i2d_ECPKParameters(group, &der)) <= 0) {
|
||||
fprintf(stderr, "FAIL: %s i2d_ECPKParameters (named)\n", __func__);
|
||||
ERR_print_errors_fp(stderr);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (compare_data("Weierstrass 25519 named curve", der, der_len,
|
||||
ec_wei25519_pkparameters_named_curve,
|
||||
sizeof(ec_wei25519_pkparameters_named_curve)) == -1)
|
||||
goto err;
|
||||
|
||||
freezero(der, der_len);
|
||||
der = NULL;
|
||||
|
||||
/* At this point we should have no error on the stack. */
|
||||
if (ERR_peek_last_error() != 0) {
|
||||
fprintf(stderr, "FAIL: %s unexpected error %lu\n", __func__,
|
||||
ERR_peek_last_error());
|
||||
goto err;
|
||||
}
|
||||
|
||||
pder = ec_wei25519_pkparameters_named_curve;
|
||||
der_len = sizeof(ec_wei25519_pkparameters_named_curve);
|
||||
if ((new_group = d2i_ECPKParameters(NULL, &pder, der_len)) != NULL) {
|
||||
fprintf(stderr, "FAIL: %s managed to decode unknown named curve\n",
|
||||
__func__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
error = ERR_get_error();
|
||||
if (ERR_GET_REASON(error) != EC_R_UNKNOWN_GROUP) {
|
||||
fprintf(stderr, "FAIL: %s unexpected error: want %d, got %d\n",
|
||||
__func__, EC_R_UNKNOWN_GROUP, ERR_GET_REASON(error));
|
||||
goto err;
|
||||
}
|
||||
|
||||
ERR_clear_error();
|
||||
pder = ec_wei25519_pkparameters_parameters;
|
||||
der_len = sizeof(ec_wei25519_pkparameters_parameters);
|
||||
|
||||
#if 0
|
||||
if ((new_group = d2i_ECPKParameters(NULL, &pder, der_len)) != NULL) {
|
||||
fprintf(stderr, "FAIL: %s managed to decode non-builtin parameters\n",
|
||||
__func__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
error = ERR_peek_last_error();
|
||||
if (ERR_GET_REASON(error) != EC_R_PKPARAMETERS2GROUP_FAILURE) {
|
||||
fprintf(stderr, "FAIL: %s unexpected error: want %d, got %d\n",
|
||||
__func__, EC_R_UNKNOWN_GROUP, ERR_GET_REASON(error));
|
||||
goto err;
|
||||
}
|
||||
#else
|
||||
if ((new_group = d2i_ECPKParameters(NULL, &pder, der_len)) == NULL) {
|
||||
fprintf(stderr, "FAIL: %s d2i_ECPKParameters(Wei25519)\n", __func__);
|
||||
goto err;
|
||||
}
|
||||
if (EC_GROUP_cmp(group, new_group, ctx) != 0) {
|
||||
fprintf(stderr, "FAIL: %s Weierstrass groups do not match!\n",
|
||||
__func__);
|
||||
goto err;
|
||||
}
|
||||
#endif
|
||||
|
||||
failed = 0;
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx);
|
||||
|
||||
EC_GROUP_free(group);
|
||||
EC_GROUP_free(new_group);
|
||||
EC_POINT_free(generator);
|
||||
|
||||
freezero(der, der_len);
|
||||
|
||||
return failed;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
@ -348,6 +634,7 @@ main(int argc, char **argv)
|
||||
failed |= ec_group_pkparameters_parameters_test();
|
||||
failed |= ec_group_pkparameters_correct_padding_test();
|
||||
failed |= ec_group_roundtrip_builtin_curves();
|
||||
failed |= ec_weierstrass25519();
|
||||
|
||||
return (failed);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: if_tun.c,v 1.241 2024/10/10 06:50:58 dlg Exp $ */
|
||||
/* $OpenBSD: if_tun.c,v 1.243 2024/10/16 11:12:31 dlg Exp $ */
|
||||
/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
@ -123,7 +123,6 @@ int tap_clone_create(struct if_clone *, int);
|
||||
int tun_create(struct if_clone *, int, int);
|
||||
int tun_clone_destroy(struct ifnet *);
|
||||
void tun_wakeup(struct tun_softc *);
|
||||
int tun_init(struct tun_softc *);
|
||||
void tun_start(struct ifnet *);
|
||||
int filt_tunread(struct knote *, long);
|
||||
int filt_tunwrite(struct knote *, long);
|
||||
@ -523,61 +522,6 @@ tun_dev_close(dev_t dev, struct proc *p)
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
tun_init(struct tun_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp = &sc->sc_if;
|
||||
struct ifaddr *ifa;
|
||||
|
||||
TUNDEBUG(("%s: tun_init\n", ifp->if_xname));
|
||||
|
||||
ifp->if_flags |= IFF_UP | IFF_RUNNING;
|
||||
|
||||
sc->sc_flags &= ~(TUN_IASET|TUN_DSTADDR|TUN_BRDADDR);
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
|
||||
if (ifa->ifa_addr->sa_family == AF_INET) {
|
||||
struct sockaddr_in *sin;
|
||||
|
||||
sin = satosin(ifa->ifa_addr);
|
||||
if (sin && sin->sin_addr.s_addr)
|
||||
sc->sc_flags |= TUN_IASET;
|
||||
|
||||
if (ifp->if_flags & IFF_POINTOPOINT) {
|
||||
sin = satosin(ifa->ifa_dstaddr);
|
||||
if (sin && sin->sin_addr.s_addr)
|
||||
sc->sc_flags |= TUN_DSTADDR;
|
||||
} else
|
||||
sc->sc_flags &= ~TUN_DSTADDR;
|
||||
|
||||
if (ifp->if_flags & IFF_BROADCAST) {
|
||||
sin = satosin(ifa->ifa_broadaddr);
|
||||
if (sin && sin->sin_addr.s_addr)
|
||||
sc->sc_flags |= TUN_BRDADDR;
|
||||
} else
|
||||
sc->sc_flags &= ~TUN_BRDADDR;
|
||||
}
|
||||
#ifdef INET6
|
||||
if (ifa->ifa_addr->sa_family == AF_INET6) {
|
||||
struct sockaddr_in6 *sin6;
|
||||
|
||||
sin6 = satosin6(ifa->ifa_addr);
|
||||
if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
|
||||
sc->sc_flags |= TUN_IASET;
|
||||
|
||||
if (ifp->if_flags & IFF_POINTOPOINT) {
|
||||
sin6 = satosin6(ifa->ifa_dstaddr);
|
||||
if (sin6 &&
|
||||
!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
|
||||
sc->sc_flags |= TUN_DSTADDR;
|
||||
} else
|
||||
sc->sc_flags &= ~TUN_DSTADDR;
|
||||
}
|
||||
#endif /* INET6 */
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Process an ioctl request.
|
||||
*/
|
||||
@ -590,8 +534,8 @@ tun_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
|
||||
switch (cmd) {
|
||||
case SIOCSIFADDR:
|
||||
tun_init(sc);
|
||||
break;
|
||||
SET(ifp->if_flags, IFF_UP);
|
||||
/* FALLTHROUGH */
|
||||
case SIOCSIFFLAGS:
|
||||
if (ISSET(ifp->if_flags, IFF_UP))
|
||||
SET(ifp->if_flags, IFF_RUNNING);
|
||||
@ -599,10 +543,6 @@ tun_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
CLR(ifp->if_flags, IFF_RUNNING);
|
||||
break;
|
||||
|
||||
case SIOCSIFDSTADDR:
|
||||
tun_init(sc);
|
||||
TUNDEBUG(("%s: destination address set\n", ifp->if_xname));
|
||||
break;
|
||||
case SIOCSIFMTU:
|
||||
if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > TUNMRU)
|
||||
error = EINVAL;
|
||||
|
120
sys/sys/exec.h
120
sys/sys/exec.h
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: exec.h,v 1.54 2024/04/02 08:39:16 deraadt Exp $ */
|
||||
/* $OpenBSD: exec.h,v 1.55 2024/10/16 18:47:48 miod Exp $ */
|
||||
/* $NetBSD: exec.h,v 1.59 1996/02/09 18:25:09 christos Exp $ */
|
||||
|
||||
/*-
|
||||
@ -222,38 +222,6 @@ extern int stackgap_random;
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#ifndef N_PAGSIZ
|
||||
#define N_PAGSIZ(ex) (__LDPGSZ)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Legacy a.out structures and defines; start deleting these when
|
||||
* external use no longer exist.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Header prepended to each a.out file.
|
||||
* only manipulate the a_midmag field via the
|
||||
* N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros below.
|
||||
*/
|
||||
struct exec {
|
||||
u_int32_t a_midmag; /* htonl(flags<<26|mid<<16|magic) */
|
||||
u_int32_t a_text; /* text segment size */
|
||||
u_int32_t a_data; /* initialized data size */
|
||||
u_int32_t a_bss; /* uninitialized data size */
|
||||
u_int32_t a_syms; /* symbol table size */
|
||||
u_int32_t a_entry; /* entry point */
|
||||
u_int32_t a_trsize; /* text relocation size */
|
||||
u_int32_t a_drsize; /* data relocation size */
|
||||
};
|
||||
|
||||
/* a_magic */
|
||||
#define OMAGIC 0407 /* old impure format */
|
||||
#define NMAGIC 0410 /* read-only text */
|
||||
#define ZMAGIC 0413 /* demand load format */
|
||||
#define QMAGIC 0314 /* "compact" demand load format; deprecated */
|
||||
|
||||
/*
|
||||
* a_mid - keep sorted in numerical order for sanity's sake
|
||||
* ensure that: 0 < mid < 0x3ff
|
||||
@ -292,92 +260,6 @@ struct exec {
|
||||
#define MID_HPPA11 0x210 /* hp700 HP-UX binary pa1.1 */
|
||||
#define MID_HPPA20 0x214 /* hp700 HP-UX binary pa2.0 */
|
||||
|
||||
/*
|
||||
* a_flags
|
||||
*/
|
||||
#define EX_DYNAMIC 0x20
|
||||
#define EX_PIC 0x10
|
||||
#define EX_DPMASK 0x30
|
||||
/*
|
||||
* Interpretation of the (a_flags & EX_DPMASK) bits:
|
||||
*
|
||||
* 00 traditional executable or object file
|
||||
* 01 object file contains PIC code (set by `as -k')
|
||||
* 10 dynamic executable
|
||||
* 11 position independent executable image
|
||||
* (eg. a shared library)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* The a.out structure's a_midmag field is a network-byteorder encoding
|
||||
* of this int
|
||||
* FFFFFFmmmmmmmmmmMMMMMMMMMMMMMMMM
|
||||
* Where `F' is 6 bits of flag like EX_DYNAMIC,
|
||||
* `m' is 10 bits of machine-id like MID_I386, and
|
||||
* `M' is 16 bits worth of magic number, ie. ZMAGIC.
|
||||
* The macros below will set/get the needed fields.
|
||||
*/
|
||||
#define N_GETMAGIC(ex) \
|
||||
( (((ex).a_midmag)&0xffff0000) ? (ntohl(((ex).a_midmag))&0xffff) : ((ex).a_midmag))
|
||||
#define N_GETMAGIC2(ex) \
|
||||
( (((ex).a_midmag)&0xffff0000) ? (ntohl(((ex).a_midmag))&0xffff) : \
|
||||
(((ex).a_midmag) | 0x10000) )
|
||||
#define N_GETMID(ex) \
|
||||
( (((ex).a_midmag)&0xffff0000) ? ((ntohl(((ex).a_midmag))>>16)&0x03ff) : MID_ZERO )
|
||||
#define N_GETFLAG(ex) \
|
||||
( (((ex).a_midmag)&0xffff0000) ? ((ntohl(((ex).a_midmag))>>26)&0x3f) : 0 )
|
||||
#define N_SETMAGIC(ex,mag,mid,flag) \
|
||||
( (ex).a_midmag = htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) | \
|
||||
(((mag)&0xffff)) ) )
|
||||
|
||||
#define N_ALIGN(ex,x) \
|
||||
(N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC ? \
|
||||
((x) + __LDPGSZ - 1) & ~(__LDPGSZ - 1) : (x))
|
||||
|
||||
/* Valid magic number check. */
|
||||
#define N_BADMAG(ex) \
|
||||
(N_GETMAGIC(ex) != NMAGIC && N_GETMAGIC(ex) != OMAGIC && \
|
||||
N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC)
|
||||
|
||||
/* Address of the bottom of the text segment. */
|
||||
#define N_TXTADDR(ex) (N_GETMAGIC2(ex) == (ZMAGIC|0x10000) ? 0 : __LDPGSZ)
|
||||
|
||||
/* Address of the bottom of the data segment. */
|
||||
#define N_DATADDR(ex) \
|
||||
(N_GETMAGIC(ex) == OMAGIC ? N_TXTADDR(ex) + (ex).a_text : \
|
||||
(N_TXTADDR(ex) + (ex).a_text + __LDPGSZ - 1) & ~(__LDPGSZ - 1))
|
||||
|
||||
/* Address of the bottom of the bss segment. */
|
||||
#define N_BSSADDR(ex) \
|
||||
(N_DATADDR(ex) + (ex).a_data)
|
||||
|
||||
/* Text segment offset. */
|
||||
#define N_TXTOFF(ex) \
|
||||
( N_GETMAGIC2(ex)==ZMAGIC || N_GETMAGIC2(ex)==(QMAGIC|0x10000) ? \
|
||||
0 : (N_GETMAGIC2(ex)==(ZMAGIC|0x10000) ? __LDPGSZ : \
|
||||
sizeof(struct exec)) )
|
||||
|
||||
/* Data segment offset. */
|
||||
#define N_DATOFF(ex) \
|
||||
N_ALIGN(ex, N_TXTOFF(ex) + (ex).a_text)
|
||||
|
||||
/* Text relocation table offset. */
|
||||
#define N_TRELOFF(ex) \
|
||||
(N_DATOFF(ex) + (ex).a_data)
|
||||
|
||||
/* Data relocation table offset. */
|
||||
#define N_DRELOFF(ex) \
|
||||
(N_TRELOFF(ex) + (ex).a_trsize)
|
||||
|
||||
/* Symbol table offset. */
|
||||
#define N_SYMOFF(ex) \
|
||||
(N_DRELOFF(ex) + (ex).a_drsize)
|
||||
|
||||
/* String table offset. */
|
||||
#define N_STROFF(ex) \
|
||||
(N_SYMOFF(ex) + (ex).a_syms)
|
||||
|
||||
#include <machine/exec.h>
|
||||
|
||||
#endif /* !_SYS_EXEC_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: file.c,v 1.19 2017/10/29 08:45:53 mpi Exp $ */
|
||||
/* $OpenBSD: file.c,v 1.20 2024/10/16 18:47:48 miod Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995-96 Mats O Jansson. All rights reserved.
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
#ifndef NOAOUT
|
||||
#if defined(__OpenBSD__)
|
||||
#include <sys/exec.h>
|
||||
#include <a.out.h>
|
||||
#endif
|
||||
#if defined(__bsdi__)
|
||||
#define NOAOUT
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: mopa.out.c,v 1.18 2022/12/28 21:30:17 jmc Exp $ */
|
||||
/* $OpenBSD: mopa.out.c,v 1.19 2024/10/16 18:47:48 miod Exp $ */
|
||||
|
||||
/*
|
||||
* mopa.out - Convert a Unix format kernel into something that
|
||||
@ -53,7 +53,7 @@
|
||||
#include "common/mopdef.h"
|
||||
#include "common/file.h"
|
||||
#if defined(__OpenBSD__)
|
||||
#include <sys/exec.h>
|
||||
#include <a.out.h>
|
||||
#endif
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/imgact_aout.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: validate.c,v 1.76 2024/06/17 18:52:50 tb Exp $ */
|
||||
/* $OpenBSD: validate.c,v 1.77 2024/10/16 06:09:45 tb Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
*
|
||||
@ -587,7 +587,7 @@ valid_uuid(const char *s)
|
||||
static int
|
||||
valid_ca_pkey_rsa(const char *fn, EVP_PKEY *pkey)
|
||||
{
|
||||
RSA *rsa;
|
||||
const RSA *rsa;
|
||||
const BIGNUM *rsa_e;
|
||||
int key_bits;
|
||||
|
||||
@ -618,7 +618,7 @@ valid_ca_pkey_rsa(const char *fn, EVP_PKEY *pkey)
|
||||
static int
|
||||
valid_ca_pkey_ec(const char *fn, EVP_PKEY *pkey)
|
||||
{
|
||||
EC_KEY *ec;
|
||||
const EC_KEY *ec;
|
||||
const EC_GROUP *group;
|
||||
int nid;
|
||||
const char *cname;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: x509.c,v 1.103 2024/10/07 14:45:33 tb Exp $ */
|
||||
/* $OpenBSD: x509.c,v 1.104 2024/10/16 06:09:45 tb Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
|
||||
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
|
||||
@ -413,7 +413,7 @@ char *
|
||||
x509_get_pubkey(X509 *x, const char *fn)
|
||||
{
|
||||
EVP_PKEY *pkey;
|
||||
EC_KEY *eckey;
|
||||
const EC_KEY *eckey;
|
||||
int nid;
|
||||
const char *cname;
|
||||
uint8_t *pubkey = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user