sync with OpenBSD -current
This commit is contained in:
parent
784d5aeff3
commit
38a9ea224a
44 changed files with 791 additions and 621 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: fpu_add.c,v 1.4 2021/09/17 15:12:28 deraadt Exp $ */
|
||||
/* $OpenBSD: fpu_add.c,v 1.5 2024/03/29 21:02:11 miod Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -53,7 +53,6 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <machine/frame.h>
|
||||
#include <machine/fsr.h>
|
||||
#include <machine/instr.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: fpu_compare.c,v 1.3 2019/03/15 05:42:38 kevlo Exp $ */
|
||||
/* $OpenBSD: fpu_compare.c,v 1.4 2024/03/29 21:02:11 miod Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -54,7 +54,6 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <machine/frame.h>
|
||||
#include <machine/fsr.h>
|
||||
|
||||
#include "fpu_arith.h"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: fpu_div.c,v 1.4 2019/03/15 05:42:38 kevlo Exp $ */
|
||||
/* $OpenBSD: fpu_div.c,v 1.5 2024/03/29 21:02:11 miod Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -51,7 +51,6 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <machine/frame.h>
|
||||
#include <machine/fsr.h>
|
||||
|
||||
#include "fpu_arith.h"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: fpu_explode.c,v 1.11 2021/09/17 15:12:28 deraadt Exp $ */
|
||||
/* $OpenBSD: fpu_explode.c,v 1.12 2024/03/29 21:02:11 miod Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -52,7 +52,6 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <machine/frame.h>
|
||||
#include <machine/fsr.h>
|
||||
#include <machine/ieee.h>
|
||||
#include <machine/instr.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: fpu_implode.c,v 1.7 2021/09/17 15:12:28 deraadt Exp $ */
|
||||
/* $OpenBSD: fpu_implode.c,v 1.8 2024/03/29 21:02:11 miod Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -52,7 +52,6 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <machine/frame.h>
|
||||
#include <machine/fsr.h>
|
||||
#include <machine/ieee.h>
|
||||
#include <machine/instr.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: fpu_mul.c,v 1.3 2019/03/15 05:42:38 kevlo Exp $ */
|
||||
/* $OpenBSD: fpu_mul.c,v 1.4 2024/03/29 21:02:11 miod Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -51,8 +51,6 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <machine/frame.h>
|
||||
|
||||
#include "fpu_arith.h"
|
||||
#include "fpu_emu.h"
|
||||
#include "fpu_extern.h"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: fpu_sqrt.c,v 1.6 2022/12/27 17:10:06 jmc Exp $ */
|
||||
/* $OpenBSD: fpu_sqrt.c,v 1.7 2024/03/29 21:02:11 miod Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -51,8 +51,6 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <machine/frame.h>
|
||||
|
||||
#include "fpu_arith.h"
|
||||
#include "fpu_emu.h"
|
||||
#include "fpu_extern.h"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: fpu_subr.c,v 1.4 2021/09/17 15:12:28 deraadt Exp $ */
|
||||
/* $OpenBSD: fpu_subr.c,v 1.5 2024/03/29 21:02:11 miod Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -51,7 +51,6 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <machine/frame.h>
|
||||
#include <machine/fsr.h>
|
||||
#include <machine/instr.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: malloc.c,v 1.295 2023/12/19 06:59:28 otto Exp $ */
|
||||
/* $OpenBSD: malloc.c,v 1.296 2024/03/30 07:50:39 miod Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2008, 2010, 2011, 2016, 2023 Otto Moerbeek <otto@drijf.net>
|
||||
* Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
|
||||
|
@ -1428,7 +1428,7 @@ _malloc_init(int from_rthreads)
|
|||
}
|
||||
if (!mopts.malloc_canary) {
|
||||
char *p;
|
||||
size_t sz, d_avail;
|
||||
size_t sz, roundup_sz, d_avail;
|
||||
|
||||
omalloc_init();
|
||||
/*
|
||||
|
@ -1436,20 +1436,20 @@ _malloc_init(int from_rthreads)
|
|||
* randomise offset inside the page at which the dir_infos
|
||||
* lay (subject to alignment by 1 << MALLOC_MINSHIFT)
|
||||
*/
|
||||
sz = mopts.malloc_mutexes * sizeof(*d) + 2 * MALLOC_PAGESIZE;
|
||||
if ((p = MMAPNONE(sz, 0)) == MAP_FAILED)
|
||||
sz = mopts.malloc_mutexes * sizeof(*d);
|
||||
roundup_sz = (sz + MALLOC_PAGEMASK) & ~MALLOC_PAGEMASK;
|
||||
if ((p = MMAPNONE(roundup_sz + 2 * MALLOC_PAGESIZE, 0)) ==
|
||||
MAP_FAILED)
|
||||
wrterror(NULL, "malloc_init mmap1 failed");
|
||||
if (mprotect(p + MALLOC_PAGESIZE, mopts.malloc_mutexes *
|
||||
sizeof(*d), PROT_READ | PROT_WRITE))
|
||||
if (mprotect(p + MALLOC_PAGESIZE, roundup_sz,
|
||||
PROT_READ | PROT_WRITE))
|
||||
wrterror(NULL, "malloc_init mprotect1 failed");
|
||||
if (mimmutable(p, sz))
|
||||
if (mimmutable(p, roundup_sz + 2 * MALLOC_PAGESIZE))
|
||||
wrterror(NULL, "malloc_init mimmutable1 failed");
|
||||
d_avail = (((mopts.malloc_mutexes * sizeof(*d) +
|
||||
MALLOC_PAGEMASK) & ~MALLOC_PAGEMASK) -
|
||||
(mopts.malloc_mutexes * sizeof(*d))) >> MALLOC_MINSHIFT;
|
||||
d_avail = (roundup_sz - sz) >> MALLOC_MINSHIFT;
|
||||
d = (struct dir_info *)(p + MALLOC_PAGESIZE +
|
||||
(arc4random_uniform(d_avail) << MALLOC_MINSHIFT));
|
||||
STATS_ADD(d[1].malloc_used, sz);
|
||||
STATS_ADD(d[1].malloc_used, roundup_sz + 2 * MALLOC_PAGESIZE);
|
||||
for (i = 0; i < mopts.malloc_mutexes; i++)
|
||||
mopts.malloc_pool[i] = &d[i];
|
||||
mopts.internal_funcs = 1;
|
||||
|
|
|
@ -2591,3 +2591,40 @@ _libre_BF_ecb_encrypt
|
|||
_libre_BF_cbc_encrypt
|
||||
_libre_BF_cfb64_encrypt
|
||||
_libre_BF_ofb64_encrypt
|
||||
_libre_PEM_read_bio_CMS
|
||||
_libre_PEM_read_CMS
|
||||
_libre_PEM_write_bio_CMS
|
||||
_libre_PEM_write_CMS
|
||||
_libre_CMS_get1_ReceiptRequest
|
||||
_libre_CMS_ReceiptRequest_create0
|
||||
_libre_CMS_add1_ReceiptRequest
|
||||
_libre_CMS_ReceiptRequest_get0_values
|
||||
_libre_WHIRLPOOL_Init
|
||||
_libre_WHIRLPOOL_Update
|
||||
_libre_WHIRLPOOL_BitUpdate
|
||||
_libre_WHIRLPOOL_Final
|
||||
_libre_WHIRLPOOL
|
||||
_libre_Camellia_set_key
|
||||
_libre_Camellia_encrypt
|
||||
_libre_Camellia_decrypt
|
||||
_libre_Camellia_ecb_encrypt
|
||||
_libre_Camellia_cbc_encrypt
|
||||
_libre_Camellia_cfb128_encrypt
|
||||
_libre_Camellia_cfb1_encrypt
|
||||
_libre_Camellia_cfb8_encrypt
|
||||
_libre_Camellia_ofb128_encrypt
|
||||
_libre_Camellia_ctr128_encrypt
|
||||
_libre_AES_set_encrypt_key
|
||||
_libre_AES_set_decrypt_key
|
||||
_libre_AES_encrypt
|
||||
_libre_AES_decrypt
|
||||
_libre_AES_ecb_encrypt
|
||||
_libre_AES_cbc_encrypt
|
||||
_libre_AES_cfb128_encrypt
|
||||
_libre_AES_cfb1_encrypt
|
||||
_libre_AES_cfb8_encrypt
|
||||
_libre_AES_ofb128_encrypt
|
||||
_libre_AES_ctr128_encrypt
|
||||
_libre_AES_ige_encrypt
|
||||
_libre_AES_wrap_key
|
||||
_libre_AES_unwrap_key
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: aes.c,v 1.2 2024/03/28 12:52:58 jsing Exp $ */
|
||||
/* $OpenBSD: aes.c,v 1.3 2024/03/30 05:14:12 joshua Exp $ */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
@ -83,6 +83,7 @@ AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
|||
{
|
||||
aes_cbc_encrypt_internal(in, out, len, key, ivec, enc);
|
||||
}
|
||||
LCRYPTO_ALIAS(AES_cbc_encrypt);
|
||||
|
||||
/*
|
||||
* The input and output encrypted as though 128bit cfb mode is being
|
||||
|
@ -97,6 +98,7 @@ AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, size_t length,
|
|||
CRYPTO_cfb128_encrypt(in, out, length, key, ivec, num, enc,
|
||||
(block128_f)AES_encrypt);
|
||||
}
|
||||
LCRYPTO_ALIAS(AES_cfb128_encrypt);
|
||||
|
||||
/* N.B. This expects the input to be packed, MS bit first */
|
||||
void
|
||||
|
@ -106,6 +108,7 @@ AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, size_t length,
|
|||
CRYPTO_cfb128_1_encrypt(in, out, length, key, ivec, num, enc,
|
||||
(block128_f)AES_encrypt);
|
||||
}
|
||||
LCRYPTO_ALIAS(AES_cfb1_encrypt);
|
||||
|
||||
void
|
||||
AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, size_t length,
|
||||
|
@ -114,6 +117,7 @@ AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, size_t length,
|
|||
CRYPTO_cfb128_8_encrypt(in, out, length, key, ivec, num, enc,
|
||||
(block128_f)AES_encrypt);
|
||||
}
|
||||
LCRYPTO_ALIAS(AES_cfb8_encrypt);
|
||||
|
||||
void
|
||||
AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
|
@ -123,6 +127,7 @@ AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
|
|||
CRYPTO_ctr128_encrypt(in, out, length, key, ivec, ecount_buf, num,
|
||||
(block128_f)AES_encrypt);
|
||||
}
|
||||
LCRYPTO_ALIAS(AES_ctr128_encrypt);
|
||||
|
||||
void
|
||||
AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
|
@ -133,6 +138,7 @@ AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
|||
else
|
||||
AES_decrypt(in, out, key);
|
||||
}
|
||||
LCRYPTO_ALIAS(AES_ecb_encrypt);
|
||||
|
||||
void
|
||||
AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, size_t length,
|
||||
|
@ -141,6 +147,7 @@ AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, size_t length,
|
|||
CRYPTO_ofb128_encrypt(in, out, length, key, ivec, num,
|
||||
(block128_f)AES_encrypt);
|
||||
}
|
||||
LCRYPTO_ALIAS(AES_ofb128_encrypt);
|
||||
|
||||
int
|
||||
AES_wrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out,
|
||||
|
@ -176,6 +183,7 @@ AES_wrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out,
|
|||
memcpy(out, A, 8);
|
||||
return inlen + 8;
|
||||
}
|
||||
LCRYPTO_ALIAS(AES_wrap_key);
|
||||
|
||||
int
|
||||
AES_unwrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out,
|
||||
|
@ -213,3 +221,4 @@ AES_unwrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out,
|
|||
}
|
||||
return inlen;
|
||||
}
|
||||
LCRYPTO_ALIAS(AES_unwrap_key);
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
/* $OpenBSD: aes_cbc.c,v 1.12 2014/06/12 15:49:27 deraadt Exp $ */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 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.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/modes.h>
|
||||
|
||||
void
|
||||
AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const AES_KEY *key, unsigned char *ivec, const int enc)
|
||||
{
|
||||
if (enc)
|
||||
CRYPTO_cbc128_encrypt(in, out, len, key, ivec,
|
||||
(block128_f)AES_encrypt);
|
||||
else
|
||||
CRYPTO_cbc128_decrypt(in, out, len, key, ivec,
|
||||
(block128_f)AES_decrypt);
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
/* $OpenBSD: aes_cfb.c,v 1.8 2014/06/12 15:49:27 deraadt Exp $ */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2002-2006 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.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/modes.h>
|
||||
|
||||
/* The input and output encrypted as though 128bit cfb mode is being
|
||||
* used. The extra state information to record how much of the
|
||||
* 128bit block we have used is contained in *num;
|
||||
*/
|
||||
|
||||
void
|
||||
AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, size_t length,
|
||||
const AES_KEY *key, unsigned char *ivec, int *num, const int enc)
|
||||
{
|
||||
CRYPTO_cfb128_encrypt(in, out, length, key, ivec, num, enc,
|
||||
(block128_f)AES_encrypt);
|
||||
}
|
||||
|
||||
/* N.B. This expects the input to be packed, MS bit first */
|
||||
void
|
||||
AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, size_t length,
|
||||
const AES_KEY *key, unsigned char *ivec, int *num, const int enc)
|
||||
{
|
||||
CRYPTO_cfb128_1_encrypt(in, out, length, key, ivec, num, enc,
|
||||
(block128_f)AES_encrypt);
|
||||
}
|
||||
|
||||
void
|
||||
AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, size_t length,
|
||||
const AES_KEY *key, unsigned char *ivec, int *num, const int enc)
|
||||
{
|
||||
CRYPTO_cfb128_8_encrypt(in, out, length, key, ivec, num, enc,
|
||||
(block128_f)AES_encrypt);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: aes_core.c,v 1.22 2024/03/29 11:19:01 jsing Exp $ */
|
||||
/* $OpenBSD: aes_core.c,v 1.23 2024/03/30 05:14:12 joshua Exp $ */
|
||||
/**
|
||||
* rijndael-alg-fst.c
|
||||
*
|
||||
|
@ -746,6 +746,7 @@ AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key)
|
|||
{
|
||||
return aes_set_encrypt_key_internal(userKey, bits, key);
|
||||
}
|
||||
LCRYPTO_ALIAS(AES_set_encrypt_key);
|
||||
|
||||
#ifdef HAVE_AES_SET_DECRYPT_KEY_INTERNAL
|
||||
int aes_set_decrypt_key_internal(const unsigned char *userKey, const int bits,
|
||||
|
@ -818,6 +819,7 @@ AES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key)
|
|||
{
|
||||
return aes_set_decrypt_key_internal(userKey, bits, key);
|
||||
}
|
||||
LCRYPTO_ALIAS(AES_set_decrypt_key);
|
||||
|
||||
#ifdef HAVE_AES_ENCRYPT_INTERNAL
|
||||
void aes_encrypt_internal(const unsigned char *in, unsigned char *out,
|
||||
|
@ -1020,6 +1022,7 @@ AES_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key)
|
|||
{
|
||||
return aes_encrypt_internal(in, out, key);
|
||||
}
|
||||
LCRYPTO_ALIAS(AES_encrypt);
|
||||
|
||||
#ifdef HAVE_AES_DECRYPT_INTERNAL
|
||||
void aes_decrypt_internal(const unsigned char *in, unsigned char *out,
|
||||
|
@ -1222,3 +1225,4 @@ AES_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key)
|
|||
{
|
||||
return aes_decrypt_internal(in, out, key);
|
||||
}
|
||||
LCRYPTO_ALIAS(AES_decrypt);
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/* $OpenBSD: aes_ctr.c,v 1.9 2014/06/12 15:49:27 deraadt Exp $ */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 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.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/modes.h>
|
||||
|
||||
void
|
||||
AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key, unsigned char ivec[AES_BLOCK_SIZE],
|
||||
unsigned char ecount_buf[AES_BLOCK_SIZE], unsigned int *num)
|
||||
{
|
||||
CRYPTO_ctr128_encrypt(in, out, length, key, ivec, ecount_buf, num,
|
||||
(block128_f)AES_encrypt);
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
/* $OpenBSD: aes_ecb.c,v 1.7 2022/11/26 16:08:50 tb Exp $ */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 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.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AES_DEBUG
|
||||
# ifndef NDEBUG
|
||||
# define NDEBUG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <openssl/aes.h>
|
||||
#include "aes_local.h"
|
||||
|
||||
void
|
||||
AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key, const int enc)
|
||||
{
|
||||
if (AES_ENCRYPT == enc)
|
||||
AES_encrypt(in, out, key);
|
||||
else
|
||||
AES_decrypt(in, out, key);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: aes_ige.c,v 1.9 2022/11/26 16:08:50 tb Exp $ */
|
||||
/* $OpenBSD: aes_ige.c,v 1.10 2024/03/30 05:14:12 joshua Exp $ */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
@ -192,3 +192,4 @@ AES_ige_encrypt(const unsigned char *in, unsigned char *out, size_t length,
|
|||
}
|
||||
}
|
||||
}
|
||||
LCRYPTO_ALIAS(AES_ige_encrypt);
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
/* $OpenBSD: aes_ofb.c,v 1.6 2014/06/12 15:49:27 deraadt Exp $ */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2002-2006 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.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/modes.h>
|
||||
|
||||
void
|
||||
AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, size_t length,
|
||||
const AES_KEY *key, unsigned char *ivec, int *num)
|
||||
{
|
||||
CRYPTO_ofb128_encrypt(in, out, length, key, ivec, num,
|
||||
(block128_f)AES_encrypt);
|
||||
}
|
|
@ -1,133 +0,0 @@
|
|||
/* $OpenBSD: aes_wrap.c,v 1.12 2018/11/07 18:31:16 tb Exp $ */
|
||||
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
|
||||
* project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2008 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
|
||||
* 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.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/bio.h>
|
||||
|
||||
static const unsigned char default_iv[] = {
|
||||
0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,
|
||||
};
|
||||
|
||||
int
|
||||
AES_wrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out,
|
||||
const unsigned char *in, unsigned int inlen)
|
||||
{
|
||||
unsigned char *A, B[16], *R;
|
||||
unsigned int i, j, t;
|
||||
|
||||
if ((inlen & 0x7) || (inlen < 16))
|
||||
return -1;
|
||||
A = B;
|
||||
t = 1;
|
||||
memmove(out + 8, in, inlen);
|
||||
if (!iv)
|
||||
iv = default_iv;
|
||||
|
||||
memcpy(A, iv, 8);
|
||||
|
||||
for (j = 0; j < 6; j++) {
|
||||
R = out + 8;
|
||||
for (i = 0; i < inlen; i += 8, t++, R += 8) {
|
||||
memcpy(B + 8, R, 8);
|
||||
AES_encrypt(B, B, key);
|
||||
A[7] ^= (unsigned char)(t & 0xff);
|
||||
if (t > 0xff) {
|
||||
A[6] ^= (unsigned char)((t >> 8) & 0xff);
|
||||
A[5] ^= (unsigned char)((t >> 16) & 0xff);
|
||||
A[4] ^= (unsigned char)((t >> 24) & 0xff);
|
||||
}
|
||||
memcpy(R, B + 8, 8);
|
||||
}
|
||||
}
|
||||
memcpy(out, A, 8);
|
||||
return inlen + 8;
|
||||
}
|
||||
|
||||
int
|
||||
AES_unwrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out,
|
||||
const unsigned char *in, unsigned int inlen)
|
||||
{
|
||||
unsigned char *A, B[16], *R;
|
||||
unsigned int i, j, t;
|
||||
|
||||
if ((inlen & 0x7) || (inlen < 24))
|
||||
return -1;
|
||||
inlen -= 8;
|
||||
A = B;
|
||||
t = 6 * (inlen >> 3);
|
||||
memcpy(A, in, 8);
|
||||
memmove(out, in + 8, inlen);
|
||||
for (j = 0; j < 6; j++) {
|
||||
R = out + inlen - 8;
|
||||
for (i = 0; i < inlen; i += 8, t--, R -= 8) {
|
||||
A[7] ^= (unsigned char)(t & 0xff);
|
||||
if (t > 0xff) {
|
||||
A[6] ^= (unsigned char)((t >> 8) & 0xff);
|
||||
A[5] ^= (unsigned char)((t >> 16) & 0xff);
|
||||
A[4] ^= (unsigned char)((t >> 24) & 0xff);
|
||||
}
|
||||
memcpy(B + 8, R, 8);
|
||||
AES_decrypt(B, B, key);
|
||||
memcpy(R, B + 8, 8);
|
||||
}
|
||||
}
|
||||
if (!iv)
|
||||
iv = default_iv;
|
||||
if (memcmp(A, iv, 8)) {
|
||||
explicit_bzero(out, inlen);
|
||||
return 0;
|
||||
}
|
||||
return inlen;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: camellia.c,v 1.13 2024/03/29 07:26:21 jsing Exp $ */
|
||||
/* $OpenBSD: camellia.c,v 1.14 2024/03/30 04:58:12 joshua Exp $ */
|
||||
/* ====================================================================
|
||||
* Copyright 2006 NTT (Nippon Telegraph and Telephone Corporation) .
|
||||
* ALL RIGHTS RESERVED.
|
||||
|
@ -591,6 +591,7 @@ Camellia_set_key(const unsigned char *userKey, const int bits,
|
|||
key->grand_rounds = Camellia_Ekeygen(bits, userKey, key->u.rd_key);
|
||||
return 0;
|
||||
}
|
||||
LCRYPTO_ALIAS(Camellia_set_key);
|
||||
|
||||
void
|
||||
Camellia_encrypt(const unsigned char *in, unsigned char *out,
|
||||
|
@ -598,6 +599,7 @@ Camellia_encrypt(const unsigned char *in, unsigned char *out,
|
|||
{
|
||||
Camellia_EncryptBlock_Rounds(key->grand_rounds, in, key->u.rd_key, out);
|
||||
}
|
||||
LCRYPTO_ALIAS(Camellia_encrypt);
|
||||
|
||||
void
|
||||
Camellia_decrypt(const unsigned char *in, unsigned char *out,
|
||||
|
@ -605,6 +607,7 @@ Camellia_decrypt(const unsigned char *in, unsigned char *out,
|
|||
{
|
||||
Camellia_DecryptBlock_Rounds(key->grand_rounds, in, key->u.rd_key, out);
|
||||
}
|
||||
LCRYPTO_ALIAS(Camellia_decrypt);
|
||||
|
||||
void
|
||||
Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len,
|
||||
|
@ -617,6 +620,7 @@ Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len,
|
|||
CRYPTO_cbc128_decrypt(in, out, len, key, ivec,
|
||||
(block128_f)Camellia_decrypt);
|
||||
}
|
||||
LCRYPTO_ALIAS(Camellia_cbc_encrypt);
|
||||
|
||||
/*
|
||||
* The input and output encrypted as though 128bit cfb mode is being
|
||||
|
@ -632,6 +636,7 @@ Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out,
|
|||
CRYPTO_cfb128_encrypt(in, out, length, key, ivec, num, enc,
|
||||
(block128_f)Camellia_encrypt);
|
||||
}
|
||||
LCRYPTO_ALIAS(Camellia_cfb128_encrypt);
|
||||
|
||||
/* N.B. This expects the input to be packed, MS bit first */
|
||||
void
|
||||
|
@ -642,6 +647,7 @@ Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out,
|
|||
CRYPTO_cfb128_1_encrypt(in, out, length, key, ivec, num, enc,
|
||||
(block128_f)Camellia_encrypt);
|
||||
}
|
||||
LCRYPTO_ALIAS(Camellia_cfb1_encrypt);
|
||||
|
||||
void
|
||||
Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out,
|
||||
|
@ -651,6 +657,7 @@ Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out,
|
|||
CRYPTO_cfb128_8_encrypt(in, out, length, key, ivec, num, enc,
|
||||
(block128_f)Camellia_encrypt);
|
||||
}
|
||||
LCRYPTO_ALIAS(Camellia_cfb8_encrypt);
|
||||
|
||||
void
|
||||
Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
|
@ -661,6 +668,7 @@ Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,
|
|||
CRYPTO_ctr128_encrypt(in, out, length, key, ivec, ecount_buf, num,
|
||||
(block128_f)Camellia_encrypt);
|
||||
}
|
||||
LCRYPTO_ALIAS(Camellia_ctr128_encrypt);
|
||||
|
||||
void
|
||||
Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
|
@ -671,6 +679,7 @@ Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
|||
else
|
||||
Camellia_decrypt(in, out, key);
|
||||
}
|
||||
LCRYPTO_ALIAS(Camellia_ecb_encrypt);
|
||||
|
||||
/*
|
||||
* The input and output encrypted as though 128bit ofb mode is being
|
||||
|
@ -684,3 +693,4 @@ Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out,
|
|||
CRYPTO_ofb128_encrypt(in, out, length, key, ivec, num,
|
||||
(block128_f)Camellia_encrypt);
|
||||
}
|
||||
LCRYPTO_ALIAS(Camellia_ofb128_encrypt);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: cms.h,v 1.17 2024/03/29 02:28:50 jsing Exp $ */
|
||||
/* $OpenBSD: cms.h,v 1.18 2024/03/30 00:35:15 joshua Exp $ */
|
||||
/*
|
||||
* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
|
||||
* project.
|
||||
|
@ -315,8 +315,6 @@ int CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si, const char *attrname,
|
|||
void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,
|
||||
int lastpos, int type);
|
||||
|
||||
#ifdef HEADER_X509V3_H
|
||||
|
||||
int CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr);
|
||||
CMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen,
|
||||
int allorfirst, STACK_OF(GENERAL_NAMES) *receiptList,
|
||||
|
@ -325,7 +323,7 @@ int CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr);
|
|||
void CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr, ASN1_STRING **pcid,
|
||||
int *pallorfirst, STACK_OF(GENERAL_NAMES) **plist,
|
||||
STACK_OF(GENERAL_NAMES) **prto);
|
||||
#endif
|
||||
|
||||
int CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri, X509_ALGOR **palg,
|
||||
ASN1_OCTET_STRING **pukm);
|
||||
STACK_OF(CMS_RecipientEncryptedKey) *
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: cms_ess.c,v 1.24 2024/01/14 18:40:24 tb Exp $ */
|
||||
/* $OpenBSD: cms_ess.c,v 1.25 2024/03/30 01:53:05 joshua Exp $ */
|
||||
/*
|
||||
* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
|
||||
* project.
|
||||
|
@ -118,6 +118,7 @@ CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr)
|
|||
|
||||
return 1;
|
||||
}
|
||||
LCRYPTO_ALIAS(CMS_get1_ReceiptRequest);
|
||||
|
||||
CMS_ReceiptRequest *
|
||||
CMS_ReceiptRequest_create0(unsigned char *id, int idlen, int allorfirst,
|
||||
|
@ -155,6 +156,7 @@ CMS_ReceiptRequest_create0(unsigned char *id, int idlen, int allorfirst,
|
|||
|
||||
return NULL;
|
||||
}
|
||||
LCRYPTO_ALIAS(CMS_ReceiptRequest_create0);
|
||||
|
||||
int
|
||||
CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr)
|
||||
|
@ -180,6 +182,7 @@ CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr)
|
|||
|
||||
return r;
|
||||
}
|
||||
LCRYPTO_ALIAS(CMS_add1_ReceiptRequest);
|
||||
|
||||
void
|
||||
CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr, ASN1_STRING **pcid,
|
||||
|
@ -202,6 +205,7 @@ CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr, ASN1_STRING **pcid,
|
|||
if (prto)
|
||||
*prto = rr->receiptsTo;
|
||||
}
|
||||
LCRYPTO_ALIAS(CMS_ReceiptRequest_get0_values);
|
||||
|
||||
/* Digest a SignerInfo structure for msgSigDigest attribute processing */
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: cms_io.c,v 1.20 2023/07/08 08:26:26 beck Exp $ */
|
||||
/* $OpenBSD: cms_io.c,v 1.21 2024/03/30 01:53:05 joshua Exp $ */
|
||||
/*
|
||||
* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
|
||||
* project.
|
||||
|
@ -105,6 +105,7 @@ PEM_read_bio_CMS(BIO *bp, CMS_ContentInfo **x, pem_password_cb *cb, void *u)
|
|||
return PEM_ASN1_read_bio((d2i_of_void *)d2i_CMS_ContentInfo,
|
||||
PEM_STRING_CMS, bp, (void **)x, cb, u);
|
||||
}
|
||||
LCRYPTO_ALIAS(PEM_read_bio_CMS);
|
||||
|
||||
CMS_ContentInfo *
|
||||
PEM_read_CMS(FILE *fp, CMS_ContentInfo **x, pem_password_cb *cb, void *u)
|
||||
|
@ -112,6 +113,7 @@ PEM_read_CMS(FILE *fp, CMS_ContentInfo **x, pem_password_cb *cb, void *u)
|
|||
return PEM_ASN1_read((d2i_of_void *)d2i_CMS_ContentInfo,
|
||||
PEM_STRING_CMS, fp, (void **)x, cb, u);
|
||||
}
|
||||
LCRYPTO_ALIAS(PEM_read_CMS);
|
||||
|
||||
int
|
||||
PEM_write_bio_CMS(BIO *bp, const CMS_ContentInfo *x)
|
||||
|
@ -119,6 +121,7 @@ PEM_write_bio_CMS(BIO *bp, const CMS_ContentInfo *x)
|
|||
return PEM_ASN1_write_bio((i2d_of_void *)i2d_CMS_ContentInfo,
|
||||
PEM_STRING_CMS, bp, (void *)x, NULL, NULL, 0, NULL, NULL);
|
||||
}
|
||||
LCRYPTO_ALIAS(PEM_write_bio_CMS);
|
||||
|
||||
int
|
||||
PEM_write_CMS(FILE *fp, const CMS_ContentInfo *x)
|
||||
|
@ -126,6 +129,7 @@ PEM_write_CMS(FILE *fp, const CMS_ContentInfo *x)
|
|||
return PEM_ASN1_write((i2d_of_void *)i2d_CMS_ContentInfo,
|
||||
PEM_STRING_CMS, fp, (void *)x, NULL, NULL, 0, NULL, NULL);
|
||||
}
|
||||
LCRYPTO_ALIAS(PEM_write_CMS);
|
||||
|
||||
BIO *
|
||||
BIO_new_CMS(BIO *out, CMS_ContentInfo *cms)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: cms_lib.c,v 1.24 2023/08/24 04:56:36 tb Exp $ */
|
||||
/* $OpenBSD: cms_lib.c,v 1.25 2024/03/30 01:53:05 joshua Exp $ */
|
||||
/*
|
||||
* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
|
||||
* project.
|
||||
|
@ -314,6 +314,7 @@ CMS_get0_content(CMS_ContentInfo *cms)
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
LCRYPTO_ALIAS(CMS_get0_content);
|
||||
|
||||
/*
|
||||
* Return an ASN1_OBJECT pointer to content type. This allows it to be
|
||||
|
|
43
lib/libcrypto/hidden/openssl/aes.h
Normal file
43
lib/libcrypto/hidden/openssl/aes.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/* $OpenBSD: aes.h,v 1.1 2024/03/30 05:14:12 joshua Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2024 Joshua Sing <joshua@joshuasing.dev>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _LIBCRYPTO_AES_H
|
||||
#define _LIBCRYPTO_AES_H
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include_next <openssl/aes.h>
|
||||
#else
|
||||
#include "../include/openssl/aes.h"
|
||||
#endif
|
||||
#include "crypto_namespace.h"
|
||||
|
||||
LCRYPTO_USED(AES_set_encrypt_key);
|
||||
LCRYPTO_USED(AES_set_decrypt_key);
|
||||
LCRYPTO_USED(AES_encrypt);
|
||||
LCRYPTO_USED(AES_decrypt);
|
||||
LCRYPTO_USED(AES_ecb_encrypt);
|
||||
LCRYPTO_USED(AES_cbc_encrypt);
|
||||
LCRYPTO_USED(AES_cfb128_encrypt);
|
||||
LCRYPTO_USED(AES_cfb1_encrypt);
|
||||
LCRYPTO_USED(AES_cfb8_encrypt);
|
||||
LCRYPTO_USED(AES_ofb128_encrypt);
|
||||
LCRYPTO_USED(AES_ctr128_encrypt);
|
||||
LCRYPTO_USED(AES_ige_encrypt);
|
||||
LCRYPTO_USED(AES_wrap_key);
|
||||
LCRYPTO_USED(AES_unwrap_key);
|
||||
|
||||
#endif /* _LIBCRYPTO_AES_H */
|
39
lib/libcrypto/hidden/openssl/camellia.h
Normal file
39
lib/libcrypto/hidden/openssl/camellia.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* $OpenBSD: camellia.h,v 1.1 2024/03/30 04:58:12 joshua Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2024 Joshua Sing <joshua@joshuasing.dev>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _LIBCRYPTO_CAMELLIA_H
|
||||
#define _LIBCRYPTO_CAMELLIA_H
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include_next <openssl/camellia.h>
|
||||
#else
|
||||
#include "../include/openssl/camellia.h"
|
||||
#endif
|
||||
#include "crypto_namespace.h"
|
||||
|
||||
LCRYPTO_USED(Camellia_set_key);
|
||||
LCRYPTO_USED(Camellia_encrypt);
|
||||
LCRYPTO_USED(Camellia_decrypt);
|
||||
LCRYPTO_USED(Camellia_ecb_encrypt);
|
||||
LCRYPTO_USED(Camellia_cbc_encrypt);
|
||||
LCRYPTO_USED(Camellia_cfb128_encrypt);
|
||||
LCRYPTO_USED(Camellia_cfb1_encrypt);
|
||||
LCRYPTO_USED(Camellia_cfb8_encrypt);
|
||||
LCRYPTO_USED(Camellia_ofb128_encrypt);
|
||||
LCRYPTO_USED(Camellia_ctr128_encrypt);
|
||||
|
||||
#endif /* _LIBCRYPTO_CAMELLIA_H */
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: cms.h,v 1.2 2023/07/28 10:28:02 tb Exp $ */
|
||||
/* $OpenBSD: cms.h,v 1.3 2024/03/30 01:53:05 joshua Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2023 Bob Beck <beck@openbsd.org>
|
||||
*
|
||||
|
@ -39,8 +39,13 @@ LCRYPTO_USED(CMS_get_version);
|
|||
LCRYPTO_USED(CMS_SignerInfo_get_version);
|
||||
LCRYPTO_USED(CMS_dataInit);
|
||||
LCRYPTO_USED(CMS_dataFinal);
|
||||
LCRYPTO_USED(CMS_get0_content);
|
||||
LCRYPTO_USED(CMS_is_detached);
|
||||
LCRYPTO_USED(CMS_set_detached);
|
||||
LCRYPTO_USED(PEM_read_bio_CMS);
|
||||
LCRYPTO_USED(PEM_read_CMS);
|
||||
LCRYPTO_USED(PEM_write_bio_CMS);
|
||||
LCRYPTO_USED(PEM_write_CMS);
|
||||
LCRYPTO_USED(CMS_stream);
|
||||
LCRYPTO_USED(d2i_CMS_bio);
|
||||
LCRYPTO_USED(i2d_CMS_bio);
|
||||
|
@ -133,6 +138,10 @@ LCRYPTO_USED(CMS_unsigned_add1_attr_by_OBJ);
|
|||
LCRYPTO_USED(CMS_unsigned_add1_attr_by_NID);
|
||||
LCRYPTO_USED(CMS_unsigned_add1_attr_by_txt);
|
||||
LCRYPTO_USED(CMS_unsigned_get0_data_by_OBJ);
|
||||
LCRYPTO_USED(CMS_get1_ReceiptRequest);
|
||||
LCRYPTO_USED(CMS_ReceiptRequest_create0);
|
||||
LCRYPTO_USED(CMS_add1_ReceiptRequest);
|
||||
LCRYPTO_USED(CMS_ReceiptRequest_get0_values);
|
||||
LCRYPTO_USED(CMS_RecipientInfo_kari_get0_alg);
|
||||
LCRYPTO_USED(CMS_RecipientInfo_kari_get0_reks);
|
||||
LCRYPTO_USED(CMS_RecipientInfo_kari_get0_orig_id);
|
||||
|
|
34
lib/libcrypto/hidden/openssl/whrlpool.h
Normal file
34
lib/libcrypto/hidden/openssl/whrlpool.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* $OpenBSD: whrlpool.h,v 1.1 2024/03/30 03:45:47 joshua Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2024 Joshua Sing <joshua@joshuasing.dev>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _LIBCRYPTO_WHRLPOOL_H
|
||||
#define _LIBCRYPTO_WHRLPOOL_H
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include_next <openssl/whrlpool.h>
|
||||
#else
|
||||
#include "../include/openssl/whrlpool.h"
|
||||
#endif
|
||||
#include "crypto_namespace.h"
|
||||
|
||||
LCRYPTO_USED(WHIRLPOOL_Init);
|
||||
LCRYPTO_USED(WHIRLPOOL_Update);
|
||||
LCRYPTO_USED(WHIRLPOOL_BitUpdate);
|
||||
LCRYPTO_USED(WHIRLPOOL_Final);
|
||||
LCRYPTO_USED(WHIRLPOOL);
|
||||
|
||||
#endif /* _LIBCRYPTO_WHRLPOOL_H */
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: rsa_pk1.c,v 1.16 2023/07/08 12:26:45 beck Exp $ */
|
||||
/* $OpenBSD: rsa_pk1.c,v 1.17 2024/03/30 04:34:17 jsing Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -64,31 +64,61 @@
|
|||
#include <openssl/err.h>
|
||||
#include <openssl/rsa.h>
|
||||
|
||||
#include "bytestring.h"
|
||||
|
||||
int
|
||||
RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
|
||||
const unsigned char *from, int flen)
|
||||
{
|
||||
int j;
|
||||
unsigned char *p;
|
||||
CBB cbb;
|
||||
int i;
|
||||
int ret = 0;
|
||||
|
||||
if (flen > (tlen - RSA_PKCS1_PADDING_SIZE)) {
|
||||
/*
|
||||
* Pad data block with PKCS1 type 1 padding - RFC 2313, section 8.1.
|
||||
*/
|
||||
|
||||
memset(&cbb, 0, sizeof(cbb));
|
||||
|
||||
if (flen < 0 || tlen < 0)
|
||||
goto err;
|
||||
|
||||
if (flen > tlen - RSA_PKCS1_PADDING_SIZE) {
|
||||
RSAerror(RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
|
||||
p = (unsigned char *)to;
|
||||
if (!CBB_init_fixed(&cbb, to, tlen))
|
||||
goto err;
|
||||
|
||||
*(p++) = 0;
|
||||
*(p++) = 1; /* Private Key BT (Block Type) */
|
||||
/*
|
||||
* Add leading NUL, block type (0x01), padding bytes (0xff) and
|
||||
* trailing NUL.
|
||||
*/
|
||||
if (!CBB_add_u8(&cbb, 0))
|
||||
goto err;
|
||||
if (!CBB_add_u8(&cbb, 1))
|
||||
goto err;
|
||||
for (i = 0; i < tlen - 3 - flen; i++) {
|
||||
if (!CBB_add_u8(&cbb, 0xff))
|
||||
goto err;
|
||||
}
|
||||
if (!CBB_add_u8(&cbb, 0))
|
||||
goto err;
|
||||
|
||||
/* pad out with 0xff data */
|
||||
j = tlen - 3 - flen;
|
||||
memset(p, 0xff, j);
|
||||
p += j;
|
||||
*(p++) = '\0';
|
||||
memcpy(p, from, flen);
|
||||
/* Now add the actual data. */
|
||||
if (!CBB_add_bytes(&cbb, from, flen))
|
||||
goto err;
|
||||
|
||||
return 1;
|
||||
if (!CBB_finish(&cbb, NULL, NULL))
|
||||
goto err;
|
||||
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
CBB_cleanup(&cbb);
|
||||
|
||||
return ret;
|
||||
}
|
||||
LCRYPTO_ALIAS(RSA_padding_add_PKCS1_type_1);
|
||||
|
||||
|
@ -146,33 +176,69 @@ int
|
|||
RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
|
||||
const unsigned char *from, int flen)
|
||||
{
|
||||
int i, j;
|
||||
unsigned char *p;
|
||||
uint8_t padding[256];
|
||||
uint8_t pad;
|
||||
CBB cbb;
|
||||
CBS cbs;
|
||||
int i;
|
||||
int ret = 0;
|
||||
|
||||
if (flen > tlen - 11) {
|
||||
/*
|
||||
* Pad data block with PKCS1 type 2 padding - RFC 2313, section 8.1.
|
||||
*/
|
||||
|
||||
memset(&cbb, 0, sizeof(cbb));
|
||||
CBS_init(&cbs, NULL, 0);
|
||||
|
||||
if (flen < 0 || tlen < 0)
|
||||
goto err;
|
||||
|
||||
if (flen > tlen - RSA_PKCS1_PADDING_SIZE) {
|
||||
RSAerror(RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
|
||||
p = (unsigned char *)to;
|
||||
if (!CBB_init_fixed(&cbb, to, tlen))
|
||||
goto err;
|
||||
|
||||
*(p++) = 0;
|
||||
*(p++) = 2; /* Public Key BT (Block Type) */
|
||||
/*
|
||||
* Add leading NUL, block type (0x02), padding bytes (random non-zero
|
||||
* bytes) and trailing NUL.
|
||||
*/
|
||||
if (!CBB_add_u8(&cbb, 0))
|
||||
goto err;
|
||||
if (!CBB_add_u8(&cbb, 2))
|
||||
goto err;
|
||||
for (i = 0; i < tlen - 3 - flen; i++) {
|
||||
do {
|
||||
if (CBS_len(&cbs) == 0) {
|
||||
arc4random_buf(padding, sizeof(padding));
|
||||
CBS_init(&cbs, padding, sizeof(padding));
|
||||
}
|
||||
if (!CBS_get_u8(&cbs, &pad))
|
||||
goto err;
|
||||
} while (pad == 0);
|
||||
|
||||
/* pad out with non-zero random data */
|
||||
j = tlen - 3 - flen;
|
||||
|
||||
arc4random_buf(p, j);
|
||||
for (i = 0; i < j; i++) {
|
||||
while (*p == '\0')
|
||||
arc4random_buf(p, 1);
|
||||
p++;
|
||||
if (!CBB_add_u8(&cbb, pad))
|
||||
goto err;
|
||||
}
|
||||
if (!CBB_add_u8(&cbb, 0))
|
||||
goto err;
|
||||
|
||||
*(p++) = '\0';
|
||||
/* Now add the actual data. */
|
||||
if (!CBB_add_bytes(&cbb, from, flen))
|
||||
goto err;
|
||||
|
||||
memcpy(p, from, flen);
|
||||
return 1;
|
||||
if (!CBB_finish(&cbb, NULL, NULL))
|
||||
goto err;
|
||||
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
CBB_cleanup(&cbb);
|
||||
explicit_bzero(padding, sizeof(padding));
|
||||
|
||||
return ret;
|
||||
}
|
||||
LCRYPTO_ALIAS(RSA_padding_add_PKCS1_type_2);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: whirlpool.c,v 1.1 2024/03/29 02:41:49 jsing Exp $ */
|
||||
/* $OpenBSD: whirlpool.c,v 1.2 2024/03/30 03:45:47 joshua Exp $ */
|
||||
/**
|
||||
* The Whirlpool hashing function.
|
||||
*
|
||||
|
@ -650,6 +650,7 @@ WHIRLPOOL_Init(WHIRLPOOL_CTX *c)
|
|||
memset (c, 0, sizeof(*c));
|
||||
return (1);
|
||||
}
|
||||
LCRYPTO_ALIAS(WHIRLPOOL_Init);
|
||||
|
||||
int
|
||||
WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *_inp, size_t bytes)
|
||||
|
@ -671,6 +672,7 @@ WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *_inp, size_t bytes)
|
|||
|
||||
return (1);
|
||||
}
|
||||
LCRYPTO_ALIAS(WHIRLPOOL_Update);
|
||||
|
||||
void
|
||||
WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *_inp, size_t bits)
|
||||
|
@ -796,6 +798,7 @@ reconsider:
|
|||
}
|
||||
}
|
||||
}
|
||||
LCRYPTO_ALIAS(WHIRLPOOL_BitUpdate);
|
||||
|
||||
int
|
||||
WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c)
|
||||
|
@ -837,6 +840,7 @@ WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c)
|
|||
}
|
||||
return (0);
|
||||
}
|
||||
LCRYPTO_ALIAS(WHIRLPOOL_Final);
|
||||
|
||||
unsigned char *
|
||||
WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md)
|
||||
|
@ -851,3 +855,4 @@ WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md)
|
|||
WHIRLPOOL_Final(md, &ctx);
|
||||
return (md);
|
||||
}
|
||||
LCRYPTO_ALIAS(WHIRLPOOL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue