This commit is contained in:
purplerain 2023-05-17 13:56:02 +00:00
parent 9e5eddc6af
commit 9e7f51724c
Signed by: purplerain
GPG Key ID: F42C07F07E2E35B7
24 changed files with 225 additions and 208 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: bn_isqrt.c,v 1.7 2023/03/27 10:25:02 tb Exp $ */ /* $OpenBSD: bn_isqrt.c,v 1.8 2023/05/17 07:42:38 tb Exp $ */
/* /*
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org> * Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
* *
@ -22,9 +22,7 @@
#include <openssl/err.h> #include <openssl/err.h>
#include "bn_local.h" #include "bn_local.h"
#include "crypto_internal.h"
#define CTASSERT(x) extern char _ctassert[(x) ? 1 : -1 ] \
__attribute__((__unused__))
/* /*
* Calculate integer square root of |n| using a variant of Newton's method. * Calculate integer square root of |n| using a variant of Newton's method.

View File

@ -1,4 +1,4 @@
/* $OpenBSD: crypto_internal.h,v 1.3 2023/04/14 10:42:51 jsing Exp $ */ /* $OpenBSD: crypto_internal.h,v 1.4 2023/05/17 06:37:14 jsing Exp $ */
/* /*
* Copyright (c) 2023 Joel Sing <jsing@openbsd.org> * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
* *
@ -22,14 +22,34 @@
#ifndef HEADER_CRYPTO_INTERNAL_H #ifndef HEADER_CRYPTO_INTERNAL_H
#define HEADER_CRYPTO_INTERNAL_H #define HEADER_CRYPTO_INTERNAL_H
#define CTASSERT(x) \
extern char _ctassert[(x) ? 1 : -1] __attribute__((__unused__))
/* /*
* crypto_store_htobe32() stores a 32 bit unsigned host endian value * crypto_load_be32toh() loads a 32 bit unsigned big endian value as a 32 bit
* as a 32 bit unsigned big endian value, at the specified location in * unsigned host endian value, from the specified address in memory. The memory
* memory. The memory location may have any alignment. * address may have any alignment.
*/
#ifndef HAVE_CRYPTO_LOAD_BE32TOH
static inline uint32_t
crypto_load_be32toh(const void *src)
{
uint32_t v;
memcpy(&v, src, sizeof(v));
return be32toh(v);
}
#endif
/*
* crypto_store_htobe32() stores a 32 bit unsigned host endian value as a 32 bit
* unsigned big endian value, at the specified address in memory. The memory
* address may have any alignment.
*/ */
#ifndef HAVE_CRYPTO_STORE_HTOBE32 #ifndef HAVE_CRYPTO_STORE_HTOBE32
static inline void static inline void
crypto_store_htobe32(uint8_t *dst, uint32_t v) crypto_store_htobe32(void *dst, uint32_t v)
{ {
v = htobe32(v); v = htobe32(v);
memcpy(dst, &v, sizeof(v)); memcpy(dst, &v, sizeof(v));
@ -37,13 +57,30 @@ crypto_store_htobe32(uint8_t *dst, uint32_t v)
#endif #endif
/* /*
* crypto_store_htobe64() stores a 64 bit unsigned host endian value * crypto_load_be64toh() loads a 64 bit unsigned big endian value as a 64 bit
* as a 64 bit unsigned big endian value, at the specified location in * unsigned host endian value, from the specified address in memory. The memory
* memory. The memory location may have any alignment. * address may have any alignment.
*/
#ifndef HAVE_CRYPTO_LOAD_BE64TOH
static inline uint64_t
crypto_load_be64toh(const void *src)
{
uint64_t v;
memcpy(&v, src, sizeof(v));
return be64toh(v);
}
#endif
/*
* crypto_store_htobe64() stores a 64 bit unsigned host endian value as a 64 bit
* unsigned big endian value, at the specified address in memory. The memory
* address may have any alignment.
*/ */
#ifndef HAVE_CRYPTO_STORE_HTOBE64 #ifndef HAVE_CRYPTO_STORE_HTOBE64
static inline void static inline void
crypto_store_htobe64(uint8_t *dst, uint64_t v) crypto_store_htobe64(void *dst, uint64_t v)
{ {
v = htobe64(v); v = htobe64(v);
memcpy(dst, &v, sizeof(v)); memcpy(dst, &v, sizeof(v));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: crypto_lock.c,v 1.2 2018/11/28 15:51:32 jsing Exp $ */ /* $OpenBSD: crypto_lock.c,v 1.3 2023/05/17 07:42:38 tb Exp $ */
/* /*
* Copyright (c) 2018 Brent Cook <bcook@openbsd.org> * Copyright (c) 2018 Brent Cook <bcook@openbsd.org>
* *
@ -19,6 +19,8 @@
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include "crypto_internal.h"
static pthread_mutex_t locks[] = { static pthread_mutex_t locks[] = {
PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER,
PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER,
@ -63,9 +65,6 @@ static pthread_mutex_t locks[] = {
PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER,
}; };
#define CTASSERT(x) extern char _ctassert[(x) ? 1 : -1 ] \
__attribute__((__unused__))
CTASSERT((sizeof(locks) / sizeof(*locks)) == CRYPTO_NUM_LOCKS); CTASSERT((sizeof(locks) / sizeof(*locks)) == CRYPTO_NUM_LOCKS);
void void

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sha512.c,v 1.36 2023/05/16 07:04:57 jsing Exp $ */ /* $OpenBSD: sha512.c,v 1.37 2023/05/17 06:37:14 jsing Exp $ */
/* ==================================================================== /* ====================================================================
* Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
* *
@ -66,9 +66,8 @@
#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA512) #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA512)
#if !defined(__STRICT_ALIGNMENT) || defined(SHA512_ASM) /* Ensure that SHA_LONG64 and uint64_t are equivalent. */
#define SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA CTASSERT(sizeof(SHA_LONG64) == sizeof(uint64_t));
#endif
#ifdef SHA512_ASM #ifdef SHA512_ASM
void sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num); void sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num);
@ -118,31 +117,6 @@ static const SHA_LONG64 K512[80] = {
U64(0x5fcb6fab3ad6faec), U64(0x6c44198c4a475817), U64(0x5fcb6fab3ad6faec), U64(0x6c44198c4a475817),
}; };
#if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
# if defined(__x86_64) || defined(__x86_64__)
# define PULL64(x) ({ SHA_LONG64 ret=*((const SHA_LONG64 *)(&(x))); \
asm ("bswapq %0" \
: "=r"(ret) \
: "0"(ret)); ret; })
# elif (defined(__i386) || defined(__i386__))
# define PULL64(x) ({ const unsigned int *p=(const unsigned int *)(&(x));\
unsigned int hi=p[0],lo=p[1]; \
asm ("bswapl %0; bswapl %1;" \
: "=r"(lo),"=r"(hi) \
: "0"(lo),"1"(hi)); \
((SHA_LONG64)hi)<<32|lo; })
# endif
#endif
#ifndef PULL64
#if BYTE_ORDER == BIG_ENDIAN
#define PULL64(x) (x)
#else
#define B(x, j) (((SHA_LONG64)(*(((const unsigned char *)(&x))+j)))<<((7-j)*8))
#define PULL64(x) (B(x,0)|B(x,1)|B(x,2)|B(x,3)|B(x,4)|B(x,5)|B(x,6)|B(x,7))
#endif
#endif
#define ROTR(x, s) crypto_ror_u64(x, s) #define ROTR(x, s) crypto_ror_u64(x, s)
#define Sigma0(x) (ROTR((x),28) ^ ROTR((x),34) ^ ROTR((x),39)) #define Sigma0(x) (ROTR((x),28) ^ ROTR((x),34) ^ ROTR((x),39))
@ -185,37 +159,60 @@ sha512_block_data_order(SHA512_CTX *ctx, const void *_in, size_t num)
g = ctx->h[6]; g = ctx->h[6];
h = ctx->h[7]; h = ctx->h[7];
X[0] = PULL64(in[0]); if ((uintptr_t)in % sizeof(SHA_LONG64) == 0) {
/* Input is 64 bit aligned. */
X[0] = be64toh(in[0]);
X[1] = be64toh(in[1]);
X[2] = be64toh(in[2]);
X[3] = be64toh(in[3]);
X[4] = be64toh(in[4]);
X[5] = be64toh(in[5]);
X[6] = be64toh(in[6]);
X[7] = be64toh(in[7]);
X[8] = be64toh(in[8]);
X[9] = be64toh(in[9]);
X[10] = be64toh(in[10]);
X[11] = be64toh(in[11]);
X[12] = be64toh(in[12]);
X[13] = be64toh(in[13]);
X[14] = be64toh(in[14]);
X[15] = be64toh(in[15]);
} else {
/* Input is not 64 bit aligned. */
X[0] = crypto_load_be64toh(&in[0]);
X[1] = crypto_load_be64toh(&in[1]);
X[2] = crypto_load_be64toh(&in[2]);
X[3] = crypto_load_be64toh(&in[3]);
X[4] = crypto_load_be64toh(&in[4]);
X[5] = crypto_load_be64toh(&in[5]);
X[6] = crypto_load_be64toh(&in[6]);
X[7] = crypto_load_be64toh(&in[7]);
X[8] = crypto_load_be64toh(&in[8]);
X[9] = crypto_load_be64toh(&in[9]);
X[10] = crypto_load_be64toh(&in[10]);
X[11] = crypto_load_be64toh(&in[11]);
X[12] = crypto_load_be64toh(&in[12]);
X[13] = crypto_load_be64toh(&in[13]);
X[14] = crypto_load_be64toh(&in[14]);
X[15] = crypto_load_be64toh(&in[15]);
}
in += SHA_LBLOCK;
ROUND_00_15(0, a, b, c, d, e, f, g, h, X[0]); ROUND_00_15(0, a, b, c, d, e, f, g, h, X[0]);
X[1] = PULL64(in[1]);
ROUND_00_15(1, h, a, b, c, d, e, f, g, X[1]); ROUND_00_15(1, h, a, b, c, d, e, f, g, X[1]);
X[2] = PULL64(in[2]);
ROUND_00_15(2, g, h, a, b, c, d, e, f, X[2]); ROUND_00_15(2, g, h, a, b, c, d, e, f, X[2]);
X[3] = PULL64(in[3]);
ROUND_00_15(3, f, g, h, a, b, c, d, e, X[3]); ROUND_00_15(3, f, g, h, a, b, c, d, e, X[3]);
X[4] = PULL64(in[4]);
ROUND_00_15(4, e, f, g, h, a, b, c, d, X[4]); ROUND_00_15(4, e, f, g, h, a, b, c, d, X[4]);
X[5] = PULL64(in[5]);
ROUND_00_15(5, d, e, f, g, h, a, b, c, X[5]); ROUND_00_15(5, d, e, f, g, h, a, b, c, X[5]);
X[6] = PULL64(in[6]);
ROUND_00_15(6, c, d, e, f, g, h, a, b, X[6]); ROUND_00_15(6, c, d, e, f, g, h, a, b, X[6]);
X[7] = PULL64(in[7]);
ROUND_00_15(7, b, c, d, e, f, g, h, a, X[7]); ROUND_00_15(7, b, c, d, e, f, g, h, a, X[7]);
X[8] = PULL64(in[8]);
ROUND_00_15(8, a, b, c, d, e, f, g, h, X[8]); ROUND_00_15(8, a, b, c, d, e, f, g, h, X[8]);
X[9] = PULL64(in[9]);
ROUND_00_15(9, h, a, b, c, d, e, f, g, X[9]); ROUND_00_15(9, h, a, b, c, d, e, f, g, X[9]);
X[10] = PULL64(in[10]);
ROUND_00_15(10, g, h, a, b, c, d, e, f, X[10]); ROUND_00_15(10, g, h, a, b, c, d, e, f, X[10]);
X[11] = PULL64(in[11]);
ROUND_00_15(11, f, g, h, a, b, c, d, e, X[11]); ROUND_00_15(11, f, g, h, a, b, c, d, e, X[11]);
X[12] = PULL64(in[12]);
ROUND_00_15(12, e, f, g, h, a, b, c, d, X[12]); ROUND_00_15(12, e, f, g, h, a, b, c, d, X[12]);
X[13] = PULL64(in[13]);
ROUND_00_15(13, d, e, f, g, h, a, b, c, X[13]); ROUND_00_15(13, d, e, f, g, h, a, b, c, X[13]);
X[14] = PULL64(in[14]);
ROUND_00_15(14, c, d, e, f, g, h, a, b, X[14]); ROUND_00_15(14, c, d, e, f, g, h, a, b, X[14]);
X[15] = PULL64(in[15]);
ROUND_00_15(15, b, c, d, e, f, g, h, a, X[15]); ROUND_00_15(15, b, c, d, e, f, g, h, a, X[15]);
for (i = 16; i < 80; i += 16) { for (i = 16; i < 80; i += 16) {
@ -245,8 +242,6 @@ sha512_block_data_order(SHA512_CTX *ctx, const void *_in, size_t num)
ctx->h[5] += f; ctx->h[5] += f;
ctx->h[6] += g; ctx->h[6] += g;
ctx->h[7] += h; ctx->h[7] += h;
in += SHA_LBLOCK;
} }
} }
@ -323,21 +318,15 @@ SHA512_Init(SHA512_CTX *c)
void void
SHA512_Transform(SHA512_CTX *c, const unsigned char *data) SHA512_Transform(SHA512_CTX *c, const unsigned char *data)
{ {
#ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA
if ((size_t)data % sizeof(c->u.d[0]) != 0) {
memcpy(c->u.p, data, sizeof(c->u.p));
data = c->u.p;
}
#endif
sha512_block_data_order(c, data, 1); sha512_block_data_order(c, data, 1);
} }
int int
SHA512_Update(SHA512_CTX *c, const void *_data, size_t len) SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)
{ {
SHA_LONG64 l; const unsigned char *data = _data;
unsigned char *p = c->u.p; unsigned char *p = c->u.p;
const unsigned char *data = (const unsigned char *)_data; SHA_LONG64 l;
if (len == 0) if (len == 0)
return 1; return 1;
@ -366,22 +355,10 @@ SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)
} }
if (len >= sizeof(c->u)) { if (len >= sizeof(c->u)) {
#ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA sha512_block_data_order(c, data, len/sizeof(c->u));
if ((size_t)data % sizeof(c->u.d[0]) != 0) { data += len;
while (len >= sizeof(c->u)) { len %= sizeof(c->u);
memcpy(p, data, sizeof(c->u)); data -= len;
sha512_block_data_order(c, p, 1);
len -= sizeof(c->u);
data += sizeof(c->u);
}
} else
#endif
{
sha512_block_data_order(c, data, len/sizeof(c->u));
data += len;
len %= sizeof(c->u);
data -= len;
}
} }
if (len != 0) { if (len != 0) {

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.124 2023/03/01 09:29:32 dtucker Exp $ # $OpenBSD: Makefile,v 1.125 2023/05/17 05:52:01 djm Exp $
OPENSSL?= yes OPENSSL?= yes
@ -13,7 +13,7 @@ REGRESS_SETUP_ONCE=misc # For sk-dummy.so
REGRESS_FAIL_EARLY?= yes REGRESS_FAIL_EARLY?= yes
# Key conversion operations are not supported when built w/out OpenSSL. # Key conversion operations are not supported when built w/out OpenSSL.
.if ${OPENSSL:L} != no .if !defined(LTESTS_FROM) && ${OPENSSL:L} != no
REGRESS_TARGETS= t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 REGRESS_TARGETS= t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
.endif .endif
@ -221,8 +221,14 @@ t-${t}: timestamp
sh ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/${t}.sh sh ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/${t}.sh
.endfor .endfor
.undef LTESTS_STARTED
.for t in ${LTESTS} .for t in ${LTESTS}
.if defined(LTESTS_FROM) && ${LTESTS_FROM} == t-${t}
LTESTS_STARTED=yes
.endif
.if !defined(LTESTS_FROM) || defined(LTESTS_STARTED)
REGRESS_TARGETS+=t-${t} REGRESS_TARGETS+=t-${t}
.endif
.endfor .endfor
.for t in ${INTEROP_TESTS} .for t in ${INTEROP_TESTS}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: gpt.c,v 1.90 2023/05/10 12:59:47 krw Exp $ */ /* $OpenBSD: gpt.c,v 1.91 2023/05/17 12:59:37 krw Exp $ */
/* /*
* Copyright (c) 2015 Markus Muller <mmu@grummel.net> * Copyright (c) 2015 Markus Muller <mmu@grummel.net>
* Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org> * Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org>
@ -132,7 +132,7 @@ protective_mbr(const struct mbr *mbr)
for (i = 0; i < nitems(dp); i++) { for (i = 0; i < nitems(dp); i++) {
memset(&dos_partition, 0, sizeof(dos_partition)); memset(&dos_partition, 0, sizeof(dos_partition));
if (i < nitems(mbr->mbr_prt)) if (i < nitems(mbr->mbr_prt))
PRT_make(&mbr->mbr_prt[i], mbr->mbr_lba_self, PRT_prt_to_dp(&mbr->mbr_prt[i], mbr->mbr_lba_self,
mbr->mbr_lba_firstembr, &dos_partition); mbr->mbr_lba_firstembr, &dos_partition);
memcpy(&dp[i], &dos_partition, sizeof(dp[i])); memcpy(&dp[i], &dos_partition, sizeof(dp[i]));
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mbr.c,v 1.123 2023/03/06 13:24:40 krw Exp $ */ /* $OpenBSD: mbr.c,v 1.124 2023/05/17 12:59:37 krw Exp $ */
/* /*
* Copyright (c) 1997 Tobias Weingartner * Copyright (c) 1997 Tobias Weingartner
@ -64,7 +64,7 @@ MBR_init(struct mbr *mbr)
bootprt = disk.dk_bootprt; bootprt = disk.dk_bootprt;
} else { } else {
memcpy(&dp, &default_dmbr.dmbr_parts[0], sizeof(dp)); memcpy(&dp, &default_dmbr.dmbr_parts[0], sizeof(dp));
PRT_parse(&dp, 0, 0, &bootprt); PRT_dp_to_prt(&dp, 0, 0, &bootprt);
} }
if (bootprt.prt_ns > 0) { if (bootprt.prt_ns > 0) {
@ -123,7 +123,7 @@ dos_mbr_to_mbr(const struct dos_mbr *dmbr, const uint64_t lba_self,
for (i = 0; i < nitems(mbr->mbr_prt); i++) { for (i = 0; i < nitems(mbr->mbr_prt); i++) {
memset(&mbr->mbr_prt[i], 0, sizeof(mbr->mbr_prt[i])); memset(&mbr->mbr_prt[i], 0, sizeof(mbr->mbr_prt[i]));
if (i < nitems(dmbr->dmbr_parts)) if (i < nitems(dmbr->dmbr_parts))
PRT_parse(&dos_parts[i], lba_self, lba_firstembr, PRT_dp_to_prt(&dos_parts[i], lba_self, lba_firstembr,
&mbr->mbr_prt[i]); &mbr->mbr_prt[i]);
} }
} }
@ -140,7 +140,7 @@ mbr_to_dos_mbr(const struct mbr *mbr, struct dos_mbr *dos_mbr)
for (i = 0; i < nitems(dos_mbr->dmbr_parts); i++) { for (i = 0; i < nitems(dos_mbr->dmbr_parts); i++) {
memset(&dos_partition, 0, sizeof(dos_partition)); memset(&dos_partition, 0, sizeof(dos_partition));
if (i < nitems(mbr->mbr_prt)) { if (i < nitems(mbr->mbr_prt)) {
PRT_make(&mbr->mbr_prt[i], mbr->mbr_lba_self, PRT_prt_to_dp(&mbr->mbr_prt[i], mbr->mbr_lba_self,
mbr->mbr_lba_firstembr, &dos_partition); mbr->mbr_lba_firstembr, &dos_partition);
} }
memcpy(&dos_mbr->dmbr_parts[i], &dos_partition, memcpy(&dos_mbr->dmbr_parts[i], &dos_partition,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: part.c,v 1.161 2023/05/10 13:45:49 krw Exp $ */ /* $OpenBSD: part.c,v 1.162 2023/05/17 12:59:37 krw Exp $ */
/* /*
* Copyright (c) 1997 Tobias Weingartner * Copyright (c) 1997 Tobias Weingartner
@ -951,7 +951,7 @@ PRT_print_gptmenu(char *lbuf, size_t lbuflen)
} }
void void
PRT_parse(const struct dos_partition *dp, const uint64_t lba_self, PRT_dp_to_prt(const struct dos_partition *dp, const uint64_t lba_self,
const uint64_t lba_firstembr, struct prt *prt) const uint64_t lba_firstembr, struct prt *prt)
{ {
off_t off; off_t off;
@ -974,7 +974,7 @@ PRT_parse(const struct dos_partition *dp, const uint64_t lba_self,
} }
void void
PRT_make(const struct prt *prt, const uint64_t lba_self, PRT_prt_to_dp(const struct prt *prt, const uint64_t lba_self,
const uint64_t lba_firstembr, struct dos_partition *dp) const uint64_t lba_firstembr, struct dos_partition *dp)
{ {
struct chs start, end; struct chs start, end;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: part.h,v 1.45 2023/04/09 17:19:59 krw Exp $ */ /* $OpenBSD: part.h,v 1.46 2023/05/17 12:59:37 krw Exp $ */
/* /*
* Copyright (c) 1997 Tobias Weingartner * Copyright (c) 1997 Tobias Weingartner
@ -31,9 +31,9 @@ struct prt {
void PRT_print_mbrmenu(char *, size_t); void PRT_print_mbrmenu(char *, size_t);
void PRT_print_gptmenu(char *, size_t); void PRT_print_gptmenu(char *, size_t);
void PRT_parse(const struct dos_partition *, const uint64_t, void PRT_dp_to_prt(const struct dos_partition *, const uint64_t,
const uint64_t, struct prt *); const uint64_t, struct prt *);
void PRT_make(const struct prt *,const uint64_t, const uint64_t, void PRT_prt_to_dp(const struct prt *,const uint64_t, const uint64_t,
struct dos_partition *); struct dos_partition *);
void PRT_print_part(const int, const struct prt *, const char *); void PRT_print_part(const int, const struct prt *, const char *);
void PRT_print_parthdr(void); void PRT_print_parthdr(void);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: toeplitz.h,v 1.10 2022/12/27 20:13:03 patrick Exp $ */ /* $OpenBSD: toeplitz.h,v 1.11 2023/05/17 10:22:17 dlg Exp $ */
/* /*
* Copyright (c) 2019 David Gwynne <dlg@openbsd.org> * Copyright (c) 2019 David Gwynne <dlg@openbsd.org>
@ -92,9 +92,9 @@ stoeplitz_hash_h16(const struct stoeplitz_cache *scache, uint16_t h16)
} }
static __unused inline uint16_t static __unused inline uint16_t
stoeplitz_hash_h32(const struct stoeplitz_cache *scache, uint64_t h32) stoeplitz_hash_h32(const struct stoeplitz_cache *scache, uint32_t h32)
{ {
return (stoeplitz_hash_h16(scache, h32 & (h32 >> 16))); return (stoeplitz_hash_h16(scache, h32 ^ (h32 >> 16)));
} }
static __unused inline uint16_t static __unused inline uint16_t

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4: # ex:ts=8 sw=4:
# $OpenBSD: Delete.pm,v 1.165 2022/06/09 09:27:11 espie Exp $ # $OpenBSD: Delete.pm,v 1.166 2023/05/17 15:51:58 espie Exp $
# #
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org> # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
# #
@ -360,7 +360,7 @@ sub delete
} }
} }
sub should_run() { 1 } sub should_run { 1 }
package OpenBSD::PackingElement::UnexecDelete; package OpenBSD::PackingElement::UnexecDelete;
sub should_run sub should_run

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4: # ex:ts=8 sw=4:
# $OpenBSD: Error.pm,v 1.40 2019/07/24 18:05:26 espie Exp $ # $OpenBSD: Error.pm,v 1.41 2023/05/17 15:51:58 espie Exp $
# #
# Copyright (c) 2004-2010 Marc Espie <espie@openbsd.org> # Copyright (c) 2004-2010 Marc Espie <espie@openbsd.org>
# #
@ -20,7 +20,7 @@ use warnings;
# this is a set of common classes related to error handling in pkg land # this is a set of common classes related to error handling in pkg land
package OpenBSD::Auto; package OpenBSD::Auto;
sub cache(*&) sub cache :prototype(*&)
{ {
my ($sym, $code) = @_; my ($sym, $code) = @_;
my $callpkg = caller; my $callpkg = caller;
@ -170,7 +170,7 @@ sub dienow
} }
} }
sub try(&@) sub try :prototype(&@)
{ {
my ($try, $catch) = @_; my ($try, $catch) = @_;
eval { &$try }; eval { &$try };
@ -189,7 +189,7 @@ sub rethrow
die $e if $e; die $e if $e;
} }
sub catch(&) sub catch :prototype(&)
{ {
bless $_[0], "OpenBSD::Error::catch"; bless $_[0], "OpenBSD::Error::catch";
} }

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4: # ex:ts=8 sw=4:
# $OpenBSD: Getopt.pm,v 1.12 2012/04/10 16:57:12 espie Exp $ # $OpenBSD: Getopt.pm,v 1.13 2023/05/17 15:51:58 espie Exp $
# #
# Copyright (c) 2006 Marc Espie <espie@openbsd.org> # Copyright (c) 2006 Marc Espie <espie@openbsd.org>
# #
@ -48,7 +48,7 @@ sub handle_option
} }
} }
sub getopts($;$) sub getopts
{ {
my ($args, $hash) = @_; my ($args, $hash) = @_;

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4: # ex:ts=8 sw=4:
# $OpenBSD: PackageInfo.pm,v 1.63 2022/02/15 07:35:35 espie Exp $ # $OpenBSD: PackageInfo.pm,v 1.64 2023/05/17 15:51:58 espie Exp $
# #
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org> # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
# #
@ -174,7 +174,7 @@ sub installed_name
return $name; return $name;
} }
sub info_names() sub info_names
{ {
return @info; return @info;
} }
@ -187,7 +187,7 @@ sub is_info_name
my $dlock; my $dlock;
sub lock_db($;$) sub lock_db
{ {
my ($shared, $state) = @_; my ($shared, $state) = @_;
my $mode = $shared ? LOCK_SH : LOCK_EX; my $mode = $shared ? LOCK_SH : LOCK_EX;
@ -206,7 +206,7 @@ sub lock_db($;$)
return; return;
} }
sub unlock_db() sub unlock_db
{ {
if (defined $dlock) { if (defined $dlock) {
flock($dlock, LOCK_UN); flock($dlock, LOCK_UN);

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4: # ex:ts=8 sw=4:
# $OpenBSD: PackageName.pm,v 1.56 2021/11/25 18:23:53 espie Exp $ # $OpenBSD: PackageName.pm,v 1.57 2023/05/17 15:51:58 espie Exp $
# #
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org> # Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
# #
@ -20,7 +20,7 @@ use warnings;
package OpenBSD::PackageName; package OpenBSD::PackageName;
sub url2pkgname($) sub url2pkgname
{ {
my $name = $_[0]; my $name = $_[0];
$name =~ s|.*/||; $name =~ s|.*/||;

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4: # ex:ts=8 sw=4:
# $OpenBSD: PackageRepository.pm,v 1.172 2022/05/08 13:21:04 espie Exp $ # $OpenBSD: PackageRepository.pm,v 1.173 2023/05/17 15:51:58 espie Exp $
# #
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org> # Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
# #
@ -101,12 +101,12 @@ sub dont_cleanup
{ {
} }
sub ftp() { 'OpenBSD::PackageRepository::FTP' } sub ftp { 'OpenBSD::PackageRepository::FTP' }
sub http() { 'OpenBSD::PackageRepository::HTTP' } sub http { 'OpenBSD::PackageRepository::HTTP' }
sub https() { 'OpenBSD::PackageRepository::HTTPS' } sub https { 'OpenBSD::PackageRepository::HTTPS' }
sub scp() { 'OpenBSD::PackageRepository::SCP' } sub scp { 'OpenBSD::PackageRepository::SCP' }
sub file() { 'OpenBSD::PackageRepository::Local' } sub file { 'OpenBSD::PackageRepository::Local' }
sub installed() { 'OpenBSD::PackageRepository::Installed' } sub installed { 'OpenBSD::PackageRepository::Installed' }
sub parse sub parse
{ {

View File

@ -1,6 +1,6 @@
#! /usr/bin/perl #! /usr/bin/perl
# ex:ts=8 sw=4: # ex:ts=8 sw=4:
# $OpenBSD: HTTP.pm,v 1.13 2017/08/04 11:53:03 sthen Exp $ # $OpenBSD: HTTP.pm,v 1.14 2023/05/17 15:51:58 espie Exp $
# #
# Copyright (c) 2011 Marc Espie <espie@openbsd.org> # Copyright (c) 2011 Marc Espie <espie@openbsd.org>
# #
@ -124,7 +124,7 @@ sub get_header
$h->{'Transfer-Encoding'} eq 'chunked') { $h->{'Transfer-Encoding'} eq 'chunked') {
$h->{chunked} = 1; $h->{chunked} = 1;
} }
if (defined $h->{'Content-Range'} && if (defined $h->{'Content-Range'} &&
$h->{'Content-Range'} =~ m/^bytes\s+(\d+)\-(\d+)\/(\d+)/) { $h->{'Content-Range'} =~ m/^bytes\s+(\d+)\-(\d+)\/(\d+)/) {
($h->{start}, $h->{end}, $h->{size}) = ($1, $2, $3); ($h->{start}, $h->{end}, $h->{size}) = ($1, $2, $3);
} }
@ -232,7 +232,7 @@ package _Proxy;
my $pid; my $pid;
my $token = 0; my $token = 0;
sub batch(&) sub batch
{ {
my $code = shift; my $code = shift;
if (defined $pid) { if (defined $pid) {
@ -250,7 +250,7 @@ sub batch(&)
} }
} }
sub abort_batch() sub abort_batch
{ {
if (defined $pid) { if (defined $pid) {
kill HUP => $pid; kill HUP => $pid;

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4: # ex:ts=8 sw=4:
# $OpenBSD: Installed.pm,v 1.44 2022/05/08 13:21:04 espie Exp $ # $OpenBSD: Installed.pm,v 1.45 2023/05/17 15:45:36 espie Exp $
# #
# Copyright (c) 2007-2014 Marc Espie <espie@openbsd.org> # Copyright (c) 2007-2014 Marc Espie <espie@openbsd.org>
# #
@ -75,7 +75,7 @@ sub setup_cache
# with the corresponding release # with the corresponding release
if (defined $repo->{release}) { if (defined $repo->{release}) {
my $url = $repo->urlscheme."://$repo->{host}$repo->{release}"; my $url = $repo->urlscheme."://$repo->{host}$repo->{release}";
my $r2 = $repo->parse_url(\$url, $state); my $r2 = OpenBSD::PackageRepository->parse(\$url, $state);
$r2->{info_cache} = $repo->{info_cache}; $r2->{info_cache} = $repo->{info_cache};
} }
} }

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4: # ex:ts=8 sw=4:
# $OpenBSD: SCP.pm,v 1.29 2014/08/27 18:40:03 kspillner Exp $ # $OpenBSD: SCP.pm,v 1.30 2023/05/17 15:51:58 espie Exp $
# #
# Copyright (c) 2003-2006 Marc Espie <espie@openbsd.org> # Copyright (c) 2003-2006 Marc Espie <espie@openbsd.org>
# #
@ -64,7 +64,7 @@ my $pid;
my $token = 0; my $token = 0;
$|= 1; $|= 1;
sub batch(&) sub batch
{ {
my $code = shift; my $code = shift;
if (defined $pid) { if (defined $pid) {
@ -82,7 +82,7 @@ sub batch(&)
} }
} }
sub abort_batch() sub abort_batch
{ {
if (defined $pid) { if (defined $pid) {
kill 1, $pid; kill 1, $pid;

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4: # ex:ts=8 sw=4:
# $OpenBSD: Paths.pm,v 1.37 2022/04/13 21:19:16 espie Exp $ # $OpenBSD: Paths.pm,v 1.38 2023/05/17 15:51:58 espie Exp $
# #
# Copyright (c) 2007-2014 Marc Espie <espie@openbsd.org> # Copyright (c) 2007-2014 Marc Espie <espie@openbsd.org>
# #
@ -21,61 +21,61 @@ use warnings;
package OpenBSD::Paths; package OpenBSD::Paths;
# Commands # Commands
sub ldconfig() { '/sbin/ldconfig' } sub ldconfig { '/sbin/ldconfig' }
sub chroot() { '/usr/sbin/chroot' } sub chroot { '/usr/sbin/chroot' }
sub mkfontscale() { '/usr/X11R6/bin/mkfontscale' } sub mkfontscale { '/usr/X11R6/bin/mkfontscale' }
sub mkfontdir() { '/usr/X11R6/bin/mkfontdir' } sub mkfontdir { '/usr/X11R6/bin/mkfontdir' }
sub fc_cache() { '/usr/X11R6/bin/fc-cache' } sub fc_cache { '/usr/X11R6/bin/fc-cache' }
sub install_info() { '/usr/bin/install-info' } sub install_info { '/usr/bin/install-info' }
sub useradd() { '/usr/sbin/useradd' } sub useradd { '/usr/sbin/useradd' }
sub groupadd() { '/usr/sbin/groupadd' } sub groupadd { '/usr/sbin/groupadd' }
sub sysctl() { '/sbin/sysctl' } sub sysctl { '/sbin/sysctl' }
sub openssl() { '/usr/bin/openssl' } sub openssl { '/usr/bin/openssl' }
sub pkgca() { '/etc/ssl/pkgca.pem' } sub pkgca { '/etc/ssl/pkgca.pem' }
sub signify() { '/usr/bin/signify' } sub signify { '/usr/bin/signify' }
sub signifykey { my $s = $_[1]; "/etc/signify/$s.pub" } sub signifykey { my $s = $_[1]; "/etc/signify/$s.pub" }
sub pkg_add() { '/usr/sbin/pkg_add' } sub pkg_add { '/usr/sbin/pkg_add' }
sub chmod() { '/bin/chmod' } # external command is used for symbolic modes. sub chmod { '/bin/chmod' } # external command is used for symbolic modes.
sub gzip() { '/usr/bin/gzip' } sub gzip { '/usr/bin/gzip' }
sub ftp() { $ENV{'FETCH_CMD'} || '/usr/bin/ftp' } sub ftp { $ENV{'FETCH_CMD'} || '/usr/bin/ftp' }
sub groff() { '/usr/local/bin/groff' } sub groff { '/usr/local/bin/groff' }
sub sh() { '/bin/sh' } sub sh { '/bin/sh' }
sub arch() { '/usr/bin/arch' } sub arch { '/usr/bin/arch' }
sub uname() { '/usr/bin/uname' } sub uname { '/usr/bin/uname' }
sub userdel() { '/usr/sbin/userdel' } sub userdel { '/usr/sbin/userdel' }
sub groupdel() { '/usr/sbin/groupdel' } sub groupdel { '/usr/sbin/groupdel' }
sub makewhatis() { '/usr/sbin/makewhatis' } sub makewhatis { '/usr/sbin/makewhatis' }
sub mknod() { '/sbin/mknod' } sub mknod { '/sbin/mknod' }
sub mount() { '/sbin/mount' } sub mount { '/sbin/mount' }
sub df() { '/bin/df' } sub df { '/bin/df' }
sub ssh() { '/usr/bin/ssh' } sub ssh { '/usr/bin/ssh' }
sub make() { '/usr/bin/make' } sub make { '/usr/bin/make' }
sub mklocatedb() { '/usr/libexec/locate.mklocatedb' } sub mklocatedb { '/usr/libexec/locate.mklocatedb' }
sub locate() { '/usr/bin/locate' } sub locate { '/usr/bin/locate' }
sub hostname() { '/bin/hostname' } sub hostname { '/bin/hostname' }
sub doas() { '/usr/bin/doas' } sub doas { '/usr/bin/doas' }
sub env() { '/usr/bin/env' } sub env { '/usr/bin/env' }
sub du() { '/usr/bin/du' } sub du { '/usr/bin/du' }
sub diff() { '/usr/bin/diff' } sub diff { '/usr/bin/diff' }
sub sha256() { '/bin/sha256' } sub sha256 { '/bin/sha256' }
# Various paths # Various paths
sub shells() { '/etc/shells' } sub shells { '/etc/shells' }
sub pkgdb() { '/var/db/pkg' } sub pkgdb { '/var/db/pkg' }
sub localbase() { '/usr/local' } sub localbase { '/usr/local' }
sub vartmp() { '/tmp' } sub vartmp { '/tmp' }
sub portsdir() { '/usr/ports' } sub portsdir { '/usr/ports' }
sub library_dirs() { ("/usr", "/usr/X11R6") } sub library_dirs { ("/usr", "/usr/X11R6") }
sub master_keys() { ("/etc/master_key") } sub master_keys { ("/etc/master_key") }
sub installurl() { "/etc/installurl" } sub installurl { "/etc/installurl" }
sub srclocatedb() { "/usr/lib/locate/src.db" } sub srclocatedb { "/usr/lib/locate/src.db" }
sub xlocatedb() { "/usr/X11R6/lib/locate/xorg.db" } sub xlocatedb { "/usr/X11R6/lib/locate/xorg.db" }
sub updateinfodb { '/usr/local/share/update.db' } sub updateinfodb { '/usr/local/share/update.db' }
sub font_cruft() { ("fonts.alias", "fonts.dir", "fonts.cache-1", "fonts.scale") } sub font_cruft { ("fonts.alias", "fonts.dir", "fonts.cache-1", "fonts.scale") }
sub man_cruft() { ("whatis.db", "mandoc.db", "mandoc.index") } sub man_cruft { ("whatis.db", "mandoc.db", "mandoc.index") }
sub info_cruft() { ("dir") } sub info_cruft { ("dir") }
# a bit of code, OS-dependent stuff that's run-time detected and has no # a bit of code, OS-dependent stuff that's run-time detected and has no
# home yet. # home yet.

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4: # ex:ts=8 sw=4:
# $OpenBSD: PkgCfl.pm,v 1.39 2014/02/01 10:53:17 espie Exp $ # $OpenBSD: PkgCfl.pm,v 1.40 2023/05/17 15:51:58 espie Exp $
# #
# Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org> # Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org>
# #
@ -68,20 +68,20 @@ sub conflicts_with
} }
} }
sub register($$) sub register
{ {
my ($plist, $state) = @_; my ($plist, $state) = @_;
$state->{conflict_list}{$plist->pkgname} = $plist->conflict_list; $state->{conflict_list}{$plist->pkgname} = $plist->conflict_list;
} }
sub unregister($$) sub unregister
{ {
my ($plist, $state) = @_; my ($plist, $state) = @_;
delete $state->{conflict_list}{$plist->pkgname}; delete $state->{conflict_list}{$plist->pkgname};
} }
sub fill_conflict_lists($) sub fill_conflict_lists
{ {
my $state = shift; my $state = shift;
for my $pkg (installed_packages()) { for my $pkg (installed_packages()) {
@ -96,7 +96,7 @@ sub fill_conflict_lists($)
} }
} }
sub find($$) sub find
{ {
my ($pkgname, $state) = @_; my ($pkgname, $state) = @_;
my @bad = (); my @bad = ();

View File

@ -1,6 +1,6 @@
#! /usr/bin/perl #! /usr/bin/perl
# ex:ts=8 sw=4: # ex:ts=8 sw=4:
# $OpenBSD: PkgCreate.pm,v 1.186 2023/05/16 14:30:55 espie Exp $ # $OpenBSD: PkgCreate.pm,v 1.187 2023/05/17 15:51:58 espie Exp $
# #
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org> # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
# #
@ -250,7 +250,7 @@ sub register_forbidden
} }
} }
sub is_forbidden() { 0 } sub is_forbidden { 0 }
sub resolve_link sub resolve_link
{ {
my ($filename, $base, $level) = @_; my ($filename, $base, $level) = @_;
@ -507,7 +507,7 @@ sub prepare_for_archival
return $o; return $o;
} }
sub forbidden() { 1 } sub forbidden { 1 }
sub register_for_archival sub register_for_archival
{ {
@ -842,31 +842,31 @@ sub check_version
} }
package OpenBSD::PackingElement::DigitalSignature; package OpenBSD::PackingElement::DigitalSignature;
sub is_forbidden() { 1 } sub is_forbidden { 1 }
package OpenBSD::PackingElement::Signer; package OpenBSD::PackingElement::Signer;
sub is_forbidden() { 1 } sub is_forbidden { 1 }
package OpenBSD::PackingElement::ExtraInfo; package OpenBSD::PackingElement::ExtraInfo;
sub is_forbidden() { 1 } sub is_forbidden { 1 }
package OpenBSD::PackingElement::ManualInstallation; package OpenBSD::PackingElement::ManualInstallation;
sub is_forbidden() { 1 } sub is_forbidden { 1 }
package OpenBSD::PackingElement::Firmware; package OpenBSD::PackingElement::Firmware;
sub is_forbidden() { 1 } sub is_forbidden { 1 }
package OpenBSD::PackingElement::Url; package OpenBSD::PackingElement::Url;
sub is_forbidden() { 1 } sub is_forbidden { 1 }
package OpenBSD::PackingElement::Arch; package OpenBSD::PackingElement::Arch;
sub is_forbidden() { 1 } sub is_forbidden { 1 }
package OpenBSD::PackingElement::LocalBase; package OpenBSD::PackingElement::LocalBase;
sub is_forbidden() { 1 } sub is_forbidden { 1 }
package OpenBSD::PackingElement::Version; package OpenBSD::PackingElement::Version;
sub is_forbidden() { 1 } sub is_forbidden { 1 }
# put together file and filename, in order to handle fragments simply # put together file and filename, in order to handle fragments simply
package MyFile; package MyFile;

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4: # ex:ts=8 sw=4:
# $OpenBSD: RequiredBy.pm,v 1.28 2023/05/04 14:02:44 espie Exp $ # $OpenBSD: RequiredBy.pm,v 1.29 2023/05/17 15:51:58 espie Exp $
# #
# Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org> # Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org>
# #
@ -166,12 +166,12 @@ package OpenBSD::RequiredBy;
our @ISA=qw(OpenBSD::RequirementList); our @ISA=qw(OpenBSD::RequirementList);
use OpenBSD::PackageInfo; use OpenBSD::PackageInfo;
sub filename() { REQUIRED_BY }; sub filename { REQUIRED_BY };
package OpenBSD::Requiring; package OpenBSD::Requiring;
our @ISA=qw(OpenBSD::RequirementList); our @ISA=qw(OpenBSD::RequirementList);
use OpenBSD::PackageInfo; use OpenBSD::PackageInfo;
sub filename() { REQUIRING }; sub filename { REQUIRING };
1; 1;

View File

@ -1,6 +1,6 @@
#! /usr/bin/perl #! /usr/bin/perl
# ex:ts=8 sw=4: # ex:ts=8 sw=4:
# $OpenBSD: Signer.pm,v 1.10 2016/10/03 13:17:30 espie Exp $ # $OpenBSD: Signer.pm,v 1.11 2023/05/17 15:51:58 espie Exp $
# #
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org> # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
# #
@ -19,7 +19,7 @@
use strict; use strict;
use warnings; use warnings;
# code necessary to create signed package # code necessary to create signed packages
# the factory that chooses what method to use to sign things # the factory that chooses what method to use to sign things
package OpenBSD::Signer; package OpenBSD::Signer;