sync code with last fixes and improvements from OpenBSD
This commit is contained in:
parent
58df21ce75
commit
f960599e67
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
**/obj
|
||||
**/tags
|
||||
**/CVS
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: main.c,v 1.99 2023/02/08 17:22:10 kn Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.100 2023/07/23 23:42:03 kn Exp $ */
|
||||
|
||||
/*
|
||||
* startup, main loop, environments and error handling
|
||||
@ -87,7 +87,11 @@ static const char *initcoms [] = {
|
||||
"typeset", "-x", "SHELL", "PATH", "HOME", "PWD", "OLDPWD", NULL,
|
||||
"typeset", "-ir", "PPID", NULL,
|
||||
"typeset", "-i", "OPTIND=1", NULL,
|
||||
#ifndef SMALL
|
||||
"eval", "typeset -i RANDOM MAILCHECK=\"${MAILCHECK-600}\" SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL,
|
||||
#else
|
||||
"eval", "typeset -i RANDOM SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL,
|
||||
#endif /* SMALL */
|
||||
"alias",
|
||||
/* Standard ksh aliases */
|
||||
"hash=alias -t", /* not "alias -t --": hash -r needs to work */
|
||||
@ -615,7 +619,9 @@ shell(Source *volatile s, volatile int toplevel)
|
||||
if (interactive) {
|
||||
got_sigwinch = 1;
|
||||
j_notify();
|
||||
#ifndef SMALL
|
||||
mcheck();
|
||||
#endif /* SMALL */
|
||||
set_prompt(PS1);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: var.c,v 1.72 2021/03/05 15:22:03 zhuk Exp $ */
|
||||
/* $OpenBSD: var.c,v 1.73 2023/07/23 23:42:03 kn Exp $ */
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
@ -108,9 +108,11 @@ initvar(void)
|
||||
{ "HISTSIZE", V_HISTSIZE },
|
||||
{ "EDITOR", V_EDITOR },
|
||||
{ "VISUAL", V_VISUAL },
|
||||
#ifndef SMALL
|
||||
{ "MAIL", V_MAIL },
|
||||
{ "MAILCHECK", V_MAILCHECK },
|
||||
{ "MAILPATH", V_MAILPATH },
|
||||
#endif /* SMALL */
|
||||
{ "RANDOM", V_RANDOM },
|
||||
{ "SECONDS", V_SECONDS },
|
||||
{ "TMOUT", V_TMOUT },
|
||||
@ -1029,6 +1031,7 @@ setspec(struct tbl *vp)
|
||||
x_cols = l;
|
||||
}
|
||||
break;
|
||||
#ifndef SMALL
|
||||
case V_MAIL:
|
||||
mbset(str_val(vp));
|
||||
break;
|
||||
@ -1040,6 +1043,7 @@ setspec(struct tbl *vp)
|
||||
mcset(intval(vp));
|
||||
vp->flag |= SPECIAL;
|
||||
break;
|
||||
#endif /* SMALL */
|
||||
case V_RANDOM:
|
||||
vp->flag &= ~SPECIAL;
|
||||
srand_deterministic((unsigned int)intval(vp));
|
||||
@ -1099,17 +1103,21 @@ unsetspec(struct tbl *vp)
|
||||
afree(tmpdir, APERM);
|
||||
tmpdir = NULL;
|
||||
break;
|
||||
#ifndef SMALL
|
||||
case V_MAIL:
|
||||
mbset(NULL);
|
||||
break;
|
||||
case V_MAILPATH:
|
||||
mpset(NULL);
|
||||
break;
|
||||
#endif /* SMALL */
|
||||
case V_HISTCONTROL:
|
||||
sethistcontrol(NULL);
|
||||
break;
|
||||
case V_LINENO:
|
||||
#ifndef SMALL
|
||||
case V_MAILCHECK: /* at&t ksh leaves previous value in place */
|
||||
#endif /* SMALL */
|
||||
case V_RANDOM:
|
||||
case V_SECONDS:
|
||||
case V_TMOUT: /* at&t ksh leaves previous value in place */
|
||||
|
@ -1786,7 +1786,6 @@
|
||||
./usr/share/man/man3/BIO_ctrl.3
|
||||
./usr/share/man/man3/BIO_dump.3
|
||||
./usr/share/man/man3/BIO_dup_chain.3
|
||||
./usr/share/man/man3/BIO_f_asn1.3
|
||||
./usr/share/man/man3/BIO_f_base64.3
|
||||
./usr/share/man/man3/BIO_f_buffer.3
|
||||
./usr/share/man/man3/BIO_f_cipher.3
|
||||
@ -1813,7 +1812,6 @@
|
||||
./usr/share/man/man3/BIO_s_socket.3
|
||||
./usr/share/man/man3/BIO_set_callback.3
|
||||
./usr/share/man/man3/BIO_should_retry.3
|
||||
./usr/share/man/man3/BN_BLINDING_new.3
|
||||
./usr/share/man/man3/BN_CTX_new.3
|
||||
./usr/share/man/man3/BN_CTX_start.3
|
||||
./usr/share/man/man3/BN_add.3
|
||||
@ -1967,8 +1965,8 @@
|
||||
./usr/share/man/man3/MD5Init.3
|
||||
./usr/share/man/man3/NAME_CONSTRAINTS_new.3
|
||||
./usr/share/man/man3/OBJ_NAME_add.3
|
||||
./usr/share/man/man3/OBJ_add_sigid.3
|
||||
./usr/share/man/man3/OBJ_create.3
|
||||
./usr/share/man/man3/OBJ_find_sigid_algs.3
|
||||
./usr/share/man/man3/OBJ_nid2obj.3
|
||||
./usr/share/man/man3/OCSP_CRLID_new.3
|
||||
./usr/share/man/man3/OCSP_REQUEST_new.3
|
||||
|
@ -1,7 +1,7 @@
|
||||
# $OpenBSD: Makefile,v 1.47 2021/05/19 17:25:10 deraadt Exp $
|
||||
# $OpenBSD: Makefile,v 1.48 2023/07/25 14:51:38 kn Exp $
|
||||
|
||||
SUBDIR= libstubs \
|
||||
arch bioctl cat chmod chroot cp date dd df dhclient dhcpleased disklabel \
|
||||
arch bioctl cat chmod chroot cp date dd df dhcpleased disklabel \
|
||||
dmesg doas ed eeprom encrypt fdisk fsck fsck_ext2fs fsck_ffs fsck_msdos ftp \
|
||||
ftp-ssl grep growfs gzip hostname ifconfig init installboot kbd ksh ln \
|
||||
ls md5 mkdir mknod mkuboot more mount mount_cd9660 mount_ext2fs \
|
||||
|
@ -1,16 +0,0 @@
|
||||
# $OpenBSD: Makefile,v 1.17 2019/11/11 05:39:04 deraadt Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
.PATH: ${.CURDIR}/../../../sbin/dhclient
|
||||
|
||||
CPPFLAGS+= -I${.CURDIR}/../../../sbin/dhclient
|
||||
SRCS= dhclient.c clparse.c dispatch.c bpf.c options.c \
|
||||
conflex.c log.c kroute.c packet.c \
|
||||
parse.c privsep.c
|
||||
PROG= dhclient
|
||||
LDADD+= -lutil
|
||||
DPADD+= ${LIBUTIL}
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <bsd.subdir.mk>
|
@ -1,8 +1,8 @@
|
||||
# $OpenBSD: Makefile,v 1.6 2023/02/08 17:22:10 kn Exp $
|
||||
# $OpenBSD: Makefile,v 1.7 2023/07/23 23:42:03 kn Exp $
|
||||
|
||||
PROG= ksh
|
||||
SRCS= alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c edit.c emacs.c eval.c \
|
||||
exec.c expr.c history.c io.c jobs.c lex.c mail.c main.c \
|
||||
exec.c expr.c history.c io.c jobs.c lex.c main.c \
|
||||
misc.c path.c shf.c syn.c table.c trap.c tree.c tty.c var.c \
|
||||
vi.c
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
# $OpenBSD: Makefile,v 1.1 2014/12/23 17:16:02 deraadt Exp $
|
||||
# $OpenBSD: Makefile,v 1.2 2023/07/23 23:21:19 kn Exp $
|
||||
|
||||
PROG= mount
|
||||
SRCS= mount.c
|
||||
COPTS+= -DSMALL
|
||||
DPADD= ${LIBUTIL}
|
||||
LDADD= -lutil
|
||||
MAN= mount.8
|
||||
|
@ -1,6 +1,6 @@
|
||||
From purplerain@secbsd.org Sat Jul 22 00:00:00 UTC 2023
|
||||
From purplerain@secbsd.org Wed Jul 26 00:00:00 UTC 2023
|
||||
Return-Path: root
|
||||
Date: Jul 22 00:00:00 UTC 2023
|
||||
Date: Jul 26 00:00:00 UTC 2023
|
||||
From: purplerain@secbsd.org (Purple Rain)
|
||||
To: root
|
||||
Subject: Welcome to SecBSD 1.3!
|
||||
|
@ -1 +1 @@
|
||||
# SecBSD 1.3-91d9be7: Sat Jul 22 00:00:00 UTC 2023 (Tezcatlipoca)
|
||||
# SecBSD 1.3-6971d2f: Thu Jul 27 00:00:00 UTC 2023 (Tezcatlipoca)
|
||||
|
@ -319,7 +319,7 @@ diag (xoff, xlim, yoff, ylim, minimal, part)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Compare in detail contiguous subsequences of the two files
|
||||
which are known, as a whole, to match each other.
|
||||
|
||||
@ -330,7 +330,7 @@ diag (xoff, xlim, yoff, ylim, minimal, part)
|
||||
|
||||
Note that XLIM, YLIM are exclusive bounds.
|
||||
All line numbers are origin-0 and discarded lines are not counted.
|
||||
|
||||
|
||||
If MINIMAL is nonzero, find a minimal difference no matter how
|
||||
expensive it is. */
|
||||
|
||||
@ -388,7 +388,7 @@ compareseq (xoff, xlim, yoff, ylim, minimal)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Discard lines from one file that have no matches in the other file.
|
||||
|
||||
A line which is discarded will not be considered by the actual
|
||||
@ -603,7 +603,7 @@ discard_confusing_lines (filevec)
|
||||
free (discarded[0]);
|
||||
free (equiv_count[0]);
|
||||
}
|
||||
|
||||
|
||||
/* Adjust inserts/deletes of identical lines to join changes
|
||||
as much as possible.
|
||||
|
||||
@ -716,7 +716,7 @@ shift_boundaries (filevec)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Cons an additional entry onto the front of an edit script OLD.
|
||||
LINE0 and LINE1 are the first affected lines in the two files (origin 0).
|
||||
DELETED is the number of lines deleted here from file 0.
|
||||
@ -812,7 +812,7 @@ build_script (filevec)
|
||||
|
||||
return script;
|
||||
}
|
||||
|
||||
|
||||
/* If CHANGES, briefly report that two files differed. */
|
||||
static void
|
||||
briefly_report (changes, filevec)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: arm64cap.c,v 1.2 2022/03/25 17:42:07 robert Exp $ */
|
||||
/* $OpenBSD: arm64cap.c,v 1.3 2023/07/26 09:57:34 jsing Exp $ */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -30,10 +30,6 @@
|
||||
|
||||
unsigned int OPENSSL_armcap_P;
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 2
|
||||
void OPENSSL_cpuid_setup(void) __attribute__((constructor));
|
||||
#endif
|
||||
|
||||
#if defined(CPU_ID_AA64ISAR0)
|
||||
void
|
||||
OPENSSL_cpuid_setup(void)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: armcap.c,v 1.1 2022/03/23 15:13:31 tb Exp $ */
|
||||
/* $OpenBSD: armcap.c,v 1.2 2023/07/26 09:57:34 jsing Exp $ */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -28,10 +28,6 @@ void _armv8_sha256_probe(void);
|
||||
void _armv8_pmull_probe(void);
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__>=2
|
||||
void OPENSSL_cpuid_setup(void) __attribute__((constructor));
|
||||
#endif
|
||||
|
||||
void
|
||||
OPENSSL_cpuid_setup(void)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: x_name.c,v 1.40 2023/07/07 19:37:52 beck Exp $ */
|
||||
/* $OpenBSD: x_name.c,v 1.41 2023/07/24 06:56:54 tb Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -189,13 +189,13 @@ const ASN1_ITEM X509_NAME_INTERNAL_it = {
|
||||
*/
|
||||
|
||||
const ASN1_EXTERN_FUNCS x509_name_ff = {
|
||||
NULL,
|
||||
x509_name_ex_new,
|
||||
x509_name_ex_free,
|
||||
0, /* Default clear behaviour is OK */
|
||||
x509_name_ex_d2i,
|
||||
x509_name_ex_i2d,
|
||||
x509_name_ex_print
|
||||
.app_data = NULL,
|
||||
.asn1_ex_new = x509_name_ex_new,
|
||||
.asn1_ex_free = x509_name_ex_free,
|
||||
.asn1_ex_clear = NULL,
|
||||
.asn1_ex_d2i = x509_name_ex_d2i,
|
||||
.asn1_ex_i2d = x509_name_ex_i2d,
|
||||
.asn1_ex_print = x509_name_ex_print,
|
||||
};
|
||||
|
||||
const ASN1_ITEM X509_NAME_it = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: bn_arch.h,v 1.12 2023/06/21 07:56:43 jsing Exp $ */
|
||||
/* $OpenBSD: bn_arch.h,v 1.13 2023/07/24 10:21:29 jsing Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
|
||||
*
|
||||
@ -241,7 +241,7 @@ bn_qwmulw_addw(BN_ULONG a3, BN_ULONG a2, BN_ULONG a1, BN_ULONG a0, BN_ULONG b,
|
||||
"mul %[c], %[a3], %[b] \n"
|
||||
"adcs %[r3], %[r3], %[c] \n"
|
||||
"adc %[r4], %[r4], xzr \n"
|
||||
: [c]"+r"(c), [r4]"=&r"(r4), [r3]"=&r"(r3), [r2]"=&r"(r2),
|
||||
: [c]"+&r"(c), [r4]"=&r"(r4), [r3]"=&r"(r3), [r2]"=&r"(r2),
|
||||
[r1]"=&r"(r1), [r0]"=&r"(r0)
|
||||
: [a3]"r"(a3), [a2]"r"(a2), [a1]"r"(a1), [a0]"r"(a0), [b]"r"(b)
|
||||
: "cc");
|
||||
@ -282,7 +282,7 @@ bn_qwmulw_addqw_addw(BN_ULONG a3, BN_ULONG a2, BN_ULONG a1, BN_ULONG a0,
|
||||
"adcs %[r2], %[r2], %[c2] \n"
|
||||
"adcs %[r3], %[r3], %[c3] \n"
|
||||
"adc %[r4], %[r4], xzr \n"
|
||||
: [d]"+r"(d), [r4]"=&r"(r4), [r3]"=&r"(r3), [r2]"=&r"(r2),
|
||||
: [d]"+&r"(d), [r4]"=&r"(r4), [r3]"=&r"(r3), [r2]"=&r"(r2),
|
||||
[r1]"=&r"(r1), [r0]"=&r"(r0)
|
||||
: [a3]"r"(a3), [a2]"r"(a2), [a1]"r"(a1), [a0]"r"(a0), [b]"r"(b),
|
||||
[c3]"r"(c3), [c2]"r"(c2), [c1]"r"(c1), [c0]"r"(c0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: bn_print.c,v 1.45 2023/07/10 02:29:28 tb Exp $ */
|
||||
/* $OpenBSD: bn_print.c,v 1.46 2023/07/22 17:14:08 tb Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
|
||||
@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@ -73,11 +72,9 @@ bn_print_bignum(BIO *bio, const BIGNUM *bn, int indent)
|
||||
goto err;
|
||||
|
||||
/* Secondary indent is 4 spaces, capped at 128. */
|
||||
if (indent > INT_MAX - 4)
|
||||
goto err;
|
||||
if (indent > 124)
|
||||
indent = 124;
|
||||
indent += 4;
|
||||
if (indent > 128)
|
||||
indent = 128;
|
||||
if (indent < 0)
|
||||
indent = 0;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ct_sct.c,v 1.9 2023/07/08 07:22:58 beck Exp $ */
|
||||
/* $OpenBSD: ct_sct.c,v 1.10 2023/07/22 17:02:49 tb Exp $ */
|
||||
/*
|
||||
* Written by Rob Stradling (rob@comodo.com), Stephen Henson (steve@openssl.org)
|
||||
* and Adam Eijdenberg (adam.eijdenberg@gmail.com) for the OpenSSL project 2016.
|
||||
@ -61,14 +61,16 @@
|
||||
# error "CT disabled"
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/ct.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/tls1.h>
|
||||
#include <openssl/objects.h>
|
||||
#include <openssl/x509.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "ct_local.h"
|
||||
|
||||
SCT *
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: dh_check.c,v 1.27 2023/07/08 15:29:03 beck Exp $ */
|
||||
/* $OpenBSD: dh_check.c,v 1.28 2023/07/24 16:25:02 tb Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -289,7 +289,7 @@ DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *flags)
|
||||
if (!BN_mod_exp_ct(residue, pub_key, dh->q, dh->p, ctx))
|
||||
goto err;
|
||||
if (!BN_is_one(residue))
|
||||
*flags = DH_CHECK_PUBKEY_INVALID;
|
||||
*flags |= DH_CHECK_PUBKEY_INVALID;
|
||||
}
|
||||
|
||||
ok = 1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ec_lib.c,v 1.64 2023/07/07 19:37:53 beck Exp $ */
|
||||
/* $OpenBSD: ec_lib.c,v 1.65 2023/07/25 06:57:26 tb Exp $ */
|
||||
/*
|
||||
* Originally written by Bodo Moeller for the OpenSSL project.
|
||||
*/
|
||||
@ -1062,7 +1062,7 @@ EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point,
|
||||
BN_CTX *ctx_in)
|
||||
{
|
||||
BN_CTX *ctx;
|
||||
int ret = 0;
|
||||
int ret = -1;
|
||||
|
||||
if ((ctx = ctx_in) == NULL)
|
||||
ctx = BN_CTX_new();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ecp_smpl.c,v 1.46 2023/07/07 13:54:45 beck Exp $ */
|
||||
/* $OpenBSD: ecp_smpl.c,v 1.55 2023/07/26 17:15:25 tb Exp $ */
|
||||
/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
|
||||
* for the OpenSSL project.
|
||||
* Includes code written by Bodo Moeller for the OpenSSL project.
|
||||
@ -114,11 +114,52 @@ ec_GFp_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
ec_decode_scalar(const EC_GROUP *group, BIGNUM *bn, const BIGNUM *x, BN_CTX *ctx)
|
||||
{
|
||||
if (bn == NULL)
|
||||
return 1;
|
||||
|
||||
if (group->meth->field_decode != NULL)
|
||||
return group->meth->field_decode(group, bn, x, ctx);
|
||||
|
||||
return bn_copy(bn, x);
|
||||
}
|
||||
|
||||
static int
|
||||
ec_encode_scalar(const EC_GROUP *group, BIGNUM *bn, const BIGNUM *x, BN_CTX *ctx)
|
||||
{
|
||||
if (!BN_nnmod(bn, x, &group->field, ctx))
|
||||
return 0;
|
||||
|
||||
if (group->meth->field_encode != NULL)
|
||||
return group->meth->field_encode(group, bn, bn, ctx);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
ec_encode_z_coordinate(const EC_GROUP *group, BIGNUM *bn, int *is_one,
|
||||
const BIGNUM *z, BN_CTX *ctx)
|
||||
{
|
||||
if (!BN_nnmod(bn, z, &group->field, ctx))
|
||||
return 0;
|
||||
|
||||
*is_one = BN_is_one(bn);
|
||||
if (*is_one && group->meth->field_set_to_one != NULL)
|
||||
return group->meth->field_set_to_one(group, bn, ctx);
|
||||
|
||||
if (group->meth->field_encode != NULL)
|
||||
return group->meth->field_encode(group, bn, bn, ctx);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
ec_GFp_simple_group_set_curve(EC_GROUP *group,
|
||||
const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *tmp_a;
|
||||
BIGNUM *a_plus_3;
|
||||
int ret = 0;
|
||||
|
||||
/* p must be a prime > 3 */
|
||||
@ -129,34 +170,24 @@ ec_GFp_simple_group_set_curve(EC_GROUP *group,
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
|
||||
if ((tmp_a = BN_CTX_get(ctx)) == NULL)
|
||||
if ((a_plus_3 = BN_CTX_get(ctx)) == NULL)
|
||||
goto err;
|
||||
|
||||
/* group->field */
|
||||
if (!bn_copy(&group->field, p))
|
||||
goto err;
|
||||
BN_set_negative(&group->field, 0);
|
||||
|
||||
/* group->a */
|
||||
if (!BN_nnmod(tmp_a, a, p, ctx))
|
||||
if (!ec_encode_scalar(group, &group->a, a, ctx))
|
||||
goto err;
|
||||
if (group->meth->field_encode) {
|
||||
if (!group->meth->field_encode(group, &group->a, tmp_a, ctx))
|
||||
goto err;
|
||||
} else if (!bn_copy(&group->a, tmp_a))
|
||||
if (!ec_encode_scalar(group, &group->b, b, ctx))
|
||||
goto err;
|
||||
|
||||
/* group->b */
|
||||
if (!BN_nnmod(&group->b, b, p, ctx))
|
||||
if (!BN_set_word(a_plus_3, 3))
|
||||
goto err;
|
||||
if (!BN_mod_add(a_plus_3, a_plus_3, a, &group->field, ctx))
|
||||
goto err;
|
||||
if (group->meth->field_encode)
|
||||
if (!group->meth->field_encode(group, &group->b, &group->b, ctx))
|
||||
goto err;
|
||||
|
||||
/* group->a_is_minus3 */
|
||||
if (!BN_add_word(tmp_a, 3))
|
||||
goto err;
|
||||
group->a_is_minus3 = (0 == BN_cmp(tmp_a, &group->field));
|
||||
group->a_is_minus3 = BN_is_zero(a_plus_3);
|
||||
|
||||
ret = 1;
|
||||
|
||||
@ -167,31 +198,17 @@ ec_GFp_simple_group_set_curve(EC_GROUP *group,
|
||||
}
|
||||
|
||||
int
|
||||
ec_GFp_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
|
||||
ec_GFp_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
|
||||
BIGNUM *b, BN_CTX *ctx)
|
||||
{
|
||||
if (p != NULL) {
|
||||
if (!bn_copy(p, &group->field))
|
||||
return 0;
|
||||
}
|
||||
if (group->meth->field_decode != NULL) {
|
||||
if (a != NULL) {
|
||||
if (!group->meth->field_decode(group, a, &group->a, ctx))
|
||||
return 0;
|
||||
}
|
||||
if (b != NULL) {
|
||||
if (!group->meth->field_decode(group, b, &group->b, ctx))
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if (a != NULL) {
|
||||
if (!bn_copy(a, &group->a))
|
||||
return 0;
|
||||
}
|
||||
if (b != NULL) {
|
||||
if (!bn_copy(b, &group->b))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (!ec_decode_scalar(group, a, &group->a, ctx))
|
||||
return 0;
|
||||
if (!ec_decode_scalar(group, b, &group->b, ctx))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -205,62 +222,52 @@ ec_GFp_simple_group_get_degree(const EC_GROUP *group)
|
||||
int
|
||||
ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *a, *b, *order, *tmp_1, *tmp_2;
|
||||
const BIGNUM *p = &group->field;
|
||||
BIGNUM *p, *a, *b, *discriminant;
|
||||
int ret = 0;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
|
||||
if ((p = BN_CTX_get(ctx)) == NULL)
|
||||
goto err;
|
||||
if ((a = BN_CTX_get(ctx)) == NULL)
|
||||
goto err;
|
||||
if ((b = BN_CTX_get(ctx)) == NULL)
|
||||
goto err;
|
||||
if ((tmp_1 = BN_CTX_get(ctx)) == NULL)
|
||||
goto err;
|
||||
if ((tmp_2 = BN_CTX_get(ctx)) == NULL)
|
||||
goto err;
|
||||
if ((order = BN_CTX_get(ctx)) == NULL)
|
||||
if ((discriminant = BN_CTX_get(ctx)) == NULL)
|
||||
goto err;
|
||||
|
||||
if (group->meth->field_decode) {
|
||||
if (!group->meth->field_decode(group, a, &group->a, ctx))
|
||||
goto err;
|
||||
if (!group->meth->field_decode(group, b, &group->b, ctx))
|
||||
goto err;
|
||||
} else {
|
||||
if (!bn_copy(a, &group->a))
|
||||
goto err;
|
||||
if (!bn_copy(b, &group->b))
|
||||
goto err;
|
||||
}
|
||||
if (!EC_GROUP_get_curve(group, p, a, b, ctx))
|
||||
goto err;
|
||||
|
||||
/*
|
||||
* check the discriminant: y^2 = x^3 + a*x + b is an elliptic curve
|
||||
* <=> 4*a^3 + 27*b^2 != 0 (mod p) 0 =< a, b < p
|
||||
* Check that the discriminant 4a^3 + 27b^2 is non-zero modulo p.
|
||||
*/
|
||||
if (BN_is_zero(a)) {
|
||||
if (BN_is_zero(b))
|
||||
goto err;
|
||||
} else if (!BN_is_zero(b)) {
|
||||
if (!BN_mod_sqr(tmp_1, a, p, ctx))
|
||||
goto err;
|
||||
if (!BN_mod_mul(tmp_2, tmp_1, a, p, ctx))
|
||||
goto err;
|
||||
if (!BN_lshift(tmp_1, tmp_2, 2))
|
||||
goto err;
|
||||
/* tmp_1 = 4*a^3 */
|
||||
|
||||
if (!BN_mod_sqr(tmp_2, b, p, ctx))
|
||||
goto err;
|
||||
if (!BN_mul_word(tmp_2, 27))
|
||||
goto err;
|
||||
/* tmp_2 = 27*b^2 */
|
||||
if (BN_is_zero(a) && BN_is_zero(b))
|
||||
goto err;
|
||||
if (BN_is_zero(a) || BN_is_zero(b))
|
||||
goto done;
|
||||
|
||||
if (!BN_mod_add(a, tmp_1, tmp_2, p, ctx))
|
||||
goto err;
|
||||
if (BN_is_zero(a))
|
||||
goto err;
|
||||
}
|
||||
/* Compute the discriminant: first 4a^3, then 27b^2, then their sum. */
|
||||
if (!BN_mod_sqr(discriminant, a, p, ctx))
|
||||
goto err;
|
||||
if (!BN_mod_mul(discriminant, discriminant, a, p, ctx))
|
||||
goto err;
|
||||
if (!BN_lshift(discriminant, discriminant, 2))
|
||||
goto err;
|
||||
|
||||
if (!BN_mod_sqr(b, b, p, ctx))
|
||||
goto err;
|
||||
if (!BN_mul_word(b, 27))
|
||||
goto err;
|
||||
|
||||
if (!BN_mod_add(discriminant, discriminant, b, p, ctx))
|
||||
goto err;
|
||||
|
||||
if (BN_is_zero(discriminant))
|
||||
goto err;
|
||||
|
||||
done:
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
@ -318,39 +325,25 @@ ec_GFp_simple_set_Jprojective_coordinates(const EC_GROUP *group,
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/*
|
||||
* Setting individual coordinates allows the creation of bad points.
|
||||
* EC_POINT_set_Jprojective_coordinates() checks at the API boundary.
|
||||
*/
|
||||
|
||||
if (x != NULL) {
|
||||
if (!BN_nnmod(&point->X, x, &group->field, ctx))
|
||||
if (!ec_encode_scalar(group, &point->X, x, ctx))
|
||||
goto err;
|
||||
if (group->meth->field_encode != NULL) {
|
||||
if (!group->meth->field_encode(group, &point->X, &point->X, ctx))
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (y != NULL) {
|
||||
if (!BN_nnmod(&point->Y, y, &group->field, ctx))
|
||||
if (!ec_encode_scalar(group, &point->Y, y, ctx))
|
||||
goto err;
|
||||
if (group->meth->field_encode != NULL) {
|
||||
if (!group->meth->field_encode(group, &point->Y, &point->Y, ctx))
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (z != NULL) {
|
||||
int Z_is_one;
|
||||
|
||||
if (!BN_nnmod(&point->Z, z, &group->field, ctx))
|
||||
if (!ec_encode_z_coordinate(group, &point->Z, &point->Z_is_one,
|
||||
z, ctx))
|
||||
goto err;
|
||||
Z_is_one = BN_is_one(&point->Z);
|
||||
if (group->meth->field_encode != NULL) {
|
||||
if (Z_is_one && (group->meth->field_set_to_one != 0)) {
|
||||
if (!group->meth->field_set_to_one(group, &point->Z, ctx))
|
||||
goto err;
|
||||
} else {
|
||||
if (!group->meth->field_encode(group, &point->Z, &point->Z, ctx))
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
point->Z_is_one = Z_is_one;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
@ -363,33 +356,12 @@ ec_GFp_simple_get_Jprojective_coordinates(const EC_GROUP *group,
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (group->meth->field_decode != NULL) {
|
||||
if (x != NULL) {
|
||||
if (!group->meth->field_decode(group, x, &point->X, ctx))
|
||||
goto err;
|
||||
}
|
||||
if (y != NULL) {
|
||||
if (!group->meth->field_decode(group, y, &point->Y, ctx))
|
||||
goto err;
|
||||
}
|
||||
if (z != NULL) {
|
||||
if (!group->meth->field_decode(group, z, &point->Z, ctx))
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
if (x != NULL) {
|
||||
if (!bn_copy(x, &point->X))
|
||||
goto err;
|
||||
}
|
||||
if (y != NULL) {
|
||||
if (!bn_copy(y, &point->Y))
|
||||
goto err;
|
||||
}
|
||||
if (z != NULL) {
|
||||
if (!bn_copy(z, &point->Z))
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (!ec_decode_scalar(group, x, &point->X, ctx))
|
||||
goto err;
|
||||
if (!ec_decode_scalar(group, y, &point->Y, ctx))
|
||||
goto err;
|
||||
if (!ec_decode_scalar(group, z, &point->Z, ctx))
|
||||
goto err;
|
||||
|
||||
ret = 1;
|
||||
|
||||
@ -411,11 +383,10 @@ ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *poin
|
||||
}
|
||||
|
||||
int
|
||||
ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point,
|
||||
BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
|
||||
ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *group,
|
||||
const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *Z, *Z_1, *Z_2, *Z_3;
|
||||
const BIGNUM *Z_;
|
||||
BIGNUM *z, *Z, *Z_1, *Z_2, *Z_3;
|
||||
int ret = 0;
|
||||
|
||||
if (EC_POINT_is_at_infinity(group, point) > 0) {
|
||||
@ -425,6 +396,8 @@ ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
|
||||
if ((z = BN_CTX_get(ctx)) == NULL)
|
||||
goto err;
|
||||
if ((Z = BN_CTX_get(ctx)) == NULL)
|
||||
goto err;
|
||||
if ((Z_1 = BN_CTX_get(ctx)) == NULL)
|
||||
@ -434,77 +407,59 @@ ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT
|
||||
if ((Z_3 = BN_CTX_get(ctx)) == NULL)
|
||||
goto err;
|
||||
|
||||
/* transform (X, Y, Z) into (x, y) := (X/Z^2, Y/Z^3) */
|
||||
/* Convert from projective coordinates (X, Y, Z) into (X/Z^2, Y/Z^3). */
|
||||
|
||||
if (group->meth->field_decode) {
|
||||
if (!group->meth->field_decode(group, Z, &point->Z, ctx))
|
||||
if (!ec_decode_scalar(group, z, &point->Z, ctx))
|
||||
goto err;
|
||||
|
||||
if (BN_is_one(z)) {
|
||||
if (!ec_decode_scalar(group, x, &point->X, ctx))
|
||||
goto err;
|
||||
Z_ = Z;
|
||||
} else {
|
||||
Z_ = &point->Z;
|
||||
if (!ec_decode_scalar(group, y, &point->Y, ctx))
|
||||
goto err;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (BN_is_one(Z_)) {
|
||||
if (group->meth->field_decode) {
|
||||
if (x != NULL) {
|
||||
if (!group->meth->field_decode(group, x, &point->X, ctx))
|
||||
goto err;
|
||||
}
|
||||
if (y != NULL) {
|
||||
if (!group->meth->field_decode(group, y, &point->Y, ctx))
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
if (x != NULL) {
|
||||
if (!bn_copy(x, &point->X))
|
||||
goto err;
|
||||
}
|
||||
if (y != NULL) {
|
||||
if (!bn_copy(y, &point->Y))
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (BN_mod_inverse_ct(Z_1, Z_, &group->field, ctx) == NULL) {
|
||||
ECerror(ERR_R_BN_LIB);
|
||||
if (BN_mod_inverse_ct(Z_1, z, &group->field, ctx) == NULL) {
|
||||
ECerror(ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
if (group->meth->field_encode == NULL) {
|
||||
/* field_sqr works on standard representation */
|
||||
if (!group->meth->field_sqr(group, Z_2, Z_1, ctx))
|
||||
goto err;
|
||||
} else {
|
||||
if (!BN_mod_sqr(Z_2, Z_1, &group->field, ctx))
|
||||
goto err;
|
||||
}
|
||||
if (group->meth->field_encode == 0) {
|
||||
/* field_sqr works on standard representation */
|
||||
if (!group->meth->field_sqr(group, Z_2, Z_1, ctx))
|
||||
goto err;
|
||||
} else {
|
||||
if (!BN_mod_sqr(Z_2, Z_1, &group->field, ctx))
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (x != NULL) {
|
||||
/*
|
||||
* in the Montgomery case, field_mul will cancel out
|
||||
* Montgomery factor in X:
|
||||
*/
|
||||
if (!group->meth->field_mul(group, x, &point->X, Z_2, ctx))
|
||||
goto err;
|
||||
}
|
||||
if (y != NULL) {
|
||||
if (group->meth->field_encode == 0) {
|
||||
/* field_mul works on standard representation */
|
||||
if (!group->meth->field_mul(group, Z_3, Z_2, Z_1, ctx))
|
||||
goto err;
|
||||
} else {
|
||||
if (!BN_mod_mul(Z_3, Z_2, Z_1, &group->field, ctx))
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
* in the Montgomery case, field_mul will cancel out
|
||||
* Montgomery factor in Y:
|
||||
*/
|
||||
if (!group->meth->field_mul(group, y, &point->Y, Z_3, ctx))
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (x != NULL) {
|
||||
/*
|
||||
* in the Montgomery case, field_mul will cancel out
|
||||
* Montgomery factor in X:
|
||||
*/
|
||||
if (!group->meth->field_mul(group, x, &point->X, Z_2, ctx))
|
||||
goto err;
|
||||
}
|
||||
if (y != NULL) {
|
||||
if (group->meth->field_encode == NULL) {
|
||||
/* field_mul works on standard representation */
|
||||
if (!group->meth->field_mul(group, Z_3, Z_2, Z_1, ctx))
|
||||
goto err;
|
||||
} else {
|
||||
if (!BN_mod_mul(Z_3, Z_2, Z_1, &group->field, ctx))
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
* in the Montgomery case, field_mul will cancel out
|
||||
* Montgomery factor in Y:
|
||||
*/
|
||||
if (!group->meth->field_mul(group, y, &point->Y, Z_3, ctx))
|
||||
goto err;
|
||||
}
|
||||
|
||||
done:
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
@ -704,11 +659,9 @@ ec_GFp_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX
|
||||
BIGNUM *n0, *n1, *n2, *n3;
|
||||
int ret = 0;
|
||||
|
||||
if (EC_POINT_is_at_infinity(group, a) > 0) {
|
||||
BN_zero(&r->Z);
|
||||
r->Z_is_one = 0;
|
||||
return 1;
|
||||
}
|
||||
if (EC_POINT_is_at_infinity(group, a) > 0)
|
||||
return EC_POINT_set_to_infinity(group, r);
|
||||
|
||||
field_mul = group->meth->field_mul;
|
||||
field_sqr = group->meth->field_sqr;
|
||||
p = &group->field;
|
||||
@ -1162,7 +1115,7 @@ ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *po
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (group->meth->field_encode != 0) {
|
||||
if (group->meth->field_encode != NULL) {
|
||||
/*
|
||||
* in the Montgomery case, we just turned R*H (representing
|
||||
* H) into 1/(R*H), but we need R*(1/H) (representing
|
||||
@ -1212,7 +1165,7 @@ ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *po
|
||||
if (!group->meth->field_mul(group, &p->Y, &p->Y, tmp1, ctx))
|
||||
goto err;
|
||||
|
||||
if (group->meth->field_set_to_one != 0) {
|
||||
if (group->meth->field_set_to_one != NULL) {
|
||||
if (!group->meth->field_set_to_one(group, &p->Z, ctx))
|
||||
goto err;
|
||||
} else {
|
||||
@ -1273,7 +1226,7 @@ ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx)
|
||||
if ((tmp = BN_CTX_get(ctx)) == NULL)
|
||||
goto err;
|
||||
|
||||
/* Generate lambda in [1, group->field - 1] */
|
||||
/* Generate lambda in [1, group->field). */
|
||||
if (!bn_rand_interval(lambda, BN_value_one(), &group->field))
|
||||
goto err;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ecx_methods.c,v 1.7 2023/07/05 20:56:29 bcook Exp $ */
|
||||
/* $OpenBSD: ecx_methods.c,v 1.9 2023/07/22 19:33:25 tb Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2022 Joel Sing <jsing@openbsd.org>
|
||||
*
|
||||
@ -292,6 +292,42 @@ ecx_pub_cmp(const EVP_PKEY *pkey1, const EVP_PKEY *pkey2)
|
||||
pkey1->pkey.ecx->pub_key_len) == 0;
|
||||
}
|
||||
|
||||
/* Reimplementation of ASN1_buf_print() that adds a secondary indent of 4. */
|
||||
static int
|
||||
ecx_buf_print(BIO *bio, const uint8_t *buf, size_t buf_len, int indent)
|
||||
{
|
||||
uint8_t u8;
|
||||
size_t octets = 0;
|
||||
const char *sep = ":", *nl = "";
|
||||
CBS cbs;
|
||||
|
||||
if (indent > 60)
|
||||
indent = 60;
|
||||
indent += 4;
|
||||
if (indent < 0)
|
||||
indent = 0;
|
||||
|
||||
CBS_init(&cbs, buf, buf_len);
|
||||
while (CBS_len(&cbs) > 0) {
|
||||
if (!CBS_get_u8(&cbs, &u8))
|
||||
return 0;
|
||||
if (octets++ % 15 == 0) {
|
||||
if (BIO_printf(bio, "%s%*s", nl, indent, "") < 0)
|
||||
return 0;
|
||||
nl = "\n";
|
||||
}
|
||||
if (CBS_len(&cbs) == 0)
|
||||
sep = "";
|
||||
if (BIO_printf(bio, "%02x%s", u8, sep) <= 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (BIO_printf(bio, "\n") <= 0)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
ecx_pub_print(BIO *bio, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx)
|
||||
{
|
||||
@ -309,8 +345,7 @@ ecx_pub_print(BIO *bio, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx)
|
||||
return 0;
|
||||
if (BIO_printf(bio, "%*spub:\n", indent, "") <= 0)
|
||||
return 0;
|
||||
if (ASN1_buf_print(bio, ecx_key->pub_key, ecx_key->pub_key_len,
|
||||
indent + 4) == 0)
|
||||
if (!ecx_buf_print(bio, ecx_key->pub_key, ecx_key->pub_key_len, indent))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
@ -422,13 +457,11 @@ ecx_priv_print(BIO *bio, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx)
|
||||
return 0;
|
||||
if (BIO_printf(bio, "%*spriv:\n", indent, "") <= 0)
|
||||
return 0;
|
||||
if (ASN1_buf_print(bio, ecx_key->priv_key, ecx_key->priv_key_len,
|
||||
indent + 4) == 0)
|
||||
if (!ecx_buf_print(bio, ecx_key->priv_key, ecx_key->priv_key_len, indent))
|
||||
return 0;
|
||||
if (BIO_printf(bio, "%*spub:\n", indent, "") <= 0)
|
||||
return 0;
|
||||
if (ASN1_buf_print(bio, ecx_key->pub_key, ecx_key->pub_key_len,
|
||||
indent + 4) == 0)
|
||||
if (!ecx_buf_print(bio, ecx_key->pub_key, ecx_key->pub_key_len, indent))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ecdh.c,v 1.5 2023/07/12 08:54:18 tb Exp $ */
|
||||
/* $OpenBSD: ecdh.c,v 1.6 2023/07/24 17:08:53 tb Exp $ */
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
*
|
||||
@ -176,7 +176,7 @@ ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh
|
||||
if ((group = EC_KEY_get0_group(ecdh)) == NULL)
|
||||
goto err;
|
||||
|
||||
if (!EC_POINT_is_on_curve(group, pub_key, ctx))
|
||||
if (EC_POINT_is_on_curve(group, pub_key, ctx) <= 0)
|
||||
goto err;
|
||||
|
||||
if ((point = EC_POINT_new(group)) == NULL) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: c_all.c,v 1.31 2023/07/07 19:37:53 beck Exp $ */
|
||||
/* $OpenBSD: c_all.c,v 1.32 2023/07/24 10:24:58 jsing Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -317,7 +317,6 @@ OpenSSL_add_all_digests(void)
|
||||
void
|
||||
OPENSSL_add_all_algorithms_noconf(void)
|
||||
{
|
||||
OPENSSL_cpuid_setup();
|
||||
OpenSSL_add_all_ciphers();
|
||||
OpenSSL_add_all_digests();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: names.c,v 1.19 2023/07/07 19:37:54 beck Exp $ */
|
||||
/* $OpenBSD: names.c,v 1.20 2023/07/22 18:12:55 tb Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -152,7 +152,6 @@ EVP_cleanup(void)
|
||||
obj_cleanup_defer = 0;
|
||||
OBJ_cleanup();
|
||||
}
|
||||
OBJ_sigid_free();
|
||||
}
|
||||
|
||||
struct doall_cipher {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: gostr341001_key.c,v 1.13 2023/07/08 14:30:44 beck Exp $ */
|
||||
/* $OpenBSD: gostr341001_key.c,v 1.14 2023/07/24 17:08:53 tb Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
|
||||
* Copyright (c) 2005-2006 Cryptocom LTD
|
||||
@ -132,7 +132,7 @@ GOST_KEY_check_key(const GOST_KEY *key)
|
||||
goto err;
|
||||
|
||||
/* testing whether the pub_key is on the elliptic curve */
|
||||
if (EC_POINT_is_on_curve(key->group, key->pub_key, ctx) == 0) {
|
||||
if (EC_POINT_is_on_curve(key->group, key->pub_key, ctx) <= 0) {
|
||||
GOSTerror(EC_R_POINT_IS_NOT_ON_CURVE);
|
||||
goto err;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: BIO_ctrl.3,v 1.23 2023/05/01 07:28:11 tb Exp $
|
||||
.\" $OpenBSD: BIO_ctrl.3,v 1.24 2023/07/26 20:01:04 tb Exp $
|
||||
.\" full merge up to: OpenSSL 24a535eaf Tue Sep 22 13:14:20 2020 +0100
|
||||
.\" selective merge up to: OpenSSL 0c5bc96f Tue Mar 15 13:57:22 2022 +0000
|
||||
.\"
|
||||
@ -66,7 +66,7 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd $Mdocdate: May 1 2023 $
|
||||
.Dd $Mdocdate: July 26 2023 $
|
||||
.Dt BIO_CTRL 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -430,12 +430,10 @@ They are documented in the following manual pages:
|
||||
.Bl -column BIO_CTRL_DGRAM_SET_RECV_TIMEOUT BIO_dgram_recv_timedout(3)\
|
||||
-offset 3n
|
||||
.It Fa cmd No constant Ta manual page
|
||||
.It Dv BIO_C_GET_EX_ARG Ta Xr BIO_f_asn1 3
|
||||
.It Dv BIO_C_GET_PREFIX Ta Xr BIO_asn1_get_prefix 3
|
||||
.It Dv BIO_C_GET_SUFFIX Ta Xr BIO_asn1_get_suffix 3
|
||||
.It Dv BIO_C_SET_EX_ARG Ta Xr BIO_f_asn1 3
|
||||
.It Dv BIO_C_SET_PREFIX Ta Xr BIO_asn1_set_prefix 3
|
||||
.It Dv BIO_C_SET_SUFFIX Ta Xr BIO_asn1_set_suffix 3
|
||||
.\" The following constants are intentionally undocumented because
|
||||
.\" BIO_f_asn1 has been removed from the public API.
|
||||
.\" .It Dv BIO_C_GET_EX_ARG Ta Xr BIO_f_asn1 3
|
||||
.\" .It Dv BIO_C_SET_EX_ARG Ta Xr BIO_f_asn1 3
|
||||
.It Dv BIO_CTRL_DGRAM_GET_FALLBACK_MTU Ta Xr BIO_dgram_set_peer 3
|
||||
.It Dv BIO_CTRL_DGRAM_GET_MTU Ta Xr BIO_dgram_set_peer 3
|
||||
.It Dv BIO_CTRL_DGRAM_GET_RECV_TIMEOUT Ta Xr BIO_dgram_recv_timedout 3
|
||||
|
@ -1,228 +0,0 @@
|
||||
.\" $OpenBSD: BIO_f_asn1.3,v 1.3 2023/05/01 07:28:11 tb Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
|
||||
.\"
|
||||
.\" Permission to use, copy, modify, and distribute this software for any
|
||||
.\" purpose with or without fee is hereby granted, provided that the above
|
||||
.\" copyright notice and this permission notice appear in all copies.
|
||||
.\"
|
||||
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
.\"
|
||||
.Dd $Mdocdate: May 1 2023 $
|
||||
.Dt BIO_F_ASN1 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm BIO_f_asn1 ,
|
||||
.Nm asn1_ps_func ,
|
||||
.Nm BIO_asn1_set_prefix ,
|
||||
.Nm BIO_asn1_get_prefix ,
|
||||
.Nm BIO_asn1_set_suffix ,
|
||||
.Nm BIO_asn1_get_suffix
|
||||
.Nd BER-encoding filter BIO
|
||||
.Sh SYNOPSIS
|
||||
.In openssl/asn1.h
|
||||
.Ft const BIO_METHOD *
|
||||
.Fn BIO_f_asn1 void
|
||||
.In openssl/bio.h
|
||||
.Ft typedef int
|
||||
.Fo asn1_ps_func
|
||||
.Fa "BIO *bio"
|
||||
.Fa "unsigned char **pbuf"
|
||||
.Fa "int *plen"
|
||||
.Fa "void *parg"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BIO_asn1_set_prefix
|
||||
.Fa "BIO *chain"
|
||||
.Fa "asn1_ps_func *prefix"
|
||||
.Fa "asn1_ps_func *prefix_free"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BIO_asn1_get_prefix
|
||||
.Fa "BIO *chain"
|
||||
.Fa "asn1_ps_func **pprefix"
|
||||
.Fa "asn1_ps_func **pprefix_free"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BIO_asn1_set_suffix
|
||||
.Fa "BIO *chain"
|
||||
.Fa "asn1_ps_func *suffix"
|
||||
.Fa "asn1_ps_func *suffix_free"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BIO_asn1_get_suffix
|
||||
.Fa "BIO *chain"
|
||||
.Fa "asn1_ps_func **psuffix"
|
||||
.Fa "asn1_ps_func **psuffix_free"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
.Fn BIO_f_asn1
|
||||
returns the
|
||||
.Qq asn1
|
||||
BIO method.
|
||||
BIOs created from it with
|
||||
.Xr BIO_new 3
|
||||
are filter BIOs intended to BER-encode data written to them
|
||||
and pass the encoded data on to the next BIO in the chain.
|
||||
Such BIOs operate as follows:
|
||||
.Bl -hang -width 1n
|
||||
.It Xr BIO_method_type 3
|
||||
returns
|
||||
.Dv BIO_TYPE_ASN1 .
|
||||
.It Xr BIO_method_name 3
|
||||
returns a pointer to the static string
|
||||
.Qq asn1 .
|
||||
.It Xr BIO_write 3
|
||||
writes the DER encoding of an ASN.1 OCTET STRING with the
|
||||
.Fa len
|
||||
content octets in
|
||||
.Fa buf
|
||||
to the next BIO in the chain.
|
||||
.Pp
|
||||
If a
|
||||
.Fa prefix
|
||||
function was installed with
|
||||
.Fn BIO_asn1_set_prefix ,
|
||||
that function is called before writing the object.
|
||||
It may for example produce additional output.
|
||||
If it fails, writing fails.
|
||||
.Pp
|
||||
If a
|
||||
.Fa prefix_free
|
||||
function was installed as well, that function is called
|
||||
after writing any output produced by
|
||||
.Fa prefix
|
||||
but before writing the object.
|
||||
Failure of
|
||||
.Fa prefix_free
|
||||
is silently ignored.
|
||||
.It Xr BIO_puts 3
|
||||
operates like
|
||||
.Xr BIO_write 3
|
||||
but uses the
|
||||
.Xr strlen 3
|
||||
of
|
||||
.Fa buf
|
||||
instead of a
|
||||
.Fa len
|
||||
argument.
|
||||
.It Xr BIO_flush 3
|
||||
calls the
|
||||
.Fa suffix
|
||||
callback function, if any.
|
||||
If that produces any output, it calls the
|
||||
.Fa suffix_free
|
||||
callback function, if any, silently ignoring failure.
|
||||
Finally, it calls
|
||||
.Xr BIO_flush 3
|
||||
on the next BIO in the chain.
|
||||
It fails if no data was previously written or if the
|
||||
.Fa suffix
|
||||
callback, writing, or
|
||||
.Xr BIO_flush 3
|
||||
on the next BIO fail.
|
||||
.It Xr BIO_ctrl 3
|
||||
with a
|
||||
.Fa cmd
|
||||
of
|
||||
.Dv BIO_C_SET_EX_ARG
|
||||
stores the pointer
|
||||
.Fa parg
|
||||
internally such that it will be passed to the
|
||||
.Fn asn1_ps_func
|
||||
callback functions.
|
||||
With a
|
||||
.Fa cmd
|
||||
of
|
||||
.Dv BIO_C_GET_EX_ARG ,
|
||||
it retrieves that pointer, storing it in
|
||||
.Pf * Fa parg .
|
||||
The commands
|
||||
.Dv BIO_C_SET_PREFIX ,
|
||||
.Dv BIO_C_GET_PREFIX ,
|
||||
.Dv BIO_C_SET_SUFFIX ,
|
||||
.Dv BIO_C_GET_SUFFIX ,
|
||||
and
|
||||
.Dv BIO_CTRL_FLUSH
|
||||
are used internally to implement
|
||||
.Fn BIO_asn1_set_prefix ,
|
||||
.Fn BIO_asn1_get_prefix ,
|
||||
.Fn BIO_asn1_set_suffix ,
|
||||
.Fn BIO_asn1_get_suffix
|
||||
and
|
||||
.Xr BIO_flush 3
|
||||
and are not intended for use by application programs.
|
||||
Other commands are merely forwarded to the next BIO in the chain.
|
||||
.It Xo
|
||||
.Xr BIO_read 3 ,
|
||||
.Xr BIO_gets 3 ,
|
||||
and
|
||||
.Xr BIO_callback_ctrl 3
|
||||
.Xc
|
||||
merely call the same function on the next BIO in the chain.
|
||||
.El
|
||||
.Pp
|
||||
If the above description of a function mentions the next BIO in the
|
||||
chain, that function fails if the asn1 BIO is the last BIO in the chain.
|
||||
.Pp
|
||||
.Fn BIO_asn1_set_prefix
|
||||
and
|
||||
.Fn BIO_asn1_get_prefix
|
||||
install and retrieve the
|
||||
.Fa prefix
|
||||
and
|
||||
.Fa prefix_free
|
||||
callback functions in and from the first asn1 BIO in the given
|
||||
.Fa chain .
|
||||
Similarly,
|
||||
.Fn BIO_asn1_set_suffix
|
||||
and
|
||||
.Fn BIO_asn1_get_suffix
|
||||
install and retrieve the
|
||||
.Fa suffix
|
||||
and
|
||||
.Fa suffix_free
|
||||
callback functions.
|
||||
Passing a
|
||||
.Dv NULL
|
||||
pointer for any of the
|
||||
.Fn asn1_ps_func
|
||||
arguments disables that particular callback.
|
||||
.Sh RETURN VALUES
|
||||
.Fn BIO_f_asn1
|
||||
always returns a pointer to a static built-in object.
|
||||
.Pp
|
||||
Functions of the type
|
||||
.Fn asn1_ps_func
|
||||
are supposed to return 1 on success or 0 on failure.
|
||||
.Pp
|
||||
.Fn BIO_asn1_set_prefix ,
|
||||
.Fn BIO_asn1_get_prefix ,
|
||||
.Fn BIO_asn1_set_suffix ,
|
||||
and
|
||||
.Fn BIO_asn1_get_suffix
|
||||
return 1 on success or 0 if
|
||||
.Fa chain
|
||||
is a
|
||||
.Dv NULL
|
||||
pointer or does not contain any asn1 BIO.
|
||||
They may return \-2 if a BIO is encountered in the
|
||||
.Fa chain
|
||||
that is not properly initialized.
|
||||
.Sh SEE ALSO
|
||||
.Xr ASN1_put_object 3 ,
|
||||
.Xr BIO_ctrl 3 ,
|
||||
.Xr BIO_new 3 ,
|
||||
.Xr BIO_next 3 ,
|
||||
.Xr BIO_write 3 ,
|
||||
.Xr i2d_ASN1_OCTET_STRING 3
|
||||
.Sh HISTORY
|
||||
These functions first appeared in OpenSSL 1.0.0
|
||||
and have been available since
|
||||
.Ox 4.9 .
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: BIO_find_type.3,v 1.11 2023/04/11 15:35:31 schwarze Exp $
|
||||
.\" $OpenBSD: BIO_find_type.3,v 1.12 2023/07/26 20:01:04 tb Exp $
|
||||
.\" full merge up to: OpenSSL 1cb7eff4 Sep 10 13:56:40 2019 +0100
|
||||
.\"
|
||||
.\" This file is a derived work.
|
||||
@ -65,7 +65,7 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd $Mdocdate: April 11 2023 $
|
||||
.Dd $Mdocdate: July 26 2023 $
|
||||
.Dt BIO_FIND_TYPE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -180,7 +180,9 @@ and
|
||||
set in their type constant.
|
||||
.Bl -column BIO_TYPE_NULL_FILTER "datagram socket" BIO_s_datagram(3)
|
||||
.It Fa type No constant Ta Em name No string Ta Vt BIO_METHOD
|
||||
.It Dv BIO_TYPE_ASN1 Ta asn1 Ta Xr BIO_f_asn1 3
|
||||
.\" BIO_TYPE_ASN1 is intentionally undocumented because BIO_f_asn1 was
|
||||
.\" removed from the public API.
|
||||
.\" .It Dv BIO_TYPE_ASN1 Ta asn1 Ta Xr BIO_f_asn1 3
|
||||
.It Dv BIO_TYPE_BASE64 Ta base64 encoding Ta Xr BIO_f_base64 3
|
||||
.It Dv BIO_TYPE_BUFFER Ta buffer Ta Xr BIO_f_buffer 3
|
||||
.It Dv BIO_TYPE_CIPHER Ta cipher Ta Xr BIO_f_cipher 3
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: BIO_new.3,v 1.27 2023/07/21 04:50:47 tb Exp $
|
||||
.\" $OpenBSD: BIO_new.3,v 1.28 2023/07/26 20:01:04 tb Exp $
|
||||
.\" full merge up to:
|
||||
.\" OpenSSL man3/BIO_new.pod fb46be03 Feb 26 11:51:31 2016 +0000
|
||||
.\" OpenSSL man7/bio.pod 631c37be Dec 12 16:56:50 2017 +0100
|
||||
@ -52,7 +52,7 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd $Mdocdate: July 21 2023 $
|
||||
.Dd $Mdocdate: July 26 2023 $
|
||||
.Dt BIO_NEW 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -232,7 +232,6 @@ Create a memory BIO:
|
||||
.Xr BIO_ctrl 3 ,
|
||||
.Xr BIO_dump 3 ,
|
||||
.Xr BIO_dup_chain 3 ,
|
||||
.Xr BIO_f_asn1 3 ,
|
||||
.Xr BIO_f_base64 3 ,
|
||||
.Xr BIO_f_buffer 3 ,
|
||||
.Xr BIO_f_cipher 3 ,
|
||||
|
@ -1,317 +0,0 @@
|
||||
.\" $OpenBSD: BN_BLINDING_new.3,v 1.12 2023/04/25 20:07:55 tb Exp $
|
||||
.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
|
||||
.\"
|
||||
.\" This file was written by Nils Larsch <nils@openssl.org>.
|
||||
.\" Copyright (c) 2005, 2008, 2013, 2015 The OpenSSL Project.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\"
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\"
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in
|
||||
.\" the documentation and/or other materials provided with the
|
||||
.\" distribution.
|
||||
.\"
|
||||
.\" 3. All advertising materials mentioning features or use of this
|
||||
.\" software must display the following acknowledgment:
|
||||
.\" "This product includes software developed by the OpenSSL Project
|
||||
.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
.\"
|
||||
.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
.\" endorse or promote products derived from this software without
|
||||
.\" prior written permission. For written permission, please contact
|
||||
.\" openssl-core@openssl.org.
|
||||
.\"
|
||||
.\" 5. Products derived from this software may not be called "OpenSSL"
|
||||
.\" nor may "OpenSSL" appear in their names without prior written
|
||||
.\" permission of the OpenSSL Project.
|
||||
.\"
|
||||
.\" 6. Redistributions of any form whatsoever must retain the following
|
||||
.\" acknowledgment:
|
||||
.\" "This product includes software developed by the OpenSSL Project
|
||||
.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd $Mdocdate: April 25 2023 $
|
||||
.Dt BN_BLINDING_NEW 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm BN_BLINDING_new ,
|
||||
.Nm BN_BLINDING_free ,
|
||||
.Nm BN_BLINDING_update ,
|
||||
.Nm BN_BLINDING_convert ,
|
||||
.Nm BN_BLINDING_invert ,
|
||||
.Nm BN_BLINDING_convert_ex ,
|
||||
.Nm BN_BLINDING_invert_ex ,
|
||||
.Nm BN_BLINDING_thread_id ,
|
||||
.Nm BN_BLINDING_get_flags ,
|
||||
.Nm BN_BLINDING_set_flags ,
|
||||
.Nm BN_BLINDING_create_param
|
||||
.Nd blinding related BIGNUM functions
|
||||
.Sh SYNOPSIS
|
||||
.In openssl/bn.h
|
||||
.Ft BN_BLINDING *
|
||||
.Fo BN_BLINDING_new
|
||||
.Fa "const BIGNUM *A"
|
||||
.Fa "const BIGNUM *Ai"
|
||||
.Fa "BIGNUM *mod"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo BN_BLINDING_free
|
||||
.Fa "BN_BLINDING *b"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_BLINDING_update
|
||||
.Fa "BN_BLINDING *b"
|
||||
.Fa "BN_CTX *ctx"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_BLINDING_convert
|
||||
.Fa "BIGNUM *n"
|
||||
.Fa "BN_BLINDING *b"
|
||||
.Fa "BN_CTX *ctx"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_BLINDING_invert
|
||||
.Fa "BIGNUM *n"
|
||||
.Fa "BN_BLINDING *b"
|
||||
.Fa "BN_CTX *ctx"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_BLINDING_convert_ex
|
||||
.Fa "BIGNUM *n"
|
||||
.Fa "BIGNUM *r"
|
||||
.Fa "BN_BLINDING *b"
|
||||
.Fa "BN_CTX *ctx"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_BLINDING_invert_ex
|
||||
.Fa "BIGNUM *n"
|
||||
.Fa "const BIGNUM *r"
|
||||
.Fa "BN_BLINDING *b"
|
||||
.Fa "BN_CTX *ctx"
|
||||
.Fc
|
||||
.Ft CRYPTO_THREADID *
|
||||
.Fo BN_BLINDING_thread_id
|
||||
.Fa "BN_BLINDING *"
|
||||
.Fc
|
||||
.Ft unsigned long
|
||||
.Fo BN_BLINDING_get_flags
|
||||
.Fa "const BN_BLINDING *"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo BN_BLINDING_set_flags
|
||||
.Fa "BN_BLINDING *"
|
||||
.Fa "unsigned long"
|
||||
.Fc
|
||||
.Ft BN_BLINDING *
|
||||
.Fo BN_BLINDING_create_param
|
||||
.Fa "BN_BLINDING *b"
|
||||
.Fa "const BIGNUM *e"
|
||||
.Fa "BIGNUM *m"
|
||||
.Fa "BN_CTX *ctx"
|
||||
.Fa "int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)"
|
||||
.Fa "BN_MONT_CTX *m_ctx"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
.Fn BN_BLINDING_new
|
||||
allocates a new
|
||||
.Vt BN_BLINDING
|
||||
structure and copies the
|
||||
.Fa A
|
||||
and
|
||||
.Fa \&Ai
|
||||
values into the newly created
|
||||
.Vt BN_BLINDING
|
||||
object.
|
||||
.Pp
|
||||
.Fn BN_BLINDING_free
|
||||
frees the
|
||||
.Vt BN_BLINDING
|
||||
structure.
|
||||
If
|
||||
.Fa b
|
||||
is a
|
||||
.Dv NULL
|
||||
pointer, no action occurs.
|
||||
.Pp
|
||||
.Fn BN_BLINDING_update
|
||||
updates the
|
||||
.Vt BN_BLINDING
|
||||
parameters by squaring the
|
||||
.Fa A
|
||||
and
|
||||
.Fa \&Ai
|
||||
or, after a specific number of uses and if the necessary parameters are
|
||||
set, by re-creating the blinding parameters.
|
||||
.Pp
|
||||
.Fn BN_BLINDING_convert_ex
|
||||
multiplies
|
||||
.Fa n
|
||||
with the blinding factor
|
||||
.Fa A .
|
||||
If
|
||||
.Fa r
|
||||
is not
|
||||
.Dv NULL ,
|
||||
a copy of the inverse blinding factor
|
||||
.Fa \&Ai
|
||||
will be returned in
|
||||
.Fa r
|
||||
(this is useful if an
|
||||
.Vt RSA
|
||||
object is shared among several threads).
|
||||
.Fn BN_BLINDING_invert_ex
|
||||
multiplies
|
||||
.Fa n
|
||||
with the inverse blinding factor
|
||||
.Fa \&Ai .
|
||||
If
|
||||
.Fa r
|
||||
is not
|
||||
.Dv NULL ,
|
||||
it will be used as the inverse blinding.
|
||||
.Pp
|
||||
.Fn BN_BLINDING_convert
|
||||
and
|
||||
.Fn BN_BLINDING_invert
|
||||
are wrapper functions for
|
||||
.Fn BN_BLINDING_convert_ex
|
||||
and
|
||||
.Fn BN_BLINDING_invert_ex
|
||||
with
|
||||
.Fa r
|
||||
set to
|
||||
.Dv NULL .
|
||||
.Pp
|
||||
.Fn BN_BLINDING_thread_id
|
||||
provides access to the
|
||||
.Vt CRYPTO_THREADID
|
||||
object within the
|
||||
.Vt BN_BLINDING
|
||||
structure.
|
||||
This is to help users provide proper locking if needed for
|
||||
multi-threaded use.
|
||||
The thread ID object of a newly allocated
|
||||
.Vt BN_BLINDING
|
||||
structure is initialised to the thread ID in which
|
||||
.Fn BN_BLINDING_new
|
||||
was called.
|
||||
.Pp
|
||||
.Fn BN_BLINDING_get_flags
|
||||
returns the
|
||||
.Dv BN_BLINDING_*
|
||||
flags.
|
||||
Currently there are two supported flags:
|
||||
.Dv BN_BLINDING_NO_UPDATE
|
||||
and
|
||||
.Dv BN_BLINDING_NO_RECREATE .
|
||||
.Dv BN_BLINDING_NO_UPDATE
|
||||
inhibits the automatic update of the
|
||||
.Vt BN_BLINDING
|
||||
parameters after each use and
|
||||
.Dv BN_BLINDING_NO_RECREATE
|
||||
inhibits the automatic re-creation of the
|
||||
.Vt BN_BLINDING
|
||||
parameters after a fixed number of uses (currently 32).
|
||||
In newly allocated
|
||||
.Vt BN_BLINDING
|
||||
objects no flags are set.
|
||||
.Fn BN_BLINDING_set_flags
|
||||
sets the
|
||||
.Dv BN_BLINDING_*
|
||||
parameters flags.
|
||||
.Pp
|
||||
.Fn BN_BLINDING_create_param
|
||||
creates new
|
||||
.Vt BN_BLINDING
|
||||
parameters using the exponent
|
||||
.Fa e
|
||||
and the modulus
|
||||
.Fa m .
|
||||
.Fa bn_mod_exp
|
||||
and
|
||||
.Fa m_ctx
|
||||
can be used to pass special functions for exponentiation (normally
|
||||
.Xr BN_mod_exp 3
|
||||
and
|
||||
.Vt BN_MONT_CTX ) .
|
||||
.Sh RETURN VALUES
|
||||
.Fn BN_BLINDING_new
|
||||
returns the newly allocated
|
||||
.Vt BN_BLINDING
|
||||
structure or
|
||||
.Dv NULL
|
||||
in case of an error.
|
||||
.Pp
|
||||
.Fn BN_BLINDING_update ,
|
||||
.Fn BN_BLINDING_convert ,
|
||||
.Fn BN_BLINDING_invert ,
|
||||
.Fn BN_BLINDING_convert_ex
|
||||
and
|
||||
.Fn BN_BLINDING_invert_ex
|
||||
return 1 on success and 0 if an error occurred.
|
||||
.Pp
|
||||
.Fn BN_BLINDING_thread_id
|
||||
returns a pointer to the thread ID object within a
|
||||
.Vt BN_BLINDING
|
||||
object.
|
||||
.Pp
|
||||
.Fn BN_BLINDING_get_flags
|
||||
returns the currently set
|
||||
.Dv BN_BLINDING_*
|
||||
flags (an
|
||||
.Vt unsigned long
|
||||
value).
|
||||
.Pp
|
||||
.Fn BN_BLINDING_create_param
|
||||
returns the newly created
|
||||
.Vt BN_BLINDING
|
||||
parameters or
|
||||
.Dv NULL
|
||||
on error.
|
||||
.Sh SEE ALSO
|
||||
.Xr BN_new 3 ,
|
||||
.Xr RSA_blinding_on 3
|
||||
.Sh HISTORY
|
||||
.Fn BN_BLINDING_new ,
|
||||
.Fn BN_BLINDING_free ,
|
||||
.Fn BN_BLINDING_update ,
|
||||
.Fn BN_BLINDING_convert ,
|
||||
and
|
||||
.Fn BN_BLINDING_invert
|
||||
first appeared in SSLeay 0.9.0 and have been available since
|
||||
.Ox 2.4 .
|
||||
.Pp
|
||||
.Fn BN_BLINDING_convert_ex ,
|
||||
.Fn BN_BLINDIND_invert_ex ,
|
||||
.Fn BN_BLINDING_get_flags ,
|
||||
.Fn BN_BLINDING_set_flags ,
|
||||
and
|
||||
.Fn BN_BLINDING_create_param
|
||||
first appeared in OpenSSL 0.9.8 and have been available since
|
||||
.Ox 4.5 .
|
||||
.Pp
|
||||
.Fn BN_BLINDING_thread_id
|
||||
first appeared in OpenSSL 1.0.0 and has been available since
|
||||
.Ox 4.9 .
|
||||
.Sh AUTHORS
|
||||
.An Nils Larsch Aq Mt nils@openssl.org
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: BN_new.3,v 1.30 2023/07/21 05:04:48 tb Exp $
|
||||
.\" $OpenBSD: BN_new.3,v 1.31 2023/07/26 20:08:59 tb Exp $
|
||||
.\" full merge up to: OpenSSL man3/BN_new 2457c19d Mar 6 08:43:36 2004 +0000
|
||||
.\" selective merge up to: man3/BN_new 681acb31 Sep 29 13:10:34 2017 +0200
|
||||
.\" full merge up to: OpenSSL man7/bn 05ea606a May 20 20:52:46 2016 -0400
|
||||
@ -50,7 +50,7 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd $Mdocdate: July 21 2023 $
|
||||
.Dd $Mdocdate: July 26 2023 $
|
||||
.Dt BN_NEW 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -135,7 +135,6 @@ and sets an error code that can be obtained by
|
||||
.Sh SEE ALSO
|
||||
.Xr BN_add 3 ,
|
||||
.Xr BN_add_word 3 ,
|
||||
.Xr BN_BLINDING_new 3 ,
|
||||
.Xr BN_bn2bin 3 ,
|
||||
.Xr BN_cmp 3 ,
|
||||
.Xr BN_copy 3 ,
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: BUF_MEM_new.3,v 1.16 2019/06/06 01:06:58 schwarze Exp $
|
||||
.\" $OpenBSD: BUF_MEM_new.3,v 1.18 2023/07/27 06:20:45 tb Exp $
|
||||
.\" OpenSSL doc/crypto/buffer.pod 18edda0f Sep 20 03:28:54 2000 +0000
|
||||
.\" not merged: 74924dcb, 58e3457a, 21b0fa91, 7644a9ae
|
||||
.\" OpenSSL doc/crypto/BUF_MEM_new.pod 53934822 Jun 9 16:39:19 2016 -0400
|
||||
@ -52,16 +52,14 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd $Mdocdate: June 6 2019 $
|
||||
.Dd $Mdocdate: July 27 2023 $
|
||||
.Dt BUF_MEM_NEW 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm BUF_MEM_new ,
|
||||
.Nm BUF_MEM_free ,
|
||||
.Nm BUF_MEM_grow ,
|
||||
.Nm BUF_MEM_grow_clean ,
|
||||
.Nm BUF_reverse ,
|
||||
.Nm BUF_strdup
|
||||
.Nm BUF_MEM_grow_clean
|
||||
.Nd simple character arrays structure
|
||||
.Sh SYNOPSIS
|
||||
.In openssl/buffer.h
|
||||
@ -83,16 +81,6 @@
|
||||
.Fa "BUF_MEM *str"
|
||||
.Fa "size_t len"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo BUF_reverse
|
||||
.Fa "unsigned char *out"
|
||||
.Fa "const unsigned char *in"
|
||||
.Fa "size_t len"
|
||||
.Fc
|
||||
.Ft char *
|
||||
.Fo BUF_strdup
|
||||
.Fa "const char *str"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
The buffer library handles simple character arrays.
|
||||
Buffers are used for various purposes in the library, most notably
|
||||
@ -138,40 +126,6 @@ Any data already in the buffer is preserved if it increases in size.
|
||||
is similar to
|
||||
.Fn BUF_MEM_grow ,
|
||||
but it sets any freed or additionally allocated memory to zero.
|
||||
.Pp
|
||||
.Fn BUF_reverse
|
||||
reverses
|
||||
.Fa len
|
||||
bytes at
|
||||
.Fa in
|
||||
into
|
||||
.Fa out .
|
||||
If
|
||||
.Fa in
|
||||
is
|
||||
.Dv NULL ,
|
||||
.Fa out
|
||||
is reversed in place.
|
||||
.Pp
|
||||
.Fn BUF_strdup
|
||||
copies a NUL terminated string into a block of allocated memory and
|
||||
returns a pointer to the allocated block.
|
||||
Unlike the system
|
||||
.Xr strdup 3
|
||||
function,
|
||||
.Fn BUF_strdup
|
||||
will accept a
|
||||
.Dv NULL
|
||||
argument and will return
|
||||
.Dv NULL
|
||||
in that case.
|
||||
Its use in new programs is discouraged.
|
||||
.Pp
|
||||
The memory allocated from
|
||||
.Fn BUF_strdup
|
||||
should be freed up using the
|
||||
.Xr free 3
|
||||
function.
|
||||
.Sh RETURN VALUES
|
||||
.Fn BUF_MEM_new
|
||||
returns the buffer or
|
||||
@ -192,15 +146,9 @@ return zero on error or the new size (i.e.\&
|
||||
and
|
||||
.Fn BUF_MEM_grow
|
||||
first appeared in SSLeay 0.6.0.
|
||||
.Fn BUF_strdup
|
||||
first appeared in SSLeay 0.8.0.
|
||||
All these functions have been available since
|
||||
.Ox 2.4 .
|
||||
.Pp
|
||||
.Fn BUF_MEM_grow_clean
|
||||
first appeared in OpenSSL 0.9.7 and has been available since
|
||||
.Ox 3.2 .
|
||||
.Pp
|
||||
.Fn BUF_reverse
|
||||
first appeared in OpenSSL 1.0.0 and has been available since
|
||||
.Ox 4.9 .
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: CMS_get0_SignerInfos.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $
|
||||
.\" $OpenBSD: CMS_get0_SignerInfos.3,v 1.8 2023/07/26 19:30:43 tb Exp $
|
||||
.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
|
||||
.\"
|
||||
.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
|
||||
@ -48,11 +48,12 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd $Mdocdate: November 2 2019 $
|
||||
.Dd $Mdocdate: July 26 2023 $
|
||||
.Dt CMS_GET0_SIGNERINFOS 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm CMS_get0_SignerInfos ,
|
||||
.Nm CMS_SignerInfo_get_version ,
|
||||
.Nm CMS_SignerInfo_get0_signer_id ,
|
||||
.Nm CMS_SignerInfo_get0_signature ,
|
||||
.Nm CMS_SignerInfo_cert_cmp ,
|
||||
@ -65,6 +66,11 @@
|
||||
.Fa "CMS_ContentInfo *cms"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo CMS_SignerInfo_get_version
|
||||
.Fa "CMS_SignerInfo *si"
|
||||
.Fa "long *version"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo CMS_SignerInfo_get0_signer_id
|
||||
.Fa "CMS_SignerInfo *si"
|
||||
.Fa "ASN1_OCTET_STRING **keyid"
|
||||
@ -94,6 +100,14 @@ structures associated with the
|
||||
structure
|
||||
.Fa cms .
|
||||
.Pp
|
||||
.Fn CMS_SignerInfo_get_version
|
||||
sets
|
||||
.Pf * Fa version
|
||||
to the syntax version number of the
|
||||
.Vt SignerInfo
|
||||
structure
|
||||
.Fa si .
|
||||
.Pp
|
||||
.Fn CMS_SignerInfo_get0_signer_id
|
||||
retrieves the certificate
|
||||
.Vt SignerIdentifier
|
||||
@ -157,6 +171,9 @@ if there are no signers or if
|
||||
is not of the type
|
||||
.Vt SignedData .
|
||||
.Pp
|
||||
.Fn CMS_SignerInfo_get_version
|
||||
always succeeds and returns 1.
|
||||
.Pp
|
||||
.Fn CMS_SignerInfo_get0_signer_id
|
||||
returns 1 for success or 0 for failure.
|
||||
.Pp
|
||||
@ -190,3 +207,7 @@ first appeared in OpenSSL 0.9.8h and
|
||||
in OpenSSL 1.0.2.
|
||||
These functions have been available since
|
||||
.Ox 6.7 .
|
||||
.Pp
|
||||
.Fn CMS_SignerInfo_get_version
|
||||
first appeared in
|
||||
.Ox 7.4 .
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: CMS_get0_type.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $
|
||||
.\" $OpenBSD: CMS_get0_type.3,v 1.9 2023/07/27 05:31:28 tb Exp $
|
||||
.\" full merge up to: OpenSSL 72a7a702 Feb 26 14:05:09 2019 +0000
|
||||
.\"
|
||||
.\" This file is a derived work.
|
||||
@ -65,11 +65,12 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd $Mdocdate: November 2 2019 $
|
||||
.Dd $Mdocdate: July 27 2023 $
|
||||
.Dt CMS_GET0_TYPE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm CMS_get0_type ,
|
||||
.Nm CMS_get_version ,
|
||||
.Nm CMS_set1_eContentType ,
|
||||
.Nm CMS_get0_eContentType ,
|
||||
.Nm CMS_get0_content
|
||||
@ -81,6 +82,11 @@
|
||||
.Fa "const CMS_ContentInfo *cms"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo CMS_get_version
|
||||
.Fa "const CMS_ContentInfo *cms"
|
||||
.Fa "long *version"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo CMS_set1_eContentType
|
||||
.Fa "CMS_ContentInfo *cms"
|
||||
.Fa "const ASN1_OBJECT *oid"
|
||||
@ -149,6 +155,21 @@ copies the supplied
|
||||
.Fa oid ,
|
||||
so it should be freed up after use.
|
||||
.Pp
|
||||
.Fn CMS_get_version
|
||||
sets
|
||||
.Pf * Fa version
|
||||
to the syntax version number of the
|
||||
.Vt ContentInfo
|
||||
structure
|
||||
.Fa cms .
|
||||
The version is a number between 0 and 5 and is defined for all the
|
||||
above content types except for arbitrary data.
|
||||
For arbitrary data and unsupported content types
|
||||
.Fn CMS_get_version
|
||||
fails and the content of
|
||||
.Pf * Fa version
|
||||
is unspecified.
|
||||
.Pp
|
||||
.Fn CMS_get0_eContentType
|
||||
returns the type of the embedded content.
|
||||
.Pp
|
||||
@ -176,6 +197,9 @@ return internal pointers to
|
||||
.Vt OBJECT IDENTIFIER
|
||||
structures.
|
||||
.Pp
|
||||
.Fn CMS_get_version
|
||||
returns 1 on success and 0 on failure.
|
||||
.Pp
|
||||
.Fn CMS_get0_content
|
||||
returns an internal pointer to the storage location where the pointer
|
||||
to the embedded content is stored.
|
||||
@ -196,3 +220,7 @@ RFC 3274: Compressed Data Content Type for Cryptographic Message Syntax (CMS)
|
||||
These functions first appeared in OpenSSL 0.9.8h
|
||||
and have been available since
|
||||
.Ox 6.7 .
|
||||
.Pp
|
||||
.Fn CMS_get_version
|
||||
first appeared in
|
||||
.Ox 7.4 .
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: ERR.3,v 1.10 2022/09/06 10:22:31 kn Exp $
|
||||
.\" $OpenBSD: ERR.3,v 1.11 2023/07/26 20:15:51 tb Exp $
|
||||
.\" OpenSSL 186bb907 Apr 13 11:05:13 2015 -0700
|
||||
.\"
|
||||
.\" This file was written by Ulf Moeller <ulf@openssl.org> and
|
||||
@ -49,7 +49,7 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd $Mdocdate: September 6 2022 $
|
||||
.Dd $Mdocdate: July 26 2023 $
|
||||
.Dt ERR 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -136,10 +136,6 @@ When more error codes are added, the old ones are overwritten, on the
|
||||
assumption that the most recent errors are most important.
|
||||
.Pp
|
||||
Error strings are also stored in a hash table.
|
||||
The hash tables can be obtained by calling
|
||||
.Fn ERR_get_err_state_table
|
||||
and
|
||||
.Fn ERR_get_string_table .
|
||||
.Sh SEE ALSO
|
||||
.Xr crypto 3 ,
|
||||
.Xr ERR_asprintf_error_data 3 ,
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.255 2023/07/21 04:50:47 tb Exp $
|
||||
# $OpenBSD: Makefile,v 1.258 2023/07/26 20:08:59 tb Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
@ -37,7 +37,6 @@ MAN= \
|
||||
BIO_ctrl.3 \
|
||||
BIO_dump.3 \
|
||||
BIO_dup_chain.3 \
|
||||
BIO_f_asn1.3 \
|
||||
BIO_f_base64.3 \
|
||||
BIO_f_buffer.3 \
|
||||
BIO_f_cipher.3 \
|
||||
@ -63,7 +62,6 @@ MAN= \
|
||||
BIO_s_socket.3 \
|
||||
BIO_set_callback.3 \
|
||||
BIO_should_retry.3 \
|
||||
BN_BLINDING_new.3 \
|
||||
BN_CTX_new.3 \
|
||||
BN_CTX_start.3 \
|
||||
BN_add.3 \
|
||||
@ -214,8 +212,8 @@ MAN= \
|
||||
MD5.3 \
|
||||
NAME_CONSTRAINTS_new.3 \
|
||||
OBJ_NAME_add.3 \
|
||||
OBJ_add_sigid.3 \
|
||||
OBJ_create.3 \
|
||||
OBJ_find_sigid_algs.3 \
|
||||
OBJ_nid2obj.3 \
|
||||
OCSP_CRLID_new.3 \
|
||||
OCSP_REQUEST_new.3 \
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: OBJ_add_sigid.3,v 1.2 2023/07/21 05:02:53 tb Exp $
|
||||
.\" $OpenBSD: OBJ_find_sigid_algs.3,v 1.1 2023/07/22 06:35:26 tb Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
|
||||
.\"
|
||||
@ -14,8 +14,8 @@
|
||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
.\"
|
||||
.Dd $Mdocdate: July 21 2023 $
|
||||
.Dt OBJ_ADD_SIGID 3
|
||||
.Dd $Mdocdate: July 22 2023 $
|
||||
.Dt OBJ_FIND_SIGID_ALGS 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm OBJ_find_sigid_algs ,
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: RSA_blinding_on.3,v 1.6 2019/06/06 01:06:59 schwarze Exp $
|
||||
.\" $OpenBSD: RSA_blinding_on.3,v 1.7 2023/07/26 20:08:59 tb Exp $
|
||||
.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
|
||||
.\"
|
||||
.\" This file was written by Ulf Moeller <ulf@openssl.org>.
|
||||
@ -48,7 +48,7 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd $Mdocdate: June 6 2019 $
|
||||
.Dd $Mdocdate: July 26 2023 $
|
||||
.Dt RSA_BLINDING_ON 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -88,7 +88,6 @@ turns blinding off and frees the memory used for the blinding factor.
|
||||
.Fn RSA_blinding_on
|
||||
returns 1 on success, and 0 if an error occurred.
|
||||
.Sh SEE ALSO
|
||||
.Xr BN_BLINDING_new 3 ,
|
||||
.Xr RSA_new 3
|
||||
.Sh HISTORY
|
||||
.Fn RSA_blinding_on
|
||||
|
@ -1,241 +1,325 @@
|
||||
/* $OpenBSD: obj_xref.c,v 1.9 2023/07/08 12:27:51 beck Exp $ */
|
||||
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
|
||||
* project 2006.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
/* $OpenBSD: obj_xref.c,v 1.12 2023/07/22 19:08:03 tb Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <openssl/objects.h>
|
||||
#include "obj_xref.h"
|
||||
|
||||
DECLARE_STACK_OF(nid_triple)
|
||||
STACK_OF(nid_triple) *sig_app, *sigx_app;
|
||||
/*
|
||||
* Map between signature nids and pairs of (hash, pkey) nids. If the hash nid
|
||||
* is NID_undef, this indicates to ASN1_item_{sign,verify}() that the pkey's
|
||||
* ASN.1 method needs to handle algorithm identifiers and part of the message
|
||||
* digest.
|
||||
*/
|
||||
|
||||
static int
|
||||
sig_cmp(const nid_triple *a, const nid_triple *b)
|
||||
{
|
||||
return a->sign_id - b->sign_id;
|
||||
}
|
||||
static const struct {
|
||||
int sign_nid;
|
||||
int hash_nid;
|
||||
int pkey_nid;
|
||||
} nid_triple[] = {
|
||||
{
|
||||
.sign_nid = NID_md2WithRSAEncryption,
|
||||
.hash_nid = NID_md2,
|
||||
.pkey_nid = NID_rsaEncryption,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_md5WithRSAEncryption,
|
||||
.hash_nid = NID_md5,
|
||||
.pkey_nid = NID_rsaEncryption,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_shaWithRSAEncryption,
|
||||
.hash_nid = NID_sha,
|
||||
.pkey_nid = NID_rsaEncryption,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_sha1WithRSAEncryption,
|
||||
.hash_nid = NID_sha1,
|
||||
.pkey_nid = NID_rsaEncryption,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_dsaWithSHA,
|
||||
.hash_nid = NID_sha,
|
||||
.pkey_nid = NID_dsa,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_dsaWithSHA1_2,
|
||||
.hash_nid = NID_sha1,
|
||||
.pkey_nid = NID_dsa_2,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_mdc2WithRSA,
|
||||
.hash_nid = NID_mdc2,
|
||||
.pkey_nid = NID_rsaEncryption,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_md5WithRSA,
|
||||
.hash_nid = NID_md5,
|
||||
.pkey_nid = NID_rsa,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_dsaWithSHA1,
|
||||
.hash_nid = NID_sha1,
|
||||
.pkey_nid = NID_dsa,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_sha1WithRSA,
|
||||
.hash_nid = NID_sha1,
|
||||
.pkey_nid = NID_rsa,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_ripemd160WithRSA,
|
||||
.hash_nid = NID_ripemd160,
|
||||
.pkey_nid = NID_rsaEncryption,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_md4WithRSAEncryption,
|
||||
.hash_nid = NID_md4,
|
||||
.pkey_nid = NID_rsaEncryption,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_ecdsa_with_SHA1,
|
||||
.hash_nid = NID_sha1,
|
||||
.pkey_nid = NID_X9_62_id_ecPublicKey,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_sha256WithRSAEncryption,
|
||||
.hash_nid = NID_sha256,
|
||||
.pkey_nid = NID_rsaEncryption,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_sha384WithRSAEncryption,
|
||||
.hash_nid = NID_sha384,
|
||||
.pkey_nid = NID_rsaEncryption,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_sha512WithRSAEncryption,
|
||||
.hash_nid = NID_sha512,
|
||||
.pkey_nid = NID_rsaEncryption,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_sha224WithRSAEncryption,
|
||||
.hash_nid = NID_sha224,
|
||||
.pkey_nid = NID_rsaEncryption,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_ecdsa_with_Recommended,
|
||||
.hash_nid = NID_undef,
|
||||
.pkey_nid = NID_X9_62_id_ecPublicKey,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_ecdsa_with_Specified,
|
||||
.hash_nid = NID_undef,
|
||||
.pkey_nid = NID_X9_62_id_ecPublicKey,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_ecdsa_with_SHA224,
|
||||
.hash_nid = NID_sha224,
|
||||
.pkey_nid = NID_X9_62_id_ecPublicKey,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_ecdsa_with_SHA256,
|
||||
.hash_nid = NID_sha256,
|
||||
.pkey_nid = NID_X9_62_id_ecPublicKey,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_ecdsa_with_SHA384,
|
||||
.hash_nid = NID_sha384,
|
||||
.pkey_nid = NID_X9_62_id_ecPublicKey,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_ecdsa_with_SHA512,
|
||||
.hash_nid = NID_sha512,
|
||||
.pkey_nid = NID_X9_62_id_ecPublicKey,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_dsa_with_SHA224,
|
||||
.hash_nid = NID_sha224,
|
||||
.pkey_nid = NID_dsa,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_dsa_with_SHA256,
|
||||
.hash_nid = NID_sha256,
|
||||
.pkey_nid = NID_dsa,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_id_GostR3411_94_with_GostR3410_2001,
|
||||
.hash_nid = NID_id_GostR3411_94,
|
||||
.pkey_nid = NID_id_GostR3410_2001,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_id_GostR3411_94_with_GostR3410_94,
|
||||
.hash_nid = NID_id_GostR3411_94,
|
||||
.pkey_nid = NID_id_GostR3410_94,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_id_GostR3411_94_with_GostR3410_94_cc,
|
||||
.hash_nid = NID_id_GostR3411_94,
|
||||
.pkey_nid = NID_id_GostR3410_94_cc,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_id_GostR3411_94_with_GostR3410_2001_cc,
|
||||
.hash_nid = NID_id_GostR3411_94,
|
||||
.pkey_nid = NID_id_GostR3410_2001_cc,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_rsassaPss,
|
||||
.hash_nid = NID_undef,
|
||||
.pkey_nid = NID_rsaEncryption,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_id_tc26_signwithdigest_gost3410_2012_256,
|
||||
.hash_nid = NID_id_tc26_gost3411_2012_256,
|
||||
.pkey_nid = NID_id_GostR3410_2001,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_id_tc26_signwithdigest_gost3410_2012_512,
|
||||
.hash_nid = NID_id_tc26_gost3411_2012_512,
|
||||
.pkey_nid = NID_id_GostR3410_2001,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_Ed25519,
|
||||
.hash_nid = NID_undef,
|
||||
.pkey_nid = NID_Ed25519,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_dhSinglePass_stdDH_sha1kdf_scheme,
|
||||
.hash_nid = NID_sha1,
|
||||
.pkey_nid = NID_dh_std_kdf,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_dhSinglePass_stdDH_sha224kdf_scheme,
|
||||
.hash_nid = NID_sha224,
|
||||
.pkey_nid = NID_dh_std_kdf,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_dhSinglePass_stdDH_sha256kdf_scheme,
|
||||
.hash_nid = NID_sha256,
|
||||
.pkey_nid = NID_dh_std_kdf,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_dhSinglePass_stdDH_sha384kdf_scheme,
|
||||
.hash_nid = NID_sha384,
|
||||
.pkey_nid = NID_dh_std_kdf,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_dhSinglePass_stdDH_sha512kdf_scheme,
|
||||
.hash_nid = NID_sha512,
|
||||
.pkey_nid = NID_dh_std_kdf,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_dhSinglePass_cofactorDH_sha1kdf_scheme,
|
||||
.hash_nid = NID_sha1,
|
||||
.pkey_nid = NID_dh_cofactor_kdf,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_dhSinglePass_cofactorDH_sha224kdf_scheme,
|
||||
.hash_nid = NID_sha224,
|
||||
.pkey_nid = NID_dh_cofactor_kdf,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_dhSinglePass_cofactorDH_sha256kdf_scheme,
|
||||
.hash_nid = NID_sha256,
|
||||
.pkey_nid = NID_dh_cofactor_kdf,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_dhSinglePass_cofactorDH_sha384kdf_scheme,
|
||||
.hash_nid = NID_sha384,
|
||||
.pkey_nid = NID_dh_cofactor_kdf,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_dhSinglePass_cofactorDH_sha512kdf_scheme,
|
||||
.hash_nid = NID_sha512,
|
||||
.pkey_nid = NID_dh_cofactor_kdf,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_RSA_SHA3_224,
|
||||
.hash_nid = NID_sha3_224,
|
||||
.pkey_nid = NID_rsaEncryption,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_RSA_SHA3_256,
|
||||
.hash_nid = NID_sha3_256,
|
||||
.pkey_nid = NID_rsaEncryption,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_RSA_SHA3_384,
|
||||
.hash_nid = NID_sha3_384,
|
||||
.pkey_nid = NID_rsaEncryption,
|
||||
},
|
||||
{
|
||||
.sign_nid = NID_RSA_SHA3_512,
|
||||
.hash_nid = NID_sha3_512,
|
||||
.pkey_nid = NID_rsaEncryption,
|
||||
},
|
||||
};
|
||||
|
||||
static int sig_cmp_BSEARCH_CMP_FN(const void *, const void *);
|
||||
static int sig_cmp(nid_triple const *, nid_triple const *);
|
||||
static nid_triple *OBJ_bsearch_sig(nid_triple *key, nid_triple const *base, int num);
|
||||
|
||||
static int
|
||||
sig_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)
|
||||
{
|
||||
nid_triple const *a = a_;
|
||||
nid_triple const *b = b_;
|
||||
return sig_cmp(a, b);
|
||||
}
|
||||
|
||||
static nid_triple *
|
||||
OBJ_bsearch_sig(nid_triple *key, nid_triple const *base, int num)
|
||||
{
|
||||
return (nid_triple *)OBJ_bsearch_(key, base, num, sizeof(nid_triple),
|
||||
sig_cmp_BSEARCH_CMP_FN);
|
||||
}
|
||||
|
||||
static int
|
||||
sig_sk_cmp(const nid_triple * const *a, const nid_triple * const *b)
|
||||
{
|
||||
return (*a)->sign_id - (*b)->sign_id;
|
||||
}
|
||||
|
||||
static int sigx_cmp_BSEARCH_CMP_FN(const void *, const void *);
|
||||
static int sigx_cmp(const nid_triple * const *, const nid_triple * const *);
|
||||
static const nid_triple * *OBJ_bsearch_sigx(const nid_triple * *key, const nid_triple * const *base, int num);
|
||||
|
||||
static int
|
||||
sigx_cmp(const nid_triple * const *a, const nid_triple * const *b)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = (*a)->hash_id - (*b)->hash_id;
|
||||
if (ret)
|
||||
return ret;
|
||||
return (*a)->pkey_id - (*b)->pkey_id;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
sigx_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)
|
||||
{
|
||||
const nid_triple * const *a = a_;
|
||||
const nid_triple * const *b = b_;
|
||||
return sigx_cmp(a, b);
|
||||
}
|
||||
|
||||
static const nid_triple * *
|
||||
OBJ_bsearch_sigx(const nid_triple * *key, const nid_triple * const *base, int num)
|
||||
{
|
||||
return (const nid_triple * *)OBJ_bsearch_(key, base, num, sizeof(const nid_triple *),
|
||||
sigx_cmp_BSEARCH_CMP_FN);
|
||||
}
|
||||
#define N_NID_TRIPLES (sizeof(nid_triple) / sizeof(nid_triple[0]))
|
||||
|
||||
int
|
||||
OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid)
|
||||
OBJ_find_sigid_algs(int sign_nid, int *hash_nid, int *pkey_nid)
|
||||
{
|
||||
nid_triple tmp;
|
||||
const nid_triple *rv = NULL;
|
||||
tmp.sign_id = signid;
|
||||
size_t i;
|
||||
|
||||
if (sig_app) {
|
||||
int idx = sk_nid_triple_find(sig_app, &tmp);
|
||||
if (idx >= 0)
|
||||
rv = sk_nid_triple_value(sig_app, idx);
|
||||
for (i = 0; i < N_NID_TRIPLES; i++) {
|
||||
if (sign_nid != nid_triple[i].sign_nid)
|
||||
continue;
|
||||
|
||||
if (hash_nid != NULL)
|
||||
*hash_nid = nid_triple[i].hash_nid;
|
||||
if (pkey_nid != NULL)
|
||||
*pkey_nid = nid_triple[i].pkey_nid;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef OBJ_XREF_TEST2
|
||||
if (rv == NULL) {
|
||||
rv = OBJ_bsearch_sig(&tmp, sigoid_srt,
|
||||
sizeof(sigoid_srt) / sizeof(nid_triple));
|
||||
}
|
||||
#endif
|
||||
if (rv == NULL)
|
||||
return 0;
|
||||
if (pdig_nid)
|
||||
*pdig_nid = rv->hash_id;
|
||||
if (ppkey_nid)
|
||||
*ppkey_nid = rv->pkey_id;
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
LCRYPTO_ALIAS(OBJ_find_sigid_algs);
|
||||
|
||||
int
|
||||
OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid)
|
||||
OBJ_find_sigid_by_algs(int *sign_nid, int hash_nid, int pkey_nid)
|
||||
{
|
||||
nid_triple tmp;
|
||||
const nid_triple *t = &tmp;
|
||||
const nid_triple **rv = NULL;
|
||||
size_t i;
|
||||
|
||||
tmp.hash_id = dig_nid;
|
||||
tmp.pkey_id = pkey_nid;
|
||||
for (i = 0; i < N_NID_TRIPLES; i++) {
|
||||
if (hash_nid != nid_triple[i].hash_nid)
|
||||
continue;
|
||||
if (pkey_nid != nid_triple[i].pkey_nid)
|
||||
continue;
|
||||
|
||||
if (sigx_app) {
|
||||
int idx = sk_nid_triple_find(sigx_app, &tmp);
|
||||
if (idx >= 0) {
|
||||
t = sk_nid_triple_value(sigx_app, idx);
|
||||
rv = &t;
|
||||
}
|
||||
if (sign_nid != NULL)
|
||||
*sign_nid = nid_triple[i].sign_nid;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef OBJ_XREF_TEST2
|
||||
if (rv == NULL) {
|
||||
rv = OBJ_bsearch_sigx(&t, sigoid_srt_xref,
|
||||
sizeof(sigoid_srt_xref) / sizeof(nid_triple *));
|
||||
}
|
||||
#endif
|
||||
if (rv == NULL)
|
||||
return 0;
|
||||
if (psignid)
|
||||
*psignid = (*rv)->sign_id;
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
LCRYPTO_ALIAS(OBJ_find_sigid_by_algs);
|
||||
|
||||
int
|
||||
OBJ_add_sigid(int signid, int dig_id, int pkey_id)
|
||||
OBJ_add_sigid(int sign_nid, int hash_nid, int pkey_nid)
|
||||
{
|
||||
nid_triple *ntr;
|
||||
|
||||
if (!sig_app)
|
||||
sig_app = sk_nid_triple_new(sig_sk_cmp);
|
||||
if (!sig_app)
|
||||
return 0;
|
||||
if (!sigx_app)
|
||||
sigx_app = sk_nid_triple_new(sigx_cmp);
|
||||
if (!sigx_app)
|
||||
return 0;
|
||||
ntr = reallocarray(NULL, 3, sizeof(int));
|
||||
if (!ntr)
|
||||
return 0;
|
||||
ntr->sign_id = signid;
|
||||
ntr->hash_id = dig_id;
|
||||
ntr->pkey_id = pkey_id;
|
||||
|
||||
if (!sk_nid_triple_push(sig_app, ntr)) {
|
||||
free(ntr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!sk_nid_triple_push(sigx_app, ntr))
|
||||
return 0;
|
||||
|
||||
sk_nid_triple_sort(sig_app);
|
||||
sk_nid_triple_sort(sigx_app);
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
LCRYPTO_ALIAS(OBJ_add_sigid);
|
||||
|
||||
static void
|
||||
sid_free(nid_triple *tt)
|
||||
{
|
||||
free(tt);
|
||||
}
|
||||
|
||||
void
|
||||
OBJ_sigid_free(void)
|
||||
{
|
||||
if (sig_app) {
|
||||
sk_nid_triple_pop_free(sig_app, sid_free);
|
||||
sig_app = NULL;
|
||||
}
|
||||
if (sigx_app) {
|
||||
sk_nid_triple_free(sigx_app);
|
||||
sigx_app = NULL;
|
||||
}
|
||||
}
|
||||
LCRYPTO_ALIAS(OBJ_sigid_free);
|
||||
|
@ -1,115 +0,0 @@
|
||||
/* $OpenBSD: obj_xref.h,v 1.7 2023/06/15 17:58:27 tb Exp $ */
|
||||
/* AUTOGENERATED BY objxref.pl, DO NOT EDIT */
|
||||
|
||||
__BEGIN_HIDDEN_DECLS
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int sign_id;
|
||||
int hash_id;
|
||||
int pkey_id;
|
||||
} nid_triple;
|
||||
|
||||
static const nid_triple sigoid_srt[] =
|
||||
{
|
||||
{NID_md2WithRSAEncryption, NID_md2, NID_rsaEncryption},
|
||||
{NID_md5WithRSAEncryption, NID_md5, NID_rsaEncryption},
|
||||
{NID_shaWithRSAEncryption, NID_sha, NID_rsaEncryption},
|
||||
{NID_sha1WithRSAEncryption, NID_sha1, NID_rsaEncryption},
|
||||
{NID_dsaWithSHA, NID_sha, NID_dsa},
|
||||
{NID_dsaWithSHA1_2, NID_sha1, NID_dsa_2},
|
||||
{NID_mdc2WithRSA, NID_mdc2, NID_rsaEncryption},
|
||||
{NID_md5WithRSA, NID_md5, NID_rsa},
|
||||
{NID_dsaWithSHA1, NID_sha1, NID_dsa},
|
||||
{NID_sha1WithRSA, NID_sha1, NID_rsa},
|
||||
{NID_ripemd160WithRSA, NID_ripemd160, NID_rsaEncryption},
|
||||
{NID_md4WithRSAEncryption, NID_md4, NID_rsaEncryption},
|
||||
{NID_ecdsa_with_SHA1, NID_sha1, NID_X9_62_id_ecPublicKey},
|
||||
{NID_sha256WithRSAEncryption, NID_sha256, NID_rsaEncryption},
|
||||
{NID_sha384WithRSAEncryption, NID_sha384, NID_rsaEncryption},
|
||||
{NID_sha512WithRSAEncryption, NID_sha512, NID_rsaEncryption},
|
||||
{NID_sha224WithRSAEncryption, NID_sha224, NID_rsaEncryption},
|
||||
{NID_ecdsa_with_Recommended, NID_undef, NID_X9_62_id_ecPublicKey},
|
||||
{NID_ecdsa_with_Specified, NID_undef, NID_X9_62_id_ecPublicKey},
|
||||
{NID_ecdsa_with_SHA224, NID_sha224, NID_X9_62_id_ecPublicKey},
|
||||
{NID_ecdsa_with_SHA256, NID_sha256, NID_X9_62_id_ecPublicKey},
|
||||
{NID_ecdsa_with_SHA384, NID_sha384, NID_X9_62_id_ecPublicKey},
|
||||
{NID_ecdsa_with_SHA512, NID_sha512, NID_X9_62_id_ecPublicKey},
|
||||
{NID_dsa_with_SHA224, NID_sha224, NID_dsa},
|
||||
{NID_dsa_with_SHA256, NID_sha256, NID_dsa},
|
||||
{NID_id_GostR3411_94_with_GostR3410_2001, NID_id_GostR3411_94, NID_id_GostR3410_2001},
|
||||
{NID_id_GostR3411_94_with_GostR3410_94, NID_id_GostR3411_94, NID_id_GostR3410_94},
|
||||
{NID_id_GostR3411_94_with_GostR3410_94_cc, NID_id_GostR3411_94, NID_id_GostR3410_94_cc},
|
||||
{NID_id_GostR3411_94_with_GostR3410_2001_cc, NID_id_GostR3411_94, NID_id_GostR3410_2001_cc},
|
||||
{NID_rsassaPss, NID_undef, NID_rsaEncryption},
|
||||
{NID_id_tc26_signwithdigest_gost3410_2012_256, NID_id_tc26_gost3411_2012_256, NID_id_GostR3410_2001},
|
||||
{NID_id_tc26_signwithdigest_gost3410_2012_512, NID_id_tc26_gost3411_2012_512, NID_id_GostR3410_2001},
|
||||
{NID_Ed25519, NID_undef, NID_Ed25519},
|
||||
{NID_dhSinglePass_stdDH_sha1kdf_scheme, NID_sha1, NID_dh_std_kdf},
|
||||
{NID_dhSinglePass_stdDH_sha224kdf_scheme, NID_sha224, NID_dh_std_kdf},
|
||||
{NID_dhSinglePass_stdDH_sha256kdf_scheme, NID_sha256, NID_dh_std_kdf},
|
||||
{NID_dhSinglePass_stdDH_sha384kdf_scheme, NID_sha384, NID_dh_std_kdf},
|
||||
{NID_dhSinglePass_stdDH_sha512kdf_scheme, NID_sha512, NID_dh_std_kdf},
|
||||
{NID_dhSinglePass_cofactorDH_sha1kdf_scheme, NID_sha1, NID_dh_cofactor_kdf},
|
||||
{NID_dhSinglePass_cofactorDH_sha224kdf_scheme, NID_sha224, NID_dh_cofactor_kdf},
|
||||
{NID_dhSinglePass_cofactorDH_sha256kdf_scheme, NID_sha256, NID_dh_cofactor_kdf},
|
||||
{NID_dhSinglePass_cofactorDH_sha384kdf_scheme, NID_sha384, NID_dh_cofactor_kdf},
|
||||
{NID_dhSinglePass_cofactorDH_sha512kdf_scheme, NID_sha512, NID_dh_cofactor_kdf},
|
||||
{NID_RSA_SHA3_224, NID_sha3_224, NID_rsaEncryption},
|
||||
{NID_RSA_SHA3_256, NID_sha3_256, NID_rsaEncryption},
|
||||
{NID_RSA_SHA3_384, NID_sha3_384, NID_rsaEncryption},
|
||||
{NID_RSA_SHA3_512, NID_sha3_512, NID_rsaEncryption},
|
||||
};
|
||||
|
||||
static const nid_triple * const sigoid_srt_xref[] =
|
||||
{
|
||||
&sigoid_srt[29],
|
||||
&sigoid_srt[18],
|
||||
&sigoid_srt[17],
|
||||
&sigoid_srt[32],
|
||||
&sigoid_srt[0],
|
||||
&sigoid_srt[1],
|
||||
&sigoid_srt[7],
|
||||
&sigoid_srt[2],
|
||||
&sigoid_srt[4],
|
||||
&sigoid_srt[3],
|
||||
&sigoid_srt[9],
|
||||
&sigoid_srt[5],
|
||||
&sigoid_srt[8],
|
||||
&sigoid_srt[12],
|
||||
&sigoid_srt[33],
|
||||
&sigoid_srt[38],
|
||||
&sigoid_srt[6],
|
||||
&sigoid_srt[10],
|
||||
&sigoid_srt[11],
|
||||
&sigoid_srt[13],
|
||||
&sigoid_srt[24],
|
||||
&sigoid_srt[20],
|
||||
&sigoid_srt[35],
|
||||
&sigoid_srt[40],
|
||||
&sigoid_srt[14],
|
||||
&sigoid_srt[21],
|
||||
&sigoid_srt[36],
|
||||
&sigoid_srt[41],
|
||||
&sigoid_srt[15],
|
||||
&sigoid_srt[22],
|
||||
&sigoid_srt[37],
|
||||
&sigoid_srt[42],
|
||||
&sigoid_srt[16],
|
||||
&sigoid_srt[23],
|
||||
&sigoid_srt[19],
|
||||
&sigoid_srt[34],
|
||||
&sigoid_srt[39],
|
||||
&sigoid_srt[25],
|
||||
&sigoid_srt[26],
|
||||
&sigoid_srt[27],
|
||||
&sigoid_srt[28],
|
||||
&sigoid_srt[30],
|
||||
&sigoid_srt[31],
|
||||
&sigoid_srt[43],
|
||||
&sigoid_srt[44],
|
||||
&sigoid_srt[45],
|
||||
&sigoid_srt[46],
|
||||
};
|
||||
|
||||
__END_HIDDEN_DECLS
|
@ -1,68 +0,0 @@
|
||||
# OID cross reference table.
|
||||
# Links signatures OIDs to their corresponding public key algorithms
|
||||
# and digests. The digest "undef" indicates the public key's ASN.1
|
||||
# method should handle AlgorithmIdentifiers and (at least part of) the
|
||||
# message digest explicitly.
|
||||
|
||||
md2WithRSAEncryption md2 rsaEncryption
|
||||
md5WithRSAEncryption md5 rsaEncryption
|
||||
shaWithRSAEncryption sha rsaEncryption
|
||||
sha1WithRSAEncryption sha1 rsaEncryption
|
||||
md4WithRSAEncryption md4 rsaEncryption
|
||||
sha256WithRSAEncryption sha256 rsaEncryption
|
||||
sha384WithRSAEncryption sha384 rsaEncryption
|
||||
sha512WithRSAEncryption sha512 rsaEncryption
|
||||
sha224WithRSAEncryption sha224 rsaEncryption
|
||||
mdc2WithRSA mdc2 rsaEncryption
|
||||
ripemd160WithRSA ripemd160 rsaEncryption
|
||||
RSA_SHA3_224 sha3_224 rsaEncryption
|
||||
RSA_SHA3_256 sha3_256 rsaEncryption
|
||||
RSA_SHA3_384 sha3_384 rsaEncryption
|
||||
RSA_SHA3_512 sha3_512 rsaEncryption
|
||||
# For PSS the digest algorithm can vary and depends on the included
|
||||
# AlgorithmIdentifier.
|
||||
rsassaPss undef rsaEncryption
|
||||
|
||||
Ed25519 undef Ed25519
|
||||
|
||||
# Alternative deprecated OIDs. By using the older "rsa" OID this
|
||||
# type will be recognized by not normally used.
|
||||
|
||||
md5WithRSA md5 rsa
|
||||
sha1WithRSA sha1 rsa
|
||||
|
||||
dsaWithSHA sha dsa
|
||||
dsaWithSHA1 sha1 dsa
|
||||
|
||||
dsaWithSHA1_2 sha1 dsa_2
|
||||
|
||||
ecdsa_with_SHA1 sha1 X9_62_id_ecPublicKey
|
||||
ecdsa_with_SHA224 sha224 X9_62_id_ecPublicKey
|
||||
ecdsa_with_SHA256 sha256 X9_62_id_ecPublicKey
|
||||
ecdsa_with_SHA384 sha384 X9_62_id_ecPublicKey
|
||||
ecdsa_with_SHA512 sha512 X9_62_id_ecPublicKey
|
||||
ecdsa_with_Recommended undef X9_62_id_ecPublicKey
|
||||
ecdsa_with_Specified undef X9_62_id_ecPublicKey
|
||||
|
||||
dsa_with_SHA224 sha224 dsa
|
||||
dsa_with_SHA256 sha256 dsa
|
||||
|
||||
id_GostR3411_94_with_GostR3410_2001 id_GostR3411_94 id_GostR3410_2001
|
||||
id_GostR3411_94_with_GostR3410_94 id_GostR3411_94 id_GostR3410_94
|
||||
id_GostR3411_94_with_GostR3410_94_cc id_GostR3411_94 id_GostR3410_94_cc
|
||||
id_GostR3411_94_with_GostR3410_2001_cc id_GostR3411_94 id_GostR3410_2001_cc
|
||||
id_tc26_signwithdigest_gost3410_2012_256 id_tc26_gost3411_2012_256 id_GostR3410_2001
|
||||
id_tc26_signwithdigest_gost3410_2012_512 id_tc26_gost3411_2012_512 id_GostR3410_2001
|
||||
|
||||
# ECDH KDFs and their corresponding message digests and schemes
|
||||
dhSinglePass_stdDH_sha1kdf_scheme sha1 dh_std_kdf
|
||||
dhSinglePass_stdDH_sha224kdf_scheme sha224 dh_std_kdf
|
||||
dhSinglePass_stdDH_sha256kdf_scheme sha256 dh_std_kdf
|
||||
dhSinglePass_stdDH_sha384kdf_scheme sha384 dh_std_kdf
|
||||
dhSinglePass_stdDH_sha512kdf_scheme sha512 dh_std_kdf
|
||||
|
||||
dhSinglePass_cofactorDH_sha1kdf_scheme sha1 dh_cofactor_kdf
|
||||
dhSinglePass_cofactorDH_sha224kdf_scheme sha224 dh_cofactor_kdf
|
||||
dhSinglePass_cofactorDH_sha256kdf_scheme sha256 dh_cofactor_kdf
|
||||
dhSinglePass_cofactorDH_sha384kdf_scheme sha384 dh_cofactor_kdf
|
||||
dhSinglePass_cofactorDH_sha512kdf_scheme sha512 dh_cofactor_kdf
|
@ -1,111 +0,0 @@
|
||||
#!/usr/local/bin/perl
|
||||
|
||||
use strict;
|
||||
|
||||
my %xref_tbl;
|
||||
my %oid_tbl;
|
||||
|
||||
my ($mac_file, $xref_file) = @ARGV;
|
||||
|
||||
open(IN, $mac_file) || die "Can't open $mac_file";
|
||||
|
||||
# Read in OID nid values for a lookup table.
|
||||
|
||||
while (<IN>)
|
||||
{
|
||||
chomp;
|
||||
my ($name, $num) = /^(\S+)\s+(\S+)$/;
|
||||
$oid_tbl{$name} = $num;
|
||||
}
|
||||
close IN;
|
||||
|
||||
open(IN, $xref_file) || die "Can't open $xref_file";
|
||||
|
||||
my $ln = 1;
|
||||
|
||||
while (<IN>)
|
||||
{
|
||||
chomp;
|
||||
s/#.*$//;
|
||||
next if (/^\S*$/);
|
||||
my ($xr, $p1, $p2) = /^(\S+)\s+(\S+)\s+(\S+)/;
|
||||
check_oid($xr);
|
||||
check_oid($p1);
|
||||
check_oid($p2);
|
||||
$xref_tbl{$xr} = [$p1, $p2, $ln];
|
||||
}
|
||||
|
||||
my @xrkeys = keys %xref_tbl;
|
||||
|
||||
my @srt1 = sort { $oid_tbl{$a} <=> $oid_tbl{$b}} @xrkeys;
|
||||
|
||||
for(my $i = 0; $i <= $#srt1; $i++)
|
||||
{
|
||||
$xref_tbl{$srt1[$i]}[2] = $i;
|
||||
}
|
||||
|
||||
my @srt2 = sort
|
||||
{
|
||||
my$ap1 = $oid_tbl{$xref_tbl{$a}[0]};
|
||||
my$bp1 = $oid_tbl{$xref_tbl{$b}[0]};
|
||||
return $ap1 - $bp1 if ($ap1 != $bp1);
|
||||
my$ap2 = $oid_tbl{$xref_tbl{$a}[1]};
|
||||
my$bp2 = $oid_tbl{$xref_tbl{$b}[1]};
|
||||
|
||||
return $ap2 - $bp2;
|
||||
} @xrkeys;
|
||||
|
||||
my $pname = $0;
|
||||
|
||||
$pname =~ s|^.[^/]/||;
|
||||
|
||||
print <<EOF;
|
||||
/* \$OpenBSD\$ */
|
||||
/* AUTOGENERATED BY $pname, DO NOT EDIT */
|
||||
|
||||
__BEGIN_HIDDEN_DECLS
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int sign_id;
|
||||
int hash_id;
|
||||
int pkey_id;
|
||||
} nid_triple;
|
||||
|
||||
static const nid_triple sigoid_srt[] =
|
||||
{
|
||||
EOF
|
||||
|
||||
foreach (@srt1)
|
||||
{
|
||||
my $xr = $_;
|
||||
my ($p1, $p2) = @{$xref_tbl{$_}};
|
||||
print "\t{NID_$xr, NID_$p1, NID_$p2},\n";
|
||||
}
|
||||
|
||||
print "\t};";
|
||||
print <<EOF;
|
||||
|
||||
|
||||
static const nid_triple * const sigoid_srt_xref[] =
|
||||
{
|
||||
EOF
|
||||
|
||||
foreach (@srt2)
|
||||
{
|
||||
my $x = $xref_tbl{$_}[2];
|
||||
print "\t\&sigoid_srt\[$x\],\n";
|
||||
}
|
||||
|
||||
print "\t};\n\n";
|
||||
print "__END_HIDDEN_DECLS\n";
|
||||
|
||||
sub check_oid
|
||||
{
|
||||
my ($chk) = @_;
|
||||
if (!exists $oid_tbl{$chk})
|
||||
{
|
||||
die "Not Found \"$chk\"\n";
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ldd.c,v 1.23 2023/07/13 19:04:50 jasper Exp $ */
|
||||
/* $OpenBSD: ldd.c,v 1.24 2023/07/24 01:02:47 deraadt Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2001 Artur Grabowski <art@openbsd.org>
|
||||
* All rights reserved.
|
||||
@ -183,6 +183,8 @@ doit(char *name)
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
if (pledge(NULL, "stdio rpath") == -1)
|
||||
err(1, "pledge");
|
||||
execl(name, name, (char *)NULL);
|
||||
perror(name);
|
||||
_exit(1);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: bn_print.c,v 1.4 2023/07/10 20:21:37 tb Exp $ */
|
||||
/* $OpenBSD: bn_print.c,v 1.5 2023/07/27 06:41:39 tb Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
|
||||
@ -140,6 +140,7 @@ const struct print_test {
|
||||
" 00:80:00:00:00:00:00:00:00:00\n",
|
||||
},
|
||||
{
|
||||
/* XXX - this is incorrect and should be fixed. */
|
||||
.desc = "high bit of first nibble is set for negative number",
|
||||
.want = " mana mana (Negative)\n"
|
||||
" 00:80:00:00:00:00:00:00:00:00\n",
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* $OpenBSD: ectest.c,v 1.19 2023/04/18 15:28:17 tb Exp $ */
|
||||
/* crypto/ec/ectest.c */
|
||||
/* $OpenBSD: ectest.c,v 1.21 2023/07/26 22:46:06 tb Exp $ */
|
||||
/*
|
||||
* Originally written by Bodo Moeller for the OpenSSL project.
|
||||
*/
|
||||
@ -258,7 +257,7 @@ prime_field_tests(void)
|
||||
ABORT;
|
||||
if (!EC_POINT_set_compressed_coordinates(group, Q, x, 1, ctx))
|
||||
ABORT;
|
||||
if (!EC_POINT_is_on_curve(group, Q, ctx)) {
|
||||
if (EC_POINT_is_on_curve(group, Q, ctx) <= 0) {
|
||||
if (!EC_POINT_get_affine_coordinates(group, Q, x, y, ctx))
|
||||
ABORT;
|
||||
fprintf(stderr, "Point is not on curve: x = 0x");
|
||||
@ -365,7 +364,7 @@ prime_field_tests(void)
|
||||
ABORT;
|
||||
if (!EC_POINT_set_affine_coordinates(group, P, x, y, ctx))
|
||||
ABORT;
|
||||
if (!EC_POINT_is_on_curve(group, P, ctx))
|
||||
if (EC_POINT_is_on_curve(group, P, ctx) <= 0)
|
||||
ABORT;
|
||||
if (!BN_hex2bn(&z, "0100000000000000000001F4C8F927AED3CA752257"))
|
||||
ABORT;
|
||||
@ -415,7 +414,7 @@ prime_field_tests(void)
|
||||
ABORT;
|
||||
if (!EC_POINT_set_compressed_coordinates(group, P, x, 1, ctx))
|
||||
ABORT;
|
||||
if (!EC_POINT_is_on_curve(group, P, ctx))
|
||||
if (EC_POINT_is_on_curve(group, P, ctx) <= 0)
|
||||
ABORT;
|
||||
if (!BN_hex2bn(&z, "FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831"))
|
||||
ABORT;
|
||||
@ -465,7 +464,7 @@ prime_field_tests(void)
|
||||
ABORT;
|
||||
if (!EC_POINT_set_compressed_coordinates(group, P, x, 0, ctx))
|
||||
ABORT;
|
||||
if (!EC_POINT_is_on_curve(group, P, ctx))
|
||||
if (EC_POINT_is_on_curve(group, P, ctx) <= 0)
|
||||
ABORT;
|
||||
if (!BN_hex2bn(&z, "FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D"))
|
||||
ABORT;
|
||||
@ -515,7 +514,7 @@ prime_field_tests(void)
|
||||
ABORT;
|
||||
if (!EC_POINT_set_compressed_coordinates(group, P, x, 1, ctx))
|
||||
ABORT;
|
||||
if (!EC_POINT_is_on_curve(group, P, ctx))
|
||||
if (EC_POINT_is_on_curve(group, P, ctx) <= 0)
|
||||
ABORT;
|
||||
if (!BN_hex2bn(&z, "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E"
|
||||
"84F3B9CAC2FC632551")) ABORT;
|
||||
@ -565,7 +564,7 @@ prime_field_tests(void)
|
||||
"9859F741E082542A385502F25DBF55296C3A545E3872760AB7")) ABORT;
|
||||
if (!EC_POINT_set_compressed_coordinates(group, P, x, 1, ctx))
|
||||
ABORT;
|
||||
if (!EC_POINT_is_on_curve(group, P, ctx))
|
||||
if (EC_POINT_is_on_curve(group, P, ctx) <= 0)
|
||||
ABORT;
|
||||
if (!BN_hex2bn(&z, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
"FFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973")) ABORT;
|
||||
@ -619,7 +618,7 @@ prime_field_tests(void)
|
||||
"3C1856A429BF97E7E31C2E5BD66")) ABORT;
|
||||
if (!EC_POINT_set_compressed_coordinates(group, P, x, 0, ctx))
|
||||
ABORT;
|
||||
if (!EC_POINT_is_on_curve(group, P, ctx))
|
||||
if (EC_POINT_is_on_curve(group, P, ctx) <= 0)
|
||||
ABORT;
|
||||
if (!BN_hex2bn(&z, "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
"FFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5"
|
||||
@ -664,7 +663,7 @@ prime_field_tests(void)
|
||||
/* P := 2P */
|
||||
if (!EC_POINT_dbl(group, P, P, ctx))
|
||||
ABORT;
|
||||
if (!EC_POINT_is_on_curve(group, P, ctx))
|
||||
if (EC_POINT_is_on_curve(group, P, ctx) <= 0)
|
||||
ABORT;
|
||||
/* Q := -P */
|
||||
if (!EC_POINT_invert(group, Q, ctx))
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: freenull.c.head,v 1.4 2022/01/15 02:46:12 inoguchi Exp $ */
|
||||
/* $OpenBSD: freenull.c.head,v 1.5 2023/07/26 22:51:01 tb Exp $ */
|
||||
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/cmac.h>
|
||||
@ -6,7 +6,9 @@
|
||||
#include <openssl/comp.h>
|
||||
#include <openssl/conf_api.h>
|
||||
#include <openssl/ct.h>
|
||||
#ifndef OPENSSL_NO_DSO
|
||||
#include <openssl/dso.h>
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
#include <openssl/engine.h>
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ssltest.c,v 1.41 2023/07/04 08:47:01 tb Exp $ */
|
||||
/* $OpenBSD: ssltest.c,v 1.42 2023/07/27 07:08:09 tb Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -140,6 +140,9 @@
|
||||
* OTHERWISE.
|
||||
*/
|
||||
|
||||
/* XXX - USE_BIOPAIR code needs updating for BIO_n{read,write}{,0} removal. */
|
||||
/* #define USE_BIOPAIR */
|
||||
|
||||
#define _BSD_SOURCE 1 /* Or gethostname won't be declared properly
|
||||
on Linux and GNU platforms. */
|
||||
#include <sys/types.h>
|
||||
@ -714,10 +717,12 @@ bad:
|
||||
for (i = 0; i < number; i++) {
|
||||
if (!reuse)
|
||||
SSL_set_session(c_ssl, NULL);
|
||||
#ifdef USE_BIOPAIR
|
||||
if (bio_pair)
|
||||
ret = doit_biopair(s_ssl, c_ssl, bytes, &s_time,
|
||||
&c_time);
|
||||
else
|
||||
#endif
|
||||
ret = doit(s_ssl, c_ssl, bytes);
|
||||
}
|
||||
|
||||
@ -771,6 +776,7 @@ end:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if USE_BIOPAIR
|
||||
int
|
||||
doit_biopair(SSL *s_ssl, SSL *c_ssl, long count, clock_t *s_time,
|
||||
clock_t *c_time)
|
||||
@ -1114,6 +1120,7 @@ err:
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#define W_READ 1
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $OpenBSD: appstest.sh,v 1.57 2023/07/03 05:31:56 beck Exp $
|
||||
# $OpenBSD: appstest.sh,v 1.58 2023/07/24 05:54:12 tb Exp $
|
||||
#
|
||||
# Copyright (c) 2016 Kinichiro Inoguchi <inoguchi@openbsd.org>
|
||||
#
|
||||
@ -118,8 +118,6 @@ __EOF__
|
||||
start_message "errstr"
|
||||
$openssl_bin errstr 2606A074
|
||||
check_exit_status $?
|
||||
$openssl_bin errstr -stats 2606A074 > $user1_dir/errstr-stats.out
|
||||
check_exit_status $?
|
||||
|
||||
#---------#---------#---------#---------#---------#---------#---------
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: vioscribble.c,v 1.3 2021/06/13 21:43:35 dv Exp $ */
|
||||
/* $OpenBSD: vioscribble.c,v 1.4 2023/07/26 05:50:45 anton Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018 Ori Bernstein <ori@eigenstate.org>
|
||||
@ -50,6 +50,8 @@
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <err.h>
|
||||
#include <stdarg.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include "vmd.h"
|
||||
#include "vmm.h"
|
||||
@ -57,7 +59,6 @@
|
||||
|
||||
#define CLUSTERSZ 65536
|
||||
|
||||
int verbose;
|
||||
struct virtio_backing qcowfile;
|
||||
struct virtio_backing rawfile;
|
||||
|
||||
@ -81,7 +82,8 @@ main(int argc, char **argv)
|
||||
char buf[64*1024], cmp[64*1024];
|
||||
off_t len, off, qcsz, rawsz;
|
||||
|
||||
verbose = !!getenv("VERBOSE");
|
||||
log_init(1, LOG_DAEMON);
|
||||
|
||||
qcfd = open("scribble.qcow2", O_RDWR);
|
||||
rawfd = open("scribble.raw", O_RDWR);
|
||||
if (qcfd == -1)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: mount.c,v 1.76 2022/12/04 23:50:46 cheloha Exp $ */
|
||||
/* $OpenBSD: mount.c,v 1.77 2023/07/23 23:21:19 kn Exp $ */
|
||||
/* $NetBSD: mount.c,v 1.24 1995/11/18 03:34:29 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -565,6 +565,7 @@ prmount(struct statfs *sf)
|
||||
(void)printf(", %s=%d",
|
||||
"acdirmax", nfs_args->acdirmax);
|
||||
}
|
||||
#ifndef SMALL
|
||||
} else if (strcmp(sf->f_fstypename, MOUNT_MFS) == 0) {
|
||||
int headerlen;
|
||||
long blocksize;
|
||||
@ -573,6 +574,7 @@ prmount(struct statfs *sf)
|
||||
header = getbsize(&headerlen, &blocksize);
|
||||
(void)printf("%s%s=%lu %s", !f++ ? " (" : ", ",
|
||||
"size", sf->mount_info.mfs_args.size / blocksize, header);
|
||||
#endif /* SMALL */
|
||||
} else if (strcmp(sf->f_fstypename, MOUNT_MSDOS) == 0) {
|
||||
struct msdosfs_args *msdosfs_args = &sf->mount_info.msdosfs_args;
|
||||
|
||||
@ -597,6 +599,7 @@ prmount(struct statfs *sf)
|
||||
(void)printf("%s%s", !f++ ? " (" : ", ", "gens");
|
||||
if (iso_args->flags & ISOFSMNT_EXTATT)
|
||||
(void)printf("%s%s", !f++ ? " (" : ", ", "extatt");
|
||||
#ifndef SMALL
|
||||
} else if (strcmp(sf->f_fstypename, MOUNT_TMPFS) == 0) {
|
||||
struct tmpfs_args *tmpfs_args = &sf->mount_info.tmpfs_args;
|
||||
|
||||
@ -612,6 +615,7 @@ prmount(struct statfs *sf)
|
||||
if (verbose || tmpfs_args->ta_nodes_max)
|
||||
(void)printf("%s%s=%lu", !f++ ? " (" : ", ",
|
||||
"inodes", (unsigned long)tmpfs_args->ta_nodes_max);
|
||||
#endif /* SMALL */
|
||||
}
|
||||
(void)printf(f ? ")\n" : "\n");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: eoip.4,v 1.6 2020/12/05 18:44:35 jmc Exp $
|
||||
.\" $OpenBSD: eoip.4,v 1.8 2023/07/26 20:23:22 jmc Exp $
|
||||
.\" $NetBSD: gre.4,v 1.10 1999/12/22 14:55:49 kleink Exp $
|
||||
.\"
|
||||
.\" Copyright 1998 (c) The NetBSD Foundation, Inc.
|
||||
@ -28,7 +28,7 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd $Mdocdate: December 5 2020 $
|
||||
.Dd $Mdocdate: July 26 2023 $
|
||||
.Dt EOIP 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: bsd.README,v 1.85 2020/09/22 10:31:46 martijn Exp $
|
||||
# $OpenBSD: bsd.README,v 1.86 2023/07/25 20:19:14 asou Exp $
|
||||
# $NetBSD: bsd.README,v 1.17 1996/04/13 02:08:08 thorpej Exp $
|
||||
# @(#)bsd.README 5.1 (Berkeley) 5/11/90
|
||||
|
||||
@ -302,6 +302,8 @@ CLEANFILES Additional files to remove for the clean and cleandir targets.
|
||||
|
||||
COPTS Additional flags to the compiler when creating C objects.
|
||||
|
||||
CXXOPTS Additional flags to the compiler when creating C++ objects.
|
||||
|
||||
LDADD Additional linker objects. Usually used for libraries.
|
||||
For example, to link with the crypto and utility
|
||||
libraries, use:
|
||||
|
1
sys/.gitignore
vendored
1
sys/.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
**/obj
|
||||
**/tags
|
||||
**/CVS
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: cpu.c,v 1.171 2023/07/21 04:04:51 guenther Exp $ */
|
||||
/* $OpenBSD: cpu.c,v 1.173 2023/07/25 04:42:00 deraadt Exp $ */
|
||||
/* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */
|
||||
|
||||
/*-
|
||||
@ -1168,7 +1168,7 @@ void
|
||||
cpu_fix_msrs(struct cpu_info *ci)
|
||||
{
|
||||
int family = ci->ci_family;
|
||||
uint64_t msr;
|
||||
uint64_t msr, nmsr;
|
||||
|
||||
if (!strcmp(cpu_vendor, "GenuineIntel")) {
|
||||
if ((family > 6 || (family == 6 && ci->ci_model >= 0xd)) &&
|
||||
@ -1211,11 +1211,17 @@ cpu_fix_msrs(struct cpu_info *ci)
|
||||
* where LFENCE is always serializing.
|
||||
*/
|
||||
if (family >= 0x10 && family != 0x11) {
|
||||
msr = rdmsr(MSR_DE_CFG);
|
||||
if ((msr & DE_CFG_SERIALIZE_LFENCE) == 0) {
|
||||
msr |= DE_CFG_SERIALIZE_LFENCE;
|
||||
wrmsr(MSR_DE_CFG, msr);
|
||||
}
|
||||
nmsr = msr = rdmsr(MSR_DE_CFG);
|
||||
nmsr |= DE_CFG_SERIALIZE_LFENCE;
|
||||
if (msr != nmsr)
|
||||
wrmsr(MSR_DE_CFG, nmsr);
|
||||
}
|
||||
if (family == 0x17 && ci->ci_model >= 0x31 &&
|
||||
(cpu_ecxfeature & CPUIDECX_HV) == 0) {
|
||||
nmsr = msr = rdmsr(MSR_DE_CFG);
|
||||
nmsr |= DE_CFG_SERIALIZE_9;
|
||||
if (msr != nmsr)
|
||||
wrmsr(MSR_DE_CFG, nmsr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: identcpu.c,v 1.134 2023/07/21 04:04:51 guenther Exp $ */
|
||||
/* $OpenBSD: identcpu.c,v 1.135 2023/07/27 01:51:35 guenther Exp $ */
|
||||
/* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
@ -230,18 +230,47 @@ const struct {
|
||||
}, cpu_cpuid_apmi_edx[] = {
|
||||
{ CPUIDEDX_ITSC, "ITSC" },
|
||||
}, cpu_amdspec_ebxfeatures[] = {
|
||||
{ CPUIDEBX_IBPB, "IBPB" },
|
||||
{ CPUIDEBX_IBRS, "IBRS" },
|
||||
{ CPUIDEBX_STIBP, "STIBP" },
|
||||
{ CPUIDEBX_SSBD, "SSBD" },
|
||||
{ CPUIDEBX_VIRT_SSBD, "VIRTSSBD" },
|
||||
{ CPUIDEBX_SSBD_NOTREQ, "SSBDNR" },
|
||||
{ CPUIDEBX_INVLPGB, "INVLPGB" },
|
||||
{ CPUIDEBX_IBPB, "IBPB" },
|
||||
{ CPUIDEBX_IBRS, "IBRS" },
|
||||
{ CPUIDEBX_STIBP, "STIBP" },
|
||||
{ CPUIDEBX_IBRS_ALWAYSON, "IBRS_ALL" },
|
||||
{ CPUIDEBX_STIBP_ALWAYSON, "STIBP_ALL" },
|
||||
{ CPUIDEBX_IBRS_PREF, "IBRS_PREF" },
|
||||
{ CPUIDEBX_IBRS_SAME_MODE, "IBRS_SM" },
|
||||
{ CPUIDEBX_SSBD, "SSBD" },
|
||||
{ CPUIDEBX_VIRT_SSBD, "VIRTSSBD" },
|
||||
{ CPUIDEBX_SSBD_NOTREQ, "SSBDNR" },
|
||||
}, cpu_xsave_extfeatures[] = {
|
||||
{ XSAVE_XSAVEOPT, "XSAVEOPT" },
|
||||
{ XSAVE_XSAVEC, "XSAVEC" },
|
||||
{ XSAVE_XGETBV1, "XGETBV1" },
|
||||
{ XSAVE_XSAVES, "XSAVES" },
|
||||
{ XSAVE_XFD, "XFD" },
|
||||
}, cpu_arch_cap_features[] = {
|
||||
/* ARCH_CAP_RDCL_NO (not printed) == !MELTDOWN */
|
||||
{ ARCH_CAP_IBRS_ALL, "IBRS_ALL" },
|
||||
{ ARCH_CAP_RSBA, "RSBA" },
|
||||
{ ARCH_CAP_SKIP_L1DFL_VMENTRY, "SKIP_L1DFL" },
|
||||
{ ARCH_CAP_SSB_NO, "SSB_NO" },
|
||||
{ ARCH_CAP_MDS_NO, "MDS_NO" },
|
||||
{ ARCH_CAP_IF_PSCHANGE_MC_NO, "IF_PSCHANGE" },
|
||||
{ ARCH_CAP_TSX_CTRL, "TSX_CTRL" },
|
||||
{ ARCH_CAP_TAA_NO, "TAA_NO" },
|
||||
{ ARCH_CAP_MCU_CONTROL, "MCU_CONTROL" },
|
||||
{ ARCH_CAP_MISC_PACKAGE_CTLS, "MISC_PKG_CT" },
|
||||
{ ARCH_CAP_ENERGY_FILTERING_CTL, "ENERGY_FILT" },
|
||||
{ ARCH_CAP_DOITM, "DOITM" },
|
||||
{ ARCH_CAP_SBDR_SSDP_NO, "SBDR_SSDP_N" },
|
||||
{ ARCH_CAP_FBSDP_NO, "FBSDP_NO" },
|
||||
{ ARCH_CAP_PSDP_NO, "PSDP_NO" },
|
||||
{ ARCH_CAP_FB_CLEAR, "FB_CLEAR" },
|
||||
{ ARCH_CAP_FB_CLEAR_CTRL, "FB_CLEAR_CT" },
|
||||
{ ARCH_CAP_RRSBA, "RRSBA" },
|
||||
{ ARCH_CAP_BHI_NO, "BHI_NO" },
|
||||
{ ARCH_CAP_XAPIC_DISABLE_STATUS, "XAPIC_DIS" },
|
||||
{ ARCH_CAP_OVERCLOCKING_STATUS, "OVERCLOCK" },
|
||||
{ ARCH_CAP_PBRSB_NO, "PBRSB_NO" },
|
||||
};
|
||||
|
||||
int
|
||||
@ -674,7 +703,7 @@ identifycpu(struct cpu_info *ci)
|
||||
ci->ci_feature_tpmflags |= TPM_ARAT;
|
||||
}
|
||||
|
||||
/* AMD speculation control features */
|
||||
/* speculation control features */
|
||||
if (!strcmp(cpu_vendor, "AuthenticAMD")) {
|
||||
if (ci->ci_pnfeatset >= 0x80000008) {
|
||||
CPUID(0x80000008, dummy, ci->ci_feature_amdspec_ebx,
|
||||
@ -685,6 +714,13 @@ identifycpu(struct cpu_info *ci)
|
||||
printf(",%s",
|
||||
cpu_amdspec_ebxfeatures[i].str);
|
||||
}
|
||||
} else if (!strcmp(cpu_vendor, "GenuineIntel") &&
|
||||
(ci->ci_feature_sefflags_edx & SEFF0EDX_ARCH_CAP)) {
|
||||
uint64_t msr = rdmsr(MSR_ARCH_CAPABILITIES);
|
||||
|
||||
for (i = 0; i < nitems(cpu_arch_cap_features); i++)
|
||||
if (msr & cpu_arch_cap_features[i].bit)
|
||||
printf(",%s", cpu_arch_cap_features[i].str);
|
||||
}
|
||||
|
||||
/* xsave subfeatures */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: locore.S,v 1.136 2023/07/10 03:32:10 guenther Exp $ */
|
||||
/* $OpenBSD: locore.S,v 1.138 2023/07/27 00:28:24 guenther Exp $ */
|
||||
/* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */
|
||||
|
||||
/*
|
||||
@ -473,31 +473,17 @@ bogus_proc_pmap:
|
||||
#endif /* DIAGNOSTIC */
|
||||
END(cpu_switchto)
|
||||
|
||||
ENTRY(cpu_idle_enter)
|
||||
ret
|
||||
lfence
|
||||
END(cpu_idle_enter)
|
||||
|
||||
ENTRY(cpu_idle_leave)
|
||||
ret
|
||||
lfence
|
||||
END(cpu_idle_leave)
|
||||
|
||||
/* placed here for correct static branch prediction in cpu_idle_* */
|
||||
NENTRY(retpoline_rax)
|
||||
JMP_RETPOLINE(rax)
|
||||
|
||||
ENTRY(cpu_idle_cycle)
|
||||
RETGUARD_SETUP(cpu_idle_cycle, r11)
|
||||
movq cpu_idle_cycle_fcn,%rax
|
||||
cmpq $0,%rax
|
||||
jne retpoline_rax
|
||||
ENTRY(cpu_idle_cycle_hlt)
|
||||
RETGUARD_SETUP(cpu_idle_cycle_hlt, r11)
|
||||
sti
|
||||
hlt
|
||||
RETGUARD_CHECK(cpu_idle_cycle, r11)
|
||||
RETGUARD_CHECK(cpu_idle_cycle_hlt, r11)
|
||||
ret
|
||||
lfence
|
||||
END(cpu_idle_cycle)
|
||||
END(cpu_idle_cycle_hlt)
|
||||
|
||||
/*
|
||||
* savectx(struct pcb *pcb);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: machdep.c,v 1.285 2023/07/10 03:32:10 guenther Exp $ */
|
||||
/* $OpenBSD: machdep.c,v 1.286 2023/07/27 00:28:25 guenther Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
|
||||
|
||||
/*-
|
||||
@ -160,7 +160,8 @@ char machine[] = MACHINE;
|
||||
/*
|
||||
* switchto vectors
|
||||
*/
|
||||
void (*cpu_idle_cycle_fcn)(void) = NULL;
|
||||
void cpu_idle_cycle_hlt(void);
|
||||
void (*cpu_idle_cycle_fcn)(void) = &cpu_idle_cycle_hlt;
|
||||
|
||||
/* the following is used externally for concurrent handlers */
|
||||
int setperf_prio = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: spl.S,v 1.19 2022/12/01 00:26:15 guenther Exp $ */
|
||||
/* $OpenBSD: spl.S,v 1.20 2023/07/27 00:30:07 guenther Exp $ */
|
||||
/* $NetBSD: spl.S,v 1.3 2004/06/28 09:13:11 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
@ -122,7 +122,8 @@ KIDTVEC(spllower)
|
||||
RETGUARD_PUSH(r11)
|
||||
movl %edi,%ebx
|
||||
leaq 1f(%rip),%r13 # address to resume loop at
|
||||
1: movl %ebx,%eax # get cpl
|
||||
1: endbr64
|
||||
movl %ebx,%eax # get cpl
|
||||
movq CPUVAR(IUNMASK)(,%rax,8),%rax
|
||||
cli
|
||||
andq CPUVAR(IPENDING),%rax # any non-masked bits left?
|
||||
@ -153,7 +154,8 @@ KIDTVEC(doreti)
|
||||
movq IF_PPL(%rsp),%rbx # get previous priority
|
||||
decl CPUVAR(IDEPTH)
|
||||
leaq 1f(%rip),%r13
|
||||
1: movl %ebx,%eax
|
||||
1: endbr64
|
||||
movl %ebx,%eax
|
||||
movq CPUVAR(IUNMASK)(,%rax,8),%rax
|
||||
cli
|
||||
andq CPUVAR(IPENDING),%rax
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ucode.c,v 1.5 2019/06/28 21:54:05 bluhm Exp $ */
|
||||
/* $OpenBSD: ucode.c,v 1.6 2023/07/23 01:46:37 jsg Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2018 Stefan Fritsch <fritsch@genua.de>
|
||||
* Copyright (c) 2018 Patrick Wildt <patrick@blueri.se>
|
||||
@ -72,6 +72,8 @@ size_t cpu_ucode_size;
|
||||
void cpu_ucode_setup(void);
|
||||
void cpu_ucode_apply(struct cpu_info *);
|
||||
|
||||
struct mutex cpu_ucode_mtx = MUTEX_INITIALIZER(IPL_HIGH);
|
||||
|
||||
/* Intel */
|
||||
void cpu_ucode_intel_apply(struct cpu_info *);
|
||||
struct intel_ucode_header *
|
||||
@ -82,7 +84,8 @@ int cpu_ucode_intel_match(struct intel_ucode_header *, uint32_t, uint32_t,
|
||||
uint32_t cpu_ucode_intel_rev(void);
|
||||
|
||||
struct intel_ucode_header *cpu_ucode_intel_applied;
|
||||
struct mutex cpu_ucode_intel_mtx = MUTEX_INITIALIZER(IPL_HIGH);
|
||||
|
||||
void cpu_ucode_amd_apply(struct cpu_info *);
|
||||
|
||||
void
|
||||
cpu_ucode_setup(void)
|
||||
@ -107,6 +110,99 @@ cpu_ucode_apply(struct cpu_info *ci)
|
||||
{
|
||||
if (strcmp(cpu_vendor, "GenuineIntel") == 0)
|
||||
cpu_ucode_intel_apply(ci);
|
||||
else if (strcmp(cpu_vendor, "AuthenticAMD") == 0)
|
||||
cpu_ucode_amd_apply(ci);
|
||||
}
|
||||
|
||||
#define AMD_MAGIC 0x00414d44
|
||||
|
||||
struct amd_equiv {
|
||||
uint32_t id;
|
||||
uint32_t a;
|
||||
uint32_t b;
|
||||
uint16_t eid;
|
||||
uint16_t c;
|
||||
} __packed;
|
||||
|
||||
struct amd_patch {
|
||||
uint32_t type;
|
||||
uint32_t len;
|
||||
uint32_t a;
|
||||
uint32_t level;
|
||||
uint8_t c[16];
|
||||
uint16_t eid;
|
||||
} __packed;
|
||||
|
||||
void
|
||||
cpu_ucode_amd_apply(struct cpu_info *ci)
|
||||
{
|
||||
uint64_t level;
|
||||
uint32_t magic, tlen, i;
|
||||
uint16_t eid = 0;
|
||||
uint32_t sig, ebx, ecx, edx;
|
||||
uint64_t start = 0;
|
||||
|
||||
if (cpu_ucode_data == NULL || cpu_ucode_size == 0) {
|
||||
DPRINTF(("%s: no microcode provided\n", __func__));
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Grab a mutex, because we are not allowed to run updates
|
||||
* simultaneously on HT siblings.
|
||||
*/
|
||||
mtx_enter(&cpu_ucode_mtx);
|
||||
|
||||
CPUID(1, sig, ebx, ecx, edx);
|
||||
|
||||
level = rdmsr(MSR_PATCH_LEVEL);
|
||||
DPRINTF(("%s: cur patch level 0x%llx\n", __func__, level));
|
||||
|
||||
memcpy(&magic, cpu_ucode_data, 4);
|
||||
if (magic != AMD_MAGIC) {
|
||||
DPRINTF(("%s: bad magic %x\n", __func__, magic));
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(&tlen, &cpu_ucode_data[8], 4);
|
||||
|
||||
/* find equivalence id matching our cpu signature */
|
||||
for (i = 12; i < 12 + tlen;) {
|
||||
struct amd_equiv ae;
|
||||
if (i + sizeof(ae) > cpu_ucode_size) {
|
||||
DPRINTF(("%s: truncated etable\n", __func__));
|
||||
goto out;
|
||||
}
|
||||
memcpy(&ae, &cpu_ucode_data[i], sizeof(ae));
|
||||
i += sizeof(ae);
|
||||
if (ae.id == sig)
|
||||
eid = ae.eid;
|
||||
}
|
||||
|
||||
/* look for newer patch with the equivalence id */
|
||||
while (i < cpu_ucode_size) {
|
||||
struct amd_patch ap;
|
||||
if (i + sizeof(ap) > cpu_ucode_size) {
|
||||
DPRINTF(("%s: truncated ptable\n", __func__));
|
||||
goto out;
|
||||
}
|
||||
memcpy(&ap, &cpu_ucode_data[i], sizeof(ap));
|
||||
if (ap.type == 1 && ap.eid == eid && ap.level > level)
|
||||
start = (uint64_t)&cpu_ucode_data[i + 8];
|
||||
if (i + ap.len + 8 > cpu_ucode_size) {
|
||||
DPRINTF(("%s: truncated patch\n", __func__));
|
||||
goto out;
|
||||
}
|
||||
i += ap.len + 8;
|
||||
}
|
||||
|
||||
if (start != 0) {
|
||||
wrmsr(MSR_PATCH_LOADER, start);
|
||||
level = rdmsr(MSR_PATCH_LEVEL);
|
||||
DPRINTF(("%s: new patch level 0x%llx\n", __func__, level));
|
||||
}
|
||||
out:
|
||||
mtx_leave(&cpu_ucode_mtx);
|
||||
}
|
||||
|
||||
void
|
||||
@ -125,7 +221,7 @@ cpu_ucode_intel_apply(struct cpu_info *ci)
|
||||
* Grab a mutex, because we are not allowed to run updates
|
||||
* simultaneously on HT siblings.
|
||||
*/
|
||||
mtx_enter(&cpu_ucode_intel_mtx);
|
||||
mtx_enter(&cpu_ucode_mtx);
|
||||
|
||||
old_rev = cpu_ucode_intel_rev();
|
||||
update = cpu_ucode_intel_applied;
|
||||
@ -159,7 +255,7 @@ cpu_ucode_intel_apply(struct cpu_info *ci)
|
||||
}
|
||||
|
||||
out:
|
||||
mtx_leave(&cpu_ucode_intel_mtx);
|
||||
mtx_leave(&cpu_ucode_mtx);
|
||||
}
|
||||
|
||||
struct intel_ucode_header *
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: vector.S,v 1.92 2023/04/17 00:02:14 deraadt Exp $ */
|
||||
/* $OpenBSD: vector.S,v 1.93 2023/07/27 00:30:07 guenther Exp $ */
|
||||
/* $NetBSD: vector.S,v 1.5 2004/06/28 09:13:11 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
@ -551,6 +551,7 @@ IDTVEC(intr_lapic_ipi)
|
||||
jae 2f
|
||||
END(INTRENTRY_LABEL(intr_lapic_ipi))
|
||||
KIDTVEC_FALLTHROUGH(resume_lapic_ipi)
|
||||
endbr64
|
||||
1:
|
||||
incl CPUVAR(IDEPTH)
|
||||
movl $IPL_IPI,CPUVAR(ILEVEL)
|
||||
@ -757,6 +758,7 @@ IDTVEC(intr_lapic_ltimer)
|
||||
jae 2f
|
||||
END(INTRENTRY_LABEL(intr_lapic_ltimer))
|
||||
KIDTVEC_FALLTHROUGH(resume_lapic_ltimer)
|
||||
endbr64
|
||||
1:
|
||||
incl CPUVAR(IDEPTH)
|
||||
movl $IPL_CLOCK,CPUVAR(ILEVEL)
|
||||
@ -790,6 +792,7 @@ IDTVEC(intr_xen_upcall)
|
||||
jae 2f
|
||||
END(INTRENTRY_LABEL(intr_xen_upcall))
|
||||
KIDTVEC_FALLTHROUGH(resume_xen_upcall)
|
||||
endbr64
|
||||
1:
|
||||
incl CPUVAR(IDEPTH)
|
||||
movl $IPL_NET,CPUVAR(ILEVEL)
|
||||
@ -822,6 +825,7 @@ IDTVEC(intr_hyperv_upcall)
|
||||
jae 2f
|
||||
END(INTRENTRY_LABEL(intr_hyperv_upcall))
|
||||
KIDTVEC_FALLTHROUGH(resume_hyperv_upcall)
|
||||
endbr64
|
||||
1:
|
||||
incl CPUVAR(IDEPTH)
|
||||
movl $IPL_NET,CPUVAR(ILEVEL)
|
||||
@ -852,6 +856,7 @@ KIDTVEC(recurse_##name##num) ;\
|
||||
INTR_RECURSE ;\
|
||||
END(Xrecurse_##name##num) ;\
|
||||
KIDTVEC_FALLTHROUGH(resume_##name##num) \
|
||||
endbr64 ;\
|
||||
movq $IREENT_MAGIC,TF_ERR(%rsp) ;\
|
||||
movl %ebx,%r13d ;\
|
||||
movq CPUVAR(ISOURCES) + (num) * 8, %r14 ;\
|
||||
@ -1268,6 +1273,7 @@ NENTRY(retpoline_r13)
|
||||
END(retpoline_r13)
|
||||
|
||||
KIDTVEC(softtty)
|
||||
endbr64
|
||||
movl $IPL_SOFTTTY, CPUVAR(ILEVEL)
|
||||
sti
|
||||
incl CPUVAR(IDEPTH)
|
||||
@ -1278,6 +1284,7 @@ KIDTVEC(softtty)
|
||||
END(Xsofttty)
|
||||
|
||||
KIDTVEC(softnet)
|
||||
endbr64
|
||||
movl $IPL_SOFTNET, CPUVAR(ILEVEL)
|
||||
sti
|
||||
incl CPUVAR(IDEPTH)
|
||||
@ -1288,6 +1295,7 @@ KIDTVEC(softnet)
|
||||
END(Xsoftnet)
|
||||
|
||||
KIDTVEC(softclock)
|
||||
endbr64
|
||||
movl $IPL_SOFTCLOCK, CPUVAR(ILEVEL)
|
||||
sti
|
||||
incl CPUVAR(IDEPTH)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: cpu.h,v 1.155 2023/07/04 17:29:32 cheloha Exp $ */
|
||||
/* $OpenBSD: cpu.h,v 1.158 2023/07/27 00:28:24 guenther Exp $ */
|
||||
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
|
||||
|
||||
/*-
|
||||
@ -208,6 +208,7 @@ struct cpu_info {
|
||||
u_int64_t ci_hz_aperf;
|
||||
#if defined(GPROF) || defined(DDBPROF)
|
||||
struct gmonparam *ci_gmon;
|
||||
struct clockintr *ci_gmonclock;
|
||||
#endif
|
||||
u_int32_t ci_vmm_flags;
|
||||
#define CI_VMM_VMX (1 << 0)
|
||||
@ -403,7 +404,10 @@ void cpu_reset(void);
|
||||
void x86_64_proc0_tss_ldt_init(void);
|
||||
void cpu_proc_fork(struct proc *, struct proc *);
|
||||
int amd64_pa_used(paddr_t);
|
||||
#define cpu_idle_enter() do { /* nothing */ } while (0)
|
||||
extern void (*cpu_idle_cycle_fcn)(void);
|
||||
#define cpu_idle_cycle() (*cpu_idle_cycle_fcn)()
|
||||
#define cpu_idle_leave() do { /* nothing */ } while (0)
|
||||
|
||||
struct region_descriptor;
|
||||
void lgdt(struct region_descriptor *);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: frameasm.h,v 1.26 2023/04/17 00:02:14 deraadt Exp $ */
|
||||
/* $OpenBSD: frameasm.h,v 1.27 2023/07/27 00:30:07 guenther Exp $ */
|
||||
/* $NetBSD: frameasm.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */
|
||||
|
||||
#ifndef _AMD64_MACHINE_FRAMEASM_H
|
||||
@ -111,6 +111,7 @@ _ENTRY(INTRENTRY_LABEL(label)) /* from kernel */ \
|
||||
* to return to. %r10 and %r11 are scratch.
|
||||
*/
|
||||
#define INTR_RECURSE \
|
||||
endbr64 ; \
|
||||
/* fake the iretq_frame */ ; \
|
||||
movq %rsp,%r10 ; \
|
||||
movl %ss,%r11d ; \
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: specialreg.h,v 1.104 2023/07/21 04:04:51 guenther Exp $ */
|
||||
/* $OpenBSD: specialreg.h,v 1.106 2023/07/27 01:51:35 guenther Exp $ */
|
||||
/* $NetBSD: specialreg.h,v 1.1 2003/04/26 18:39:48 fvdl Exp $ */
|
||||
/* $NetBSD: x86/specialreg.h,v 1.2 2003/04/25 21:54:30 fvdl Exp $ */
|
||||
|
||||
@ -334,12 +334,14 @@
|
||||
/*
|
||||
* AMD CPUID function 0x80000008 EBX bits
|
||||
*/
|
||||
#define CPUIDEBX_INVLPGB (1ULL << 3) /* INVLPG w/broadcast */
|
||||
#define CPUIDEBX_IBPB (1ULL << 12) /* Speculation Control IBPB */
|
||||
#define CPUIDEBX_IBRS (1ULL << 14) /* Speculation Control IBRS */
|
||||
#define CPUIDEBX_STIBP (1ULL << 15) /* Speculation Control STIBP */
|
||||
#define CPUIDEBX_IBRS_ALWAYSON (1ULL << 16) /* IBRS always on mode */
|
||||
#define CPUIDEBX_STIBP_ALWAYSON (1ULL << 17) /* STIBP always on mode */
|
||||
#define CPUIDEBX_IBRS_PREF (1ULL << 18) /* IBRS preferred */
|
||||
#define CPUIDEBX_IBRS_SAME_MODE (1ULL << 19) /* IBRS not mode-specific */
|
||||
#define CPUIDEBX_SSBD (1ULL << 24) /* Speculation Control SSBD */
|
||||
#define CPUIDEBX_VIRT_SSBD (1ULL << 25) /* Virt Spec Control SSBD */
|
||||
#define CPUIDEBX_SSBD_NOTREQ (1ULL << 26) /* SSBD not required */
|
||||
@ -590,6 +592,7 @@
|
||||
#define MSR_DE_CFG 0xc0011029 /* Decode Configuration */
|
||||
#define DE_CFG_721 0x00000001 /* errata 721 */
|
||||
#define DE_CFG_SERIALIZE_LFENCE (1 << 1) /* Enable serializing lfence */
|
||||
#define DE_CFG_SERIALIZE_9 (1 << 9) /* Zenbleed chickenbit */
|
||||
|
||||
#define IPM_C1E_CMP_HLT 0x10000000
|
||||
#define IPM_SMI_CMP_HLT 0x08000000
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: clock.c,v 1.39 2023/02/04 19:19:36 cheloha Exp $ */
|
||||
/* $OpenBSD: clock.c,v 1.40 2023/07/25 18:16:19 cheloha Exp $ */
|
||||
/* $NetBSD: clock.c,v 1.1 2003/04/26 18:39:50 fvdl Exp $ */
|
||||
|
||||
/*-
|
||||
@ -519,7 +519,6 @@ setstatclockrate(int arg)
|
||||
mc146818_write(NULL, MC_REGA,
|
||||
MC_BASE_32_KHz | MC_RATE_1024_Hz);
|
||||
}
|
||||
clockintr_setstatclockrate(arg);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: conf.c,v 1.56 2023/04/25 10:06:12 kn Exp $ */
|
||||
/* $OpenBSD: conf.c,v 1.57 2023/07/22 10:11:19 jsg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Michael Shalayeff
|
||||
@ -41,7 +41,7 @@
|
||||
#include <biosdev.h>
|
||||
#include <dev/cons.h>
|
||||
|
||||
const char version[] = "3.56";
|
||||
const char version[] = "3.65";
|
||||
int debug = 1;
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: conf.c,v 1.50 2023/04/25 10:06:12 kn Exp $ */
|
||||
/* $OpenBSD: conf.c,v 1.51 2023/07/22 10:11:19 jsg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 Tom Cosgrove
|
||||
@ -42,7 +42,7 @@
|
||||
#include <biosdev.h>
|
||||
#include <dev/cons.h>
|
||||
|
||||
const char version[] = "3.56";
|
||||
const char version[] = "3.65";
|
||||
int debug = 1;
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: conf.c,v 1.41 2023/04/25 10:11:20 kn Exp $ */
|
||||
/* $OpenBSD: conf.c,v 1.42 2023/07/22 10:11:19 jsg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Michael Shalayeff
|
||||
@ -40,7 +40,7 @@
|
||||
#include "efidev.h"
|
||||
#include "efipxe.h"
|
||||
|
||||
const char version[] = "3.64";
|
||||
const char version[] = "3.65";
|
||||
|
||||
#ifdef EFI_DEBUG
|
||||
int debug = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: exec_i386.c,v 1.10 2023/02/23 19:48:21 miod Exp $ */
|
||||
/* $OpenBSD: exec_i386.c,v 1.11 2023/07/22 10:11:19 jsg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997-1998 Michael Shalayeff
|
||||
@ -180,7 +180,8 @@ ucode_load(void)
|
||||
|
||||
CPUID(0, dummy, vendor[0], vendor[2], vendor[1]);
|
||||
vendor[3] = 0; /* NULL-terminate */
|
||||
if (strcmp((char *)vendor, "GenuineIntel") != 0)
|
||||
if (strcmp((char *)vendor, "GenuineIntel") != 0 &&
|
||||
strcmp((char *)vendor, "AuthenticAMD") != 0)
|
||||
return;
|
||||
|
||||
CPUID(1, signature, dummy, dummy, dummy);
|
||||
@ -192,8 +193,22 @@ ucode_load(void)
|
||||
}
|
||||
stepping = (signature >> 0) & 0x0f;
|
||||
|
||||
snprintf(path, sizeof(path), "%s:/etc/firmware/intel/%02x-%02x-%02x",
|
||||
cmd.bootdev, family, model, stepping);
|
||||
if (strcmp((char *)vendor, "GenuineIntel") == 0) {
|
||||
snprintf(path, sizeof(path),
|
||||
"%s:/etc/firmware/intel/%02x-%02x-%02x",
|
||||
cmd.bootdev, family, model, stepping);
|
||||
} else if (strcmp((char *)vendor, "AuthenticAMD") == 0) {
|
||||
if (family < 0x10)
|
||||
return;
|
||||
else if (family <= 0x14)
|
||||
snprintf(path, sizeof(path),
|
||||
"%s:/etc/firmware/amd/microcode_amd.bin",
|
||||
cmd.bootdev);
|
||||
else
|
||||
snprintf(path, sizeof(path),
|
||||
"%s:/etc/firmware/amd/microcode_amd_fam%02xh.bin",
|
||||
cmd.bootdev, family);
|
||||
}
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd == -1)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: exec_i386.c,v 1.37 2022/07/11 19:45:02 kettenis Exp $ */
|
||||
/* $OpenBSD: exec_i386.c,v 1.38 2023/07/22 10:11:19 jsg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997-1998 Michael Shalayeff
|
||||
@ -202,7 +202,8 @@ ucode_load(void)
|
||||
|
||||
CPUID(0, dummy, vendor[0], vendor[2], vendor[1]);
|
||||
vendor[3] = 0; /* NULL-terminate */
|
||||
if (strcmp((char *)vendor, "GenuineIntel") != 0)
|
||||
if (strcmp((char *)vendor, "GenuineIntel") != 0 &&
|
||||
strcmp((char *)vendor, "AuthenticAMD") != 0)
|
||||
return;
|
||||
|
||||
CPUID(1, signature, dummy, dummy, dummy);
|
||||
@ -214,8 +215,22 @@ ucode_load(void)
|
||||
}
|
||||
stepping = (signature >> 0) & 0x0f;
|
||||
|
||||
snprintf(path, sizeof(path), "%s:/etc/firmware/intel/%02x-%02x-%02x",
|
||||
cmd.bootdev, family, model, stepping);
|
||||
if (strcmp((char *)vendor, "GenuineIntel") == 0) {
|
||||
snprintf(path, sizeof(path),
|
||||
"%s:/etc/firmware/intel/%02x-%02x-%02x",
|
||||
cmd.bootdev, family, model, stepping);
|
||||
} else if (strcmp((char *)vendor, "AuthenticAMD") == 0) {
|
||||
if (family < 0x10)
|
||||
return;
|
||||
else if (family <= 0x14)
|
||||
snprintf(path, sizeof(path),
|
||||
"%s:/etc/firmware/amd/microcode_amd.bin",
|
||||
cmd.bootdev);
|
||||
else
|
||||
snprintf(path, sizeof(path),
|
||||
"%s:/etc/firmware/amd/microcode_amd_fam%02xh.bin",
|
||||
cmd.bootdev, family);
|
||||
}
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd == -1)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: conf.c,v 1.55 2023/04/25 10:06:12 kn Exp $ */
|
||||
/* $OpenBSD: conf.c,v 1.56 2023/07/22 10:11:20 jsg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 Tom Cosgrove
|
||||
@ -44,7 +44,7 @@
|
||||
#include "pxeboot.h"
|
||||
#include "pxe_net.h"
|
||||
|
||||
const char version[] = "3.56";
|
||||
const char version[] = "3.65";
|
||||
int debug = 0;
|
||||
|
||||
void (*sa_cleanup)(void) = pxe_shutdown;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: agtimer.c,v 1.17 2023/02/04 19:19:36 cheloha Exp $ */
|
||||
/* $OpenBSD: agtimer.c,v 1.18 2023/07/25 18:16:19 cheloha Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2011 Dale Rahn <drahn@openbsd.org>
|
||||
* Copyright (c) 2013 Patrick Wildt <patrick@blueri.se>
|
||||
@ -288,7 +288,6 @@ agtimer_delay(u_int usecs)
|
||||
void
|
||||
agtimer_setstatclockrate(int newhz)
|
||||
{
|
||||
clockintr_setstatclockrate(newhz);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: amptimer.c,v 1.16 2023/02/04 19:19:36 cheloha Exp $ */
|
||||
/* $OpenBSD: amptimer.c,v 1.17 2023/07/25 18:16:19 cheloha Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2011 Dale Rahn <drahn@openbsd.org>
|
||||
*
|
||||
@ -343,7 +343,6 @@ amptimer_delay(u_int usecs)
|
||||
void
|
||||
amptimer_setstatclockrate(int newhz)
|
||||
{
|
||||
clockintr_setstatclockrate(newhz);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: cpu.h,v 1.62 2023/01/17 02:27:14 cheloha Exp $ */
|
||||
/* $OpenBSD: cpu.h,v 1.63 2023/07/25 18:16:19 cheloha Exp $ */
|
||||
/* $NetBSD: cpu.h,v 1.34 2003/06/23 11:01:08 martin Exp $ */
|
||||
|
||||
/*
|
||||
@ -198,6 +198,7 @@ struct cpu_info {
|
||||
|
||||
#ifdef GPROF
|
||||
struct gmonparam *ci_gmon;
|
||||
struct clockintr *ci_gmonclock;
|
||||
#endif
|
||||
struct clockintr_queue ci_queue;
|
||||
char ci_panicbuf[512];
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: GENERIC,v 1.276 2023/07/19 20:27:20 kettenis Exp $
|
||||
# $OpenBSD: GENERIC,v 1.277 2023/07/22 22:43:53 patrick Exp $
|
||||
#
|
||||
# GENERIC machine description file
|
||||
#
|
||||
@ -346,6 +346,7 @@ qcpon* at qcpmic?
|
||||
qcpwm* at qcpmic?
|
||||
qcrng* at fdt?
|
||||
qcrtc* at qcpmic?
|
||||
qcsdam* at qcpmic?
|
||||
|
||||
# Sunxi SoCs
|
||||
sxipio* at fdt? early 1 # GPIO pins for leds & PHYs
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: RAMDISK,v 1.208 2023/07/19 20:27:20 kettenis Exp $
|
||||
# $OpenBSD: RAMDISK,v 1.209 2023/07/22 22:43:53 patrick Exp $
|
||||
|
||||
machine arm64
|
||||
maxusers 4
|
||||
@ -269,6 +269,7 @@ qcpon* at qcpmic?
|
||||
qcpwm* at qcpmic?
|
||||
qcrng* at fdt?
|
||||
qcrtc* at qcpmic?
|
||||
qcsdam* at qcpmic?
|
||||
|
||||
# Sunxi SoCs
|
||||
sxipio* at fdt? early 1 # GPIO pins for leds & PHYs
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: agtimer.c,v 1.22 2023/02/04 19:19:36 cheloha Exp $ */
|
||||
/* $OpenBSD: agtimer.c,v 1.23 2023/07/25 18:16:19 cheloha Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2011 Dale Rahn <drahn@openbsd.org>
|
||||
* Copyright (c) 2013 Patrick Wildt <patrick@blueri.se>
|
||||
@ -354,7 +354,6 @@ agtimer_delay(u_int usecs)
|
||||
void
|
||||
agtimer_setstatclockrate(int newhz)
|
||||
{
|
||||
clockintr_setstatclockrate(newhz);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: apldart.c,v 1.16 2022/07/21 18:24:24 kettenis Exp $ */
|
||||
/* $OpenBSD: apldart.c,v 1.17 2023/07/23 11:47:20 kettenis Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
|
||||
*
|
||||
@ -28,6 +28,7 @@
|
||||
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofw_misc.h>
|
||||
#include <dev/ofw/ofw_power.h>
|
||||
#include <dev/ofw/fdt.h>
|
||||
|
||||
/*
|
||||
@ -161,6 +162,8 @@ struct apldart_softc {
|
||||
|
||||
struct machine_bus_dma_tag sc_bus_dmat;
|
||||
struct iommu_device sc_id;
|
||||
|
||||
int sc_do_suspend;
|
||||
};
|
||||
|
||||
struct apldart_map_state {
|
||||
@ -187,9 +190,11 @@ void apldart_dmamem_free(bus_dma_tag_t, struct apldart_dmamem *);
|
||||
|
||||
int apldart_match(struct device *, void *, void *);
|
||||
void apldart_attach(struct device *, struct device *, void *);
|
||||
int apldart_activate(struct device *, int);
|
||||
|
||||
const struct cfattach apldart_ca = {
|
||||
sizeof (struct apldart_softc), apldart_match, apldart_attach
|
||||
sizeof (struct apldart_softc), apldart_match, apldart_attach, NULL,
|
||||
apldart_activate
|
||||
};
|
||||
|
||||
struct cfdriver apldart_cd = {
|
||||
@ -255,8 +260,10 @@ apldart_attach(struct device *parent, struct device *self, void *aux)
|
||||
}
|
||||
|
||||
sc->sc_dmat = faa->fa_dmat;
|
||||
|
||||
sc->sc_node = faa->fa_node;
|
||||
|
||||
power_domain_enable(sc->sc_node);
|
||||
|
||||
if (OF_is_compatible(sc->sc_node, "apple,t8110-dart")) {
|
||||
params4 = HREAD4(sc, DART_T8110_PARAMS4);
|
||||
sc->sc_nsid = params4 & DART_T8110_PARAMS4_NSID_MASK;
|
||||
@ -321,6 +328,11 @@ apldart_attach(struct device *parent, struct device *self, void *aux)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We have full control over this DART, so do suspend it.
|
||||
*/
|
||||
sc->sc_do_suspend = 1;
|
||||
|
||||
/*
|
||||
* Use bypass mode if supported. This avoids an issue with
|
||||
* the USB3 controllers which need mappings entered into two
|
||||
@ -433,6 +445,83 @@ apldart_attach(struct device *parent, struct device *self, void *aux)
|
||||
iommu_device_register(&sc->sc_id);
|
||||
}
|
||||
|
||||
void
|
||||
apldart_suspend(struct apldart_softc *sc)
|
||||
{
|
||||
if (!sc->sc_do_suspend)
|
||||
return;
|
||||
|
||||
power_domain_disable(sc->sc_node);
|
||||
}
|
||||
|
||||
void
|
||||
apldart_resume(struct apldart_softc *sc)
|
||||
{
|
||||
paddr_t pa;
|
||||
int ntte, nl1, nl2;
|
||||
uint32_t params2;
|
||||
int sid, idx;
|
||||
|
||||
if (!sc->sc_do_suspend)
|
||||
return;
|
||||
|
||||
power_domain_enable(sc->sc_node);
|
||||
|
||||
params2 = HREAD4(sc, DART_PARAMS2);
|
||||
if (params2 & DART_PARAMS2_BYPASS_SUPPORT) {
|
||||
for (sid = 0; sid < sc->sc_nsid; sid++)
|
||||
HWRITE4(sc, DART_TCR(sc, sid), sc->sc_tcr_bypass);
|
||||
return;
|
||||
}
|
||||
|
||||
ntte = howmany(sc->sc_dvaend, DART_PAGE_SIZE);
|
||||
nl2 = howmany(ntte, DART_PAGE_SIZE / sizeof(uint64_t));
|
||||
nl1 = howmany(nl2, DART_PAGE_SIZE / sizeof(uint64_t));
|
||||
|
||||
/* Install page tables. */
|
||||
for (sid = 0; sid < sc->sc_nsid; sid++) {
|
||||
pa = APLDART_DMA_DVA(sc->sc_l1);
|
||||
for (idx = 0; idx < nl1; idx++) {
|
||||
HWRITE4(sc, DART_TTBR(sc, sid, idx),
|
||||
(pa >> DART_TTBR_SHIFT) | sc->sc_ttbr_valid);
|
||||
pa += DART_PAGE_SIZE;
|
||||
}
|
||||
}
|
||||
sc->sc_flush_tlb(sc);
|
||||
|
||||
/* Enable all streams. */
|
||||
for (idx = 0; idx < howmany(sc->sc_nsid, 32); idx++)
|
||||
HWRITE4(sc, DART_SID_ENABLE(sc, idx), ~0);
|
||||
|
||||
/* Enable translations. */
|
||||
for (sid = 0; sid < sc->sc_nsid; sid++)
|
||||
HWRITE4(sc, DART_TCR(sc, sid), sc->sc_tcr_translate_enable);
|
||||
|
||||
if (OF_is_compatible(sc->sc_node, "apple,t8110-dart")) {
|
||||
HWRITE4(sc, DART_T8110_ERROR, HREAD4(sc, DART_T8110_ERROR));
|
||||
HWRITE4(sc, DART_T8110_ERROR_MASK, 0);
|
||||
} else {
|
||||
HWRITE4(sc, DART_T8020_ERROR, HREAD4(sc, DART_T8020_ERROR));
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
apldart_activate(struct device *self, int act)
|
||||
{
|
||||
struct apldart_softc *sc = (struct apldart_softc *)self;
|
||||
|
||||
switch (act) {
|
||||
case DVACT_SUSPEND:
|
||||
apldart_suspend(sc);
|
||||
break;
|
||||
case DVACT_RESUME:
|
||||
apldart_resume(sc);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bus_dma_tag_t
|
||||
apldart_map(void *cookie, uint32_t *cells, bus_dma_tag_t dmat)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: apldma.c,v 1.5 2022/11/26 21:35:22 kettenis Exp $ */
|
||||
/* $OpenBSD: apldma.c,v 1.6 2023/07/26 11:09:24 kettenis Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2022 Mark Kettenis <kettenis@openbsd.org>
|
||||
*
|
||||
@ -110,9 +110,11 @@ struct apldma_softc *apldma_sc;
|
||||
|
||||
int apldma_match(struct device *, void *, void *);
|
||||
void apldma_attach(struct device *, struct device *, void *);
|
||||
int apldma_activate(struct device *, int);
|
||||
|
||||
const struct cfattach apldma_ca = {
|
||||
sizeof (struct apldma_softc), apldma_match, apldma_attach
|
||||
sizeof (struct apldma_softc), apldma_match, apldma_attach, NULL,
|
||||
apldma_activate
|
||||
};
|
||||
|
||||
struct cfdriver apldma_cd = {
|
||||
@ -197,6 +199,23 @@ unmap:
|
||||
bus_space_unmap(sc->sc_iot, sc->sc_ioh, faa->fa_reg[0].size);
|
||||
}
|
||||
|
||||
int
|
||||
apldma_activate(struct device *self, int act)
|
||||
{
|
||||
struct apldma_softc *sc = (struct apldma_softc *)self;
|
||||
|
||||
switch (act) {
|
||||
case DVACT_SUSPEND:
|
||||
power_domain_disable(sc->sc_node);
|
||||
break;
|
||||
case DVACT_RESUME:
|
||||
power_domain_enable(sc->sc_node);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
apldma_fill_descriptors(struct apldma_channel *ac)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: aplmbox.c,v 1.5 2022/12/21 22:30:42 kettenis Exp $ */
|
||||
/* $OpenBSD: aplmbox.c,v 1.6 2023/07/23 11:17:49 kettenis Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
|
||||
*
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofw_misc.h>
|
||||
#include <dev/ofw/ofw_power.h>
|
||||
#include <dev/ofw/fdt.h>
|
||||
|
||||
#include <arm64/dev/aplmbox.h>
|
||||
@ -111,6 +112,8 @@ aplmbox_attach(struct device *parent, struct device *self, void *aux)
|
||||
|
||||
printf("\n");
|
||||
|
||||
power_domain_enable(faa->fa_node);
|
||||
|
||||
sc->sc_md.md_node = faa->fa_node;
|
||||
sc->sc_md.md_cookie = sc;
|
||||
sc->sc_md.md_channel = aplmbox_channel;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: aplmca.c,v 1.6 2023/02/03 13:20:21 kettenis Exp $ */
|
||||
/* $OpenBSD: aplmca.c,v 1.7 2023/07/26 11:09:24 kettenis Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2022 Mark Kettenis <kettenis@openbsd.org>
|
||||
*
|
||||
@ -152,9 +152,11 @@ const struct audio_hw_if aplmca_hw_if = {
|
||||
|
||||
int aplmca_match(struct device *, void *, void *);
|
||||
void aplmca_attach(struct device *, struct device *, void *);
|
||||
int aplmca_activate(struct device *, int);
|
||||
|
||||
const struct cfattach aplmca_ca = {
|
||||
sizeof (struct aplmca_softc), aplmca_match, aplmca_attach
|
||||
sizeof (struct aplmca_softc), aplmca_match, aplmca_attach, NULL,
|
||||
aplmca_activate
|
||||
};
|
||||
|
||||
struct cfdriver aplmca_cd = {
|
||||
@ -223,6 +225,32 @@ aplmca_attach(struct device *parent, struct device *self, void *aux)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
aplmca_activate(struct device *self, int act)
|
||||
{
|
||||
struct aplmca_softc *sc = (struct aplmca_softc *)self;
|
||||
int i;
|
||||
|
||||
switch (act) {
|
||||
case DVACT_SUSPEND:
|
||||
for (i = 0; i < sc->sc_nclusters; i++) {
|
||||
if (sc->sc_ad[i].ad_ac)
|
||||
power_domain_disable_idx(sc->sc_node, i + 1);
|
||||
}
|
||||
power_domain_disable_idx(sc->sc_node, 0);
|
||||
break;
|
||||
case DVACT_RESUME:
|
||||
power_domain_enable_idx(sc->sc_node, 0);
|
||||
for (i = 0; i < sc->sc_nclusters; i++) {
|
||||
if (sc->sc_ad[i].ad_ac)
|
||||
power_domain_enable_idx(sc->sc_node, i + 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
aplmca_dai_init(struct aplmca_softc *sc, int port)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: aplpinctrl.c,v 1.7 2023/03/23 11:40:42 jsg Exp $ */
|
||||
/* $OpenBSD: aplpinctrl.c,v 1.8 2023/07/23 11:17:50 kettenis Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
|
||||
*
|
||||
@ -28,6 +28,7 @@
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofw_gpio.h>
|
||||
#include <dev/ofw/ofw_pinctrl.h>
|
||||
#include <dev/ofw/ofw_power.h>
|
||||
#include <dev/ofw/fdt.h>
|
||||
|
||||
#define APPLE_PIN(pinmux) ((pinmux) & 0xffff)
|
||||
@ -136,6 +137,8 @@ aplpinctrl_attach(struct device *parent, struct device *self, void *aux)
|
||||
return;
|
||||
}
|
||||
|
||||
power_domain_enable(faa->fa_node);
|
||||
|
||||
pinctrl_register(faa->fa_node, aplpinctrl_pinctrl, sc);
|
||||
|
||||
OF_getpropintarray(faa->fa_node, "gpio-ranges",
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: aplspi.c,v 1.4 2022/04/06 18:59:26 naddy Exp $ */
|
||||
/* $OpenBSD: aplspi.c,v 1.5 2023/07/23 11:17:50 kettenis Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
|
||||
*
|
||||
@ -30,6 +30,7 @@
|
||||
#include <dev/ofw/ofw_clock.h>
|
||||
#include <dev/ofw/ofw_gpio.h>
|
||||
#include <dev/ofw/ofw_pinctrl.h>
|
||||
#include <dev/ofw/ofw_power.h>
|
||||
#include <dev/ofw/fdt.h>
|
||||
|
||||
#define SPI_CLKCFG 0x00
|
||||
@ -147,6 +148,7 @@ aplspi_attach(struct device *parent, struct device *self, void *aux)
|
||||
|
||||
sc->sc_pfreq = clock_get_frequency(sc->sc_node, NULL);
|
||||
|
||||
power_domain_enable(sc->sc_node);
|
||||
pinctrl_byname(sc->sc_node, "default");
|
||||
|
||||
/* Configure CS# pin for manual control. */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: cpu.h,v 1.37 2023/07/13 08:33:36 kettenis Exp $ */
|
||||
/* $OpenBSD: cpu.h,v 1.38 2023/07/25 18:16:20 cheloha Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
|
||||
*
|
||||
@ -172,6 +172,7 @@ struct cpu_info {
|
||||
|
||||
#ifdef GPROF
|
||||
struct gmonparam *ci_gmon;
|
||||
struct clockintr *ci_gmonclock;
|
||||
#endif
|
||||
struct clockintr_queue ci_queue;
|
||||
char ci_panicbuf[512];
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: dmtimer.c,v 1.18 2023/02/04 19:19:36 cheloha Exp $ */
|
||||
/* $OpenBSD: dmtimer.c,v 1.19 2023/07/25 18:16:19 cheloha Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
|
||||
* Copyright (c) 2013 Raphael Graf <r@undefined.ch>
|
||||
@ -317,7 +317,6 @@ dmtimer_delay(u_int usecs)
|
||||
void
|
||||
dmtimer_setstatclockrate(int newhz)
|
||||
{
|
||||
clockintr_setstatclockrate(newhz);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: gptimer.c,v 1.19 2023/02/04 19:19:36 cheloha Exp $ */
|
||||
/* $OpenBSD: gptimer.c,v 1.20 2023/07/25 18:16:19 cheloha Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
|
||||
*
|
||||
@ -326,7 +326,6 @@ gptimer_delay(u_int usecs)
|
||||
void
|
||||
gptimer_setstatclockrate(int newhz)
|
||||
{
|
||||
clockintr_setstatclockrate(newhz);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sxitimer.c,v 1.20 2023/02/04 19:19:36 cheloha Exp $ */
|
||||
/* $OpenBSD: sxitimer.c,v 1.21 2023/07/25 18:16:19 cheloha Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
|
||||
* Copyright (c) 2013 Raphael Graf <r@undefined.ch>
|
||||
@ -299,7 +299,6 @@ sxitimer_delay(u_int usecs)
|
||||
void
|
||||
sxitimer_setstatclockrate(int newhz)
|
||||
{
|
||||
clockintr_setstatclockrate(newhz);
|
||||
}
|
||||
|
||||
u_int
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: machdep.c,v 1.663 2023/01/30 10:49:05 jsg Exp $ */
|
||||
/* $OpenBSD: machdep.c,v 1.665 2023/07/25 04:42:02 deraadt Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
@ -1639,6 +1639,7 @@ identifycpu(struct cpu_info *ci)
|
||||
char *cpu_device = ci->ci_dev->dv_xname;
|
||||
int skipspace;
|
||||
extern uint32_t cpu_meltdown;
|
||||
uint64_t msr, nmsr;
|
||||
|
||||
if (cpuid_level == -1) {
|
||||
name = "486DX";
|
||||
@ -1987,13 +1988,17 @@ identifycpu(struct cpu_info *ci)
|
||||
*/
|
||||
if (!strcmp(cpu_vendor, "AuthenticAMD")) {
|
||||
if (ci->ci_family >= 0x10 && ci->ci_family != 0x11) {
|
||||
uint64_t msr;
|
||||
|
||||
msr = rdmsr(MSR_DE_CFG);
|
||||
if ((msr & DE_CFG_SERIALIZE_LFENCE) == 0) {
|
||||
msr |= DE_CFG_SERIALIZE_LFENCE;
|
||||
wrmsr(MSR_DE_CFG, msr);
|
||||
}
|
||||
nmsr = msr = rdmsr(MSR_DE_CFG);
|
||||
nmsr |= DE_CFG_SERIALIZE_LFENCE;
|
||||
if (msr != nmsr)
|
||||
wrmsr(MSR_DE_CFG, nmsr);
|
||||
}
|
||||
if (family == 0x17 && ci->ci_model >= 0x31 &&
|
||||
(cpu_ecxfeature & CPUIDECX_HV) == 0) {
|
||||
nmsr = msr = rdmsr(MSR_DE_CFG);
|
||||
nmsr |= DE_CFG_SERIALIZE_9;
|
||||
if (msr != nmsr)
|
||||
wrmsr(MSR_DE_CFG, nmsr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ucode.c,v 1.3 2020/12/15 22:51:34 kettenis Exp $ */
|
||||
/* $OpenBSD: ucode.c,v 1.4 2023/07/23 02:59:53 jsg Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2018 Stefan Fritsch <fritsch@genua.de>
|
||||
* Copyright (c) 2018 Patrick Wildt <patrick@blueri.se>
|
||||
@ -72,6 +72,8 @@ size_t cpu_ucode_size;
|
||||
void cpu_ucode_setup(void);
|
||||
void cpu_ucode_apply(struct cpu_info *);
|
||||
|
||||
struct mutex cpu_ucode_mtx = MUTEX_INITIALIZER(IPL_HIGH);
|
||||
|
||||
/* Intel */
|
||||
void cpu_ucode_intel_apply(struct cpu_info *);
|
||||
struct intel_ucode_header *
|
||||
@ -82,7 +84,8 @@ int cpu_ucode_intel_match(struct intel_ucode_header *, uint32_t, uint32_t,
|
||||
uint32_t cpu_ucode_intel_rev(void);
|
||||
|
||||
struct intel_ucode_header *cpu_ucode_intel_applied;
|
||||
struct mutex cpu_ucode_intel_mtx = MUTEX_INITIALIZER(IPL_HIGH);
|
||||
|
||||
void cpu_ucode_amd_apply(struct cpu_info *);
|
||||
|
||||
void
|
||||
cpu_ucode_setup(void)
|
||||
@ -130,6 +133,99 @@ cpu_ucode_apply(struct cpu_info *ci)
|
||||
{
|
||||
if (strcmp(cpu_vendor, "GenuineIntel") == 0)
|
||||
cpu_ucode_intel_apply(ci);
|
||||
else if (strcmp(cpu_vendor, "AuthenticAMD") == 0)
|
||||
cpu_ucode_amd_apply(ci);
|
||||
}
|
||||
|
||||
#define AMD_MAGIC 0x00414d44
|
||||
|
||||
struct amd_equiv {
|
||||
uint32_t id;
|
||||
uint32_t a;
|
||||
uint32_t b;
|
||||
uint16_t eid;
|
||||
uint16_t c;
|
||||
} __packed;
|
||||
|
||||
struct amd_patch {
|
||||
uint32_t type;
|
||||
uint32_t len;
|
||||
uint32_t a;
|
||||
uint32_t level;
|
||||
uint8_t c[16];
|
||||
uint16_t eid;
|
||||
} __packed;
|
||||
|
||||
void
|
||||
cpu_ucode_amd_apply(struct cpu_info *ci)
|
||||
{
|
||||
uint64_t level;
|
||||
uint32_t magic, tlen, i;
|
||||
uint16_t eid = 0;
|
||||
uint32_t sig, ebx, ecx, edx;
|
||||
uint64_t start = 0;
|
||||
|
||||
if (cpu_ucode_data == NULL || cpu_ucode_size == 0) {
|
||||
DPRINTF(("%s: no microcode provided\n", __func__));
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Grab a mutex, because we are not allowed to run updates
|
||||
* simultaneously on HT siblings.
|
||||
*/
|
||||
mtx_enter(&cpu_ucode_mtx);
|
||||
|
||||
CPUID(1, sig, ebx, ecx, edx);
|
||||
|
||||
level = rdmsr(MSR_PATCH_LEVEL);
|
||||
DPRINTF(("%s: cur patch level 0x%llx\n", __func__, level));
|
||||
|
||||
memcpy(&magic, cpu_ucode_data, 4);
|
||||
if (magic != AMD_MAGIC) {
|
||||
DPRINTF(("%s: bad magic %x\n", __func__, magic));
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(&tlen, &cpu_ucode_data[8], 4);
|
||||
|
||||
/* find equivalence id matching our cpu signature */
|
||||
for (i = 12; i < 12 + tlen;) {
|
||||
struct amd_equiv ae;
|
||||
if (i + sizeof(ae) > cpu_ucode_size) {
|
||||
DPRINTF(("%s: truncated etable\n", __func__));
|
||||
goto out;
|
||||
}
|
||||
memcpy(&ae, &cpu_ucode_data[i], sizeof(ae));
|
||||
i += sizeof(ae);
|
||||
if (ae.id == sig)
|
||||
eid = ae.eid;
|
||||
}
|
||||
|
||||
/* look for newer patch with the equivalence id */
|
||||
while (i < cpu_ucode_size) {
|
||||
struct amd_patch ap;
|
||||
if (i + sizeof(ap) > cpu_ucode_size) {
|
||||
DPRINTF(("%s: truncated ptable\n", __func__));
|
||||
goto out;
|
||||
}
|
||||
memcpy(&ap, &cpu_ucode_data[i], sizeof(ap));
|
||||
if (ap.type == 1 && ap.eid == eid && ap.level > level)
|
||||
start = (uint64_t)&cpu_ucode_data[i + 8];
|
||||
if (i + ap.len + 8 > cpu_ucode_size) {
|
||||
DPRINTF(("%s: truncated patch\n", __func__));
|
||||
goto out;
|
||||
}
|
||||
i += ap.len + 8;
|
||||
}
|
||||
|
||||
if (start != 0) {
|
||||
wrmsr(MSR_PATCH_LOADER, start);
|
||||
level = rdmsr(MSR_PATCH_LEVEL);
|
||||
DPRINTF(("%s: new patch level 0x%llx\n", __func__, level));
|
||||
}
|
||||
out:
|
||||
mtx_leave(&cpu_ucode_mtx);
|
||||
}
|
||||
|
||||
void
|
||||
@ -148,7 +244,7 @@ cpu_ucode_intel_apply(struct cpu_info *ci)
|
||||
* Grab a mutex, because we are not allowed to run updates
|
||||
* simultaneously on HT siblings.
|
||||
*/
|
||||
mtx_enter(&cpu_ucode_intel_mtx);
|
||||
mtx_enter(&cpu_ucode_mtx);
|
||||
|
||||
old_rev = cpu_ucode_intel_rev();
|
||||
update = cpu_ucode_intel_applied;
|
||||
@ -182,7 +278,7 @@ cpu_ucode_intel_apply(struct cpu_info *ci)
|
||||
}
|
||||
|
||||
out:
|
||||
mtx_leave(&cpu_ucode_intel_mtx);
|
||||
mtx_leave(&cpu_ucode_mtx);
|
||||
}
|
||||
|
||||
struct intel_ucode_header *
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: cpu.h,v 1.181 2022/12/06 01:56:44 cheloha Exp $ */
|
||||
/* $OpenBSD: cpu.h,v 1.182 2023/07/25 18:16:20 cheloha Exp $ */
|
||||
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
|
||||
|
||||
/*-
|
||||
@ -168,6 +168,7 @@ struct cpu_info {
|
||||
struct ksensor ci_sensor;
|
||||
#if defined(GPROF) || defined(DDBPROF)
|
||||
struct gmonparam *ci_gmon;
|
||||
struct clockintr *ci_gmonclock;
|
||||
#endif
|
||||
struct clockintr_queue ci_queue;
|
||||
char ci_panicbuf[512];
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: specialreg.h,v 1.82 2023/07/21 04:04:52 guenther Exp $ */
|
||||
/* $OpenBSD: specialreg.h,v 1.83 2023/07/24 14:54:00 deraadt Exp $ */
|
||||
/* $NetBSD: specialreg.h,v 1.7 1994/10/27 04:16:26 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
@ -529,6 +529,7 @@
|
||||
#define MSR_DE_CFG 0xc0011029 /* Decode Configuration */
|
||||
#define DE_CFG_721 0x00000001 /* errata 721 */
|
||||
#define DE_CFG_SERIALIZE_LFENCE (1 << 1) /* Enable serializing lfence */
|
||||
#define DE_CFG_SERIALIZE_9 (1 << 9) /* Zenbleed chickenbit */
|
||||
|
||||
#define IPM_C1E_CMP_HLT 0x10000000
|
||||
#define IPM_SMI_CMP_HLT 0x08000000
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: clock.c,v 1.64 2023/02/04 19:19:36 cheloha Exp $ */
|
||||
/* $OpenBSD: clock.c,v 1.65 2023/07/25 18:16:20 cheloha Exp $ */
|
||||
/* $NetBSD: clock.c,v 1.39 1996/05/12 23:11:54 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
@ -663,7 +663,6 @@ setstatclockrate(int arg)
|
||||
mc146818_write(NULL, MC_REGA,
|
||||
MC_BASE_32_KHz | MC_RATE_1024_Hz);
|
||||
}
|
||||
clockintr_setstatclockrate(arg);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: conf.c,v 1.77 2023/04/25 14:48:16 kn Exp $ */
|
||||
/* $OpenBSD: conf.c,v 1.78 2023/07/22 10:11:20 jsg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Michael Shalayeff
|
||||
@ -42,7 +42,7 @@
|
||||
#include <dev/cons.h>
|
||||
#include "debug.h"
|
||||
|
||||
const char version[] = "3.45";
|
||||
const char version[] = "3.65";
|
||||
int debug = 1;
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: conf.c,v 1.44 2023/04/25 14:48:17 kn Exp $ */
|
||||
/* $OpenBSD: conf.c,v 1.45 2023/07/22 10:11:20 jsg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 Tom Cosgrove
|
||||
@ -43,7 +43,7 @@
|
||||
#include <dev/cons.h>
|
||||
#include "debug.h"
|
||||
|
||||
const char version[] = "3.45";
|
||||
const char version[] = "3.65";
|
||||
int debug = 1;
|
||||
|
||||
void (*sa_cleanup)(void) = NULL;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: exec_i386.c,v 1.52 2022/07/07 00:56:47 daniel Exp $ */
|
||||
/* $OpenBSD: exec_i386.c,v 1.53 2023/07/22 10:11:20 jsg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997-1998 Michael Shalayeff
|
||||
@ -190,7 +190,8 @@ ucode_load(void)
|
||||
|
||||
CPUID(0, dummy, vendor[0], vendor[2], vendor[1]);
|
||||
vendor[3] = 0; /* NULL-terminate */
|
||||
if (strcmp((char *)vendor, "GenuineIntel") != 0)
|
||||
if (strcmp((char *)vendor, "GenuineIntel") != 0 &&
|
||||
strcmp((char *)vendor, "AuthenticAMD") != 0)
|
||||
return;
|
||||
|
||||
CPUID(1, signature, dummy, dummy, dummy);
|
||||
@ -202,8 +203,22 @@ ucode_load(void)
|
||||
}
|
||||
stepping = (signature >> 0) & 0x0f;
|
||||
|
||||
snprintf(path, sizeof(path), "%s:/etc/firmware/intel/%02x-%02x-%02x",
|
||||
cmd.bootdev, family, model, stepping);
|
||||
if (strcmp((char *)vendor, "GenuineIntel") == 0) {
|
||||
snprintf(path, sizeof(path),
|
||||
"%s:/etc/firmware/intel/%02x-%02x-%02x",
|
||||
cmd.bootdev, family, model, stepping);
|
||||
} else if (strcmp((char *)vendor, "AuthenticAMD") == 0) {
|
||||
if (family < 0x10)
|
||||
return;
|
||||
else if (family <= 0x14)
|
||||
snprintf(path, sizeof(path),
|
||||
"%s:/etc/firmware/amd/microcode_amd.bin",
|
||||
cmd.bootdev);
|
||||
else
|
||||
snprintf(path, sizeof(path),
|
||||
"%s:/etc/firmware/amd/microcode_amd_fam%02xh.bin",
|
||||
cmd.bootdev, family);
|
||||
}
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd == -1)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: pciprobe.c,v 1.10 2014/03/29 18:09:29 guenther Exp $ */
|
||||
/* $OpenBSD: pciprobe.c,v 1.11 2023/07/24 14:02:36 jsg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Tobias Weingartner
|
||||
@ -39,12 +39,12 @@ pciprobe(void)
|
||||
{
|
||||
bios_pciinfo_t bpi;
|
||||
u_int32_t hw_chars, rev, rc, sig;
|
||||
u_int32_t entry32;
|
||||
u_int32_t entry32, lastbus;
|
||||
|
||||
/* PCI BIOS v2.0c+ - Installation Check */
|
||||
__asm volatile(DOINT(0x1A) "; shll $8,%2; setc %b2"
|
||||
: "=a" (hw_chars), "=b" (rev), "=c" (rc),
|
||||
"=d" (sig), "=D" (entry32)
|
||||
__asm volatile(DOINT(0x1A)
|
||||
: "=a" (hw_chars), "=b" (rev), "=c" (lastbus),
|
||||
"=d" (sig), "=D" (entry32), "=@ccc" (rc)
|
||||
: "0" (0xB101), "4" (0x0)
|
||||
: "cc");
|
||||
|
||||
@ -62,7 +62,7 @@ pciprobe(void)
|
||||
bpi.pci_chars = hw_chars & 0xFFFF;
|
||||
bpi.pci_rev = rev & 0xFFFF;
|
||||
bpi.pci_entry32 = entry32;
|
||||
bpi.pci_lastbus = (rc>>8) & 0xFF;
|
||||
bpi.pci_lastbus = lastbus & 0xFF;
|
||||
|
||||
addbootarg(BOOTARG_PCIINFO, sizeof(bios_pciinfo_t), &bpi);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: conf.c,v 1.49 2023/04/25 14:48:17 kn Exp $ */
|
||||
/* $OpenBSD: conf.c,v 1.50 2023/07/22 10:11:20 jsg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 Tom Cosgrove
|
||||
@ -45,7 +45,7 @@
|
||||
#include "pxeboot.h"
|
||||
#include "pxe_net.h"
|
||||
|
||||
const char version[] = "3.45";
|
||||
const char version[] = "3.65";
|
||||
int debug = 1;
|
||||
|
||||
void (*sa_cleanup)(void) = pxe_shutdown;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: exuart.c,v 1.11 2022/07/02 08:50:42 visa Exp $ */
|
||||
/* $OpenBSD: exuart.c,v 1.12 2023/07/23 11:16:36 kettenis Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2005 Dale Rahn <drahn@motorola.com>
|
||||
*
|
||||
@ -40,6 +40,7 @@
|
||||
#include <dev/fdt/exuartreg.h>
|
||||
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofw_power.h>
|
||||
#include <dev/ofw/fdt.h>
|
||||
|
||||
#define DEVUNIT(x) (minor(x) & 0x7f)
|
||||
@ -210,6 +211,10 @@ exuart_attach(struct device *parent, struct device *self, void *aux)
|
||||
printf(": console");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
power_domain_enable(faa->fa_node);
|
||||
|
||||
if (OF_is_compatible(faa->fa_node, "apple,s5l-uart")) {
|
||||
sc->sc_type = EXUART_TYPE_S5L;
|
||||
sc->sc_rx_fifo_cnt_mask = EXUART_S5L_UFSTAT_RX_FIFO_CNT_MASK;
|
||||
@ -270,8 +275,6 @@ exuart_attach(struct device *parent, struct device *self, void *aux)
|
||||
if(sc->sc_si == NULL)
|
||||
panic("%s: can't establish soft interrupt.",
|
||||
sc->sc_dev.dv_xname);
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: files.fdt,v 1.195 2023/07/01 16:34:30 drahn Exp $
|
||||
# $OpenBSD: files.fdt,v 1.196 2023/07/22 22:43:53 patrick Exp $
|
||||
#
|
||||
# Config file and device description for machine-independent FDT code.
|
||||
# Included by ports that need it.
|
||||
@ -761,6 +761,11 @@ device qcrtc
|
||||
attach qcrtc at spmi
|
||||
file dev/fdt/qcrtc.c qcrtc
|
||||
|
||||
# Qualcomm PMIC Shared Direct Access Memory
|
||||
device qcsdam
|
||||
attach qcsdam at spmi
|
||||
file dev/fdt/qcsdam.c qcsdam
|
||||
|
||||
# TI TPS6598x Type-C controller
|
||||
device tipd
|
||||
attach tipd at i2c
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: qcrtc.c,v 1.2 2023/01/16 20:12:38 patrick Exp $ */
|
||||
/* $OpenBSD: qcrtc.c,v 1.3 2023/07/22 22:48:35 patrick Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2022 Patrick Wildt <patrick@blueri.se>
|
||||
*
|
||||
@ -25,6 +25,7 @@
|
||||
#include <dev/fdt/spmivar.h>
|
||||
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofw_misc.h>
|
||||
#include <dev/ofw/fdt.h>
|
||||
|
||||
#include <dev/clock_subr.h>
|
||||
@ -114,12 +115,14 @@ qcrtc_gettime(struct todr_chip_handle *handle, struct timeval *tv)
|
||||
return error;
|
||||
}
|
||||
|
||||
/* Retrieve RTC offset stored in UEFI. */
|
||||
if (qcscm_uefi_rtc_get(&off) != 0)
|
||||
return EIO;
|
||||
/* Retrieve RTC offset from either NVRAM or UEFI. */
|
||||
error = nvmem_read_cell(sc->sc_node, "offset", &off, sizeof(off));
|
||||
if (error == ENXIO || (!error && off == 0))
|
||||
error = qcscm_uefi_rtc_get(&off);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
/* Add RTC counter and 10y+1w to get seconds from epoch. */
|
||||
tv->tv_sec = off + (reg + (10 * 365 * 86400 + 7 * 86400));
|
||||
tv->tv_sec = off + reg;
|
||||
tv->tv_usec = 0;
|
||||
return 0;
|
||||
}
|
||||
@ -138,9 +141,11 @@ qcrtc_settime(struct todr_chip_handle *handle, struct timeval *tv)
|
||||
return error;
|
||||
}
|
||||
|
||||
/* Subtract RTC counter and 10y+1w to get offset for UEFI. */
|
||||
off = tv->tv_sec - (reg + (10 * 365 * 86400 + 7 * 86400));
|
||||
/* Store RTC offset in either NVRAM or UEFI. */
|
||||
off = tv->tv_sec - reg;
|
||||
error = nvmem_write_cell(sc->sc_node, "offset", &off, sizeof(off));
|
||||
if (error == ENXIO)
|
||||
error = qcscm_uefi_rtc_set(off);
|
||||
|
||||
/* Store offset in UEFI. */
|
||||
return qcscm_uefi_rtc_set(off);
|
||||
return error;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: qcscm.c,v 1.4 2023/05/17 23:12:04 patrick Exp $ */
|
||||
/* $OpenBSD: qcscm.c,v 1.5 2023/07/22 22:48:35 patrick Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2022 Patrick Wildt <patrick@blueri.se>
|
||||
*
|
||||
@ -90,6 +90,8 @@
|
||||
#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
|
||||
#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
|
||||
|
||||
#define UNIX_GPS_EPOCH_OFFSET 315964800
|
||||
|
||||
struct qcscm_dmamem {
|
||||
bus_dmamap_t qdm_map;
|
||||
bus_dma_segment_t qdm_seg;
|
||||
@ -703,7 +705,8 @@ qcscm_uefi_rtc_get(uint32_t *off)
|
||||
&rtcinfosize) != 0)
|
||||
return EIO;
|
||||
|
||||
*off = rtcinfo[0];
|
||||
/* UEFI stores the offset based on GPS epoch */
|
||||
*off = rtcinfo[0] + UNIX_GPS_EPOCH_OFFSET;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -722,6 +725,9 @@ qcscm_uefi_rtc_set(uint32_t off)
|
||||
&rtcinfosize) != 0)
|
||||
return EIO;
|
||||
|
||||
/* UEFI stores the offset based on GPS epoch */
|
||||
off -= UNIX_GPS_EPOCH_OFFSET;
|
||||
|
||||
/* No need to set if we're not changing anything */
|
||||
if (rtcinfo[0] == off)
|
||||
return 0;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user