Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-22 14:04:28 +01:00
parent 81b91f4139
commit f8c34fa5ee
22732 changed files with 4815320 additions and 2 deletions

View file

@ -0,0 +1,377 @@
From b3958bdfcc9c753477fdf6e0da799c1c4e4077f1 Mon Sep 17 00:00:00 2001
From: Marcus Hoffmann <bubu@bubu1.eu>
Date: Tue, 31 Jul 2018 17:15:39 +0200
Subject: [PATCH] add aes ige mode
---
crypto/fipsmodule/CMakeLists.txt | 2 +
crypto/fipsmodule/aes/aes_ige.c | 323 +++++++++++++++++++++++++++++++
include/openssl/aes.h | 9 +
3 files changed, 334 insertions(+)
create mode 100644 crypto/fipsmodule/aes/aes_ige.c
diff --git a/crypto/fipsmodule/CMakeLists.txt b/crypto/fipsmodule/CMakeLists.txt
index 30823755..b349572c 100644
--- a/crypto/fipsmodule/CMakeLists.txt
+++ b/crypto/fipsmodule/CMakeLists.txt
@@ -198,6 +198,8 @@ else()
bcm.c
fips_shared_support.c
+ aes/aes_ige.c
+
${BCM_ASM_SOURCES}
)
diff --git a/crypto/fipsmodule/aes/aes_ige.c b/crypto/fipsmodule/aes/aes_ige.c
new file mode 100644
index 00000000..b425c7d6
--- /dev/null
+++ b/crypto/fipsmodule/aes/aes_ige.c
@@ -0,0 +1,323 @@
+/* crypto/aes/aes_ige.c -*- mode:C; c-file-style: "eay" -*- */
+/* ====================================================================
+ * Copyright (c) 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 <assert.h>
+#include <memory.h>
+#include <string.h>
+
+#define N_WORDS (AES_BLOCK_SIZE / sizeof(unsigned long))
+typedef struct {
+ unsigned long data[N_WORDS];
+} aes_block_t;
+
+/* XXX: probably some better way to do this */
+#if defined(__i386__) || defined(__x86_64__)
+#define UNALIGNED_MEMOPS_ARE_FAST 1
+#else
+#define UNALIGNED_MEMOPS_ARE_FAST 0
+#endif
+
+#if UNALIGNED_MEMOPS_ARE_FAST
+#define load_block(d, s) (d) = *(const aes_block_t *)(s)
+#define store_block(d, s) *(aes_block_t *)(d) = (s)
+#else
+#define load_block(d, s) memcpy((d).data, (s), AES_BLOCK_SIZE)
+#define store_block(d, s) memcpy((d), (s).data, AES_BLOCK_SIZE)
+#endif
+
+/* N.B. The IV for this mode is _twice_ the block size */
+
+void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
+ size_t length, const AES_KEY *key,
+ unsigned char *ivec, const int enc)
+ {
+ size_t n;
+ size_t len = length;
+
+ assert(in && out && key && ivec);
+ assert((AES_ENCRYPT == enc)||(AES_DECRYPT == enc));
+ assert((length%AES_BLOCK_SIZE) == 0);
+
+ len = length / AES_BLOCK_SIZE;
+
+ if (AES_ENCRYPT == enc)
+ {
+ if (in != out &&
+ (UNALIGNED_MEMOPS_ARE_FAST || ((size_t)in|(size_t)out|(size_t)ivec)%sizeof(long)==0))
+ {
+ aes_block_t *ivp = (aes_block_t *)ivec;
+ aes_block_t *iv2p = (aes_block_t *)(ivec + AES_BLOCK_SIZE);
+
+ while (len)
+ {
+ aes_block_t *inp = (aes_block_t *)in;
+ aes_block_t *outp = (aes_block_t *)out;
+
+ for(n=0 ; n < N_WORDS; ++n)
+ outp->data[n] = inp->data[n] ^ ivp->data[n];
+ AES_encrypt((unsigned char *)outp->data, (unsigned char *)outp->data, key);
+ for(n=0 ; n < N_WORDS; ++n)
+ outp->data[n] ^= iv2p->data[n];
+ ivp = outp;
+ iv2p = inp;
+ --len;
+ in += AES_BLOCK_SIZE;
+ out += AES_BLOCK_SIZE;
+ }
+ memcpy(ivec, ivp->data, AES_BLOCK_SIZE);
+ memcpy(ivec + AES_BLOCK_SIZE, iv2p->data, AES_BLOCK_SIZE);
+ }
+ else
+ {
+ aes_block_t tmp, tmp2;
+ aes_block_t iv;
+ aes_block_t iv2;
+
+ load_block(iv, ivec);
+ load_block(iv2, ivec + AES_BLOCK_SIZE);
+
+ while (len)
+ {
+ load_block(tmp, in);
+ for(n=0 ; n < N_WORDS; ++n)
+ tmp2.data[n] = tmp.data[n] ^ iv.data[n];
+ AES_encrypt((unsigned char *)tmp2.data, (unsigned char *)tmp2.data, key);
+ for(n=0 ; n < N_WORDS; ++n)
+ tmp2.data[n] ^= iv2.data[n];
+ store_block(out, tmp2);
+ iv = tmp2;
+ iv2 = tmp;
+ --len;
+ in += AES_BLOCK_SIZE;
+ out += AES_BLOCK_SIZE;
+ }
+ memcpy(ivec, iv.data, AES_BLOCK_SIZE);
+ memcpy(ivec + AES_BLOCK_SIZE, iv2.data, AES_BLOCK_SIZE);
+ }
+ }
+ else
+ {
+ if (in != out &&
+ (UNALIGNED_MEMOPS_ARE_FAST || ((size_t)in|(size_t)out|(size_t)ivec)%sizeof(long)==0))
+ {
+ aes_block_t *ivp = (aes_block_t *)ivec;
+ aes_block_t *iv2p = (aes_block_t *)(ivec + AES_BLOCK_SIZE);
+
+ while (len)
+ {
+ aes_block_t tmp;
+ aes_block_t *inp = (aes_block_t *)in;
+ aes_block_t *outp = (aes_block_t *)out;
+
+ for(n=0 ; n < N_WORDS; ++n)
+ tmp.data[n] = inp->data[n] ^ iv2p->data[n];
+ AES_decrypt((unsigned char *)tmp.data, (unsigned char *)outp->data, key);
+ for(n=0 ; n < N_WORDS; ++n)
+ outp->data[n] ^= ivp->data[n];
+ ivp = inp;
+ iv2p = outp;
+ --len;
+ in += AES_BLOCK_SIZE;
+ out += AES_BLOCK_SIZE;
+ }
+ memcpy(ivec, ivp->data, AES_BLOCK_SIZE);
+ memcpy(ivec + AES_BLOCK_SIZE, iv2p->data, AES_BLOCK_SIZE);
+ }
+ else
+ {
+ aes_block_t tmp, tmp2;
+ aes_block_t iv;
+ aes_block_t iv2;
+
+ load_block(iv, ivec);
+ load_block(iv2, ivec + AES_BLOCK_SIZE);
+
+ while (len)
+ {
+ load_block(tmp, in);
+ tmp2 = tmp;
+ for(n=0 ; n < N_WORDS; ++n)
+ tmp.data[n] ^= iv2.data[n];
+ AES_decrypt((unsigned char *)tmp.data, (unsigned char *)tmp.data, key);
+ for(n=0 ; n < N_WORDS; ++n)
+ tmp.data[n] ^= iv.data[n];
+ store_block(out, tmp);
+ iv = tmp2;
+ iv2 = tmp;
+ --len;
+ in += AES_BLOCK_SIZE;
+ out += AES_BLOCK_SIZE;
+ }
+ memcpy(ivec, iv.data, AES_BLOCK_SIZE);
+ memcpy(ivec + AES_BLOCK_SIZE, iv2.data, AES_BLOCK_SIZE);
+ }
+ }
+ }
+
+/*
+ * Note that its effectively impossible to do biIGE in anything other
+ * than a single pass, so no provision is made for chaining.
+ */
+
+/* N.B. The IV for this mode is _four times_ the block size */
+
+void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
+ size_t length, const AES_KEY *key,
+ const AES_KEY *key2, const unsigned char *ivec,
+ const int enc)
+ {
+ size_t n;
+ size_t len = length;
+ unsigned char tmp[AES_BLOCK_SIZE];
+ unsigned char tmp2[AES_BLOCK_SIZE];
+ unsigned char tmp3[AES_BLOCK_SIZE];
+ unsigned char prev[AES_BLOCK_SIZE];
+ const unsigned char *iv;
+ const unsigned char *iv2;
+
+ assert(in && out && key && ivec);
+ assert((AES_ENCRYPT == enc)||(AES_DECRYPT == enc));
+ assert((length%AES_BLOCK_SIZE) == 0);
+
+ if (AES_ENCRYPT == enc)
+ {
+ /* XXX: Do a separate case for when in != out (strictly should
+ check for overlap, too) */
+
+ /* First the forward pass */
+ iv = ivec;
+ iv2 = ivec + AES_BLOCK_SIZE;
+ while (len >= AES_BLOCK_SIZE)
+ {
+ for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
+ out[n] = in[n] ^ iv[n];
+ AES_encrypt(out, out, key);
+ for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
+ out[n] ^= iv2[n];
+ iv = out;
+ memcpy(prev, in, AES_BLOCK_SIZE);
+ iv2 = prev;
+ len -= AES_BLOCK_SIZE;
+ in += AES_BLOCK_SIZE;
+ out += AES_BLOCK_SIZE;
+ }
+
+ /* And now backwards */
+ iv = ivec + AES_BLOCK_SIZE*2;
+ iv2 = ivec + AES_BLOCK_SIZE*3;
+ len = length;
+ while(len >= AES_BLOCK_SIZE)
+ {
+ out -= AES_BLOCK_SIZE;
+ /* XXX: reduce copies by alternating between buffers */
+ memcpy(tmp, out, AES_BLOCK_SIZE);
+ for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
+ out[n] ^= iv[n];
+ /* hexdump(stdout, "out ^ iv", out, AES_BLOCK_SIZE); */
+ AES_encrypt(out, out, key);
+ /* hexdump(stdout,"enc", out, AES_BLOCK_SIZE); */
+ /* hexdump(stdout,"iv2", iv2, AES_BLOCK_SIZE); */
+ for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
+ out[n] ^= iv2[n];
+ /* hexdump(stdout,"out", out, AES_BLOCK_SIZE); */
+ iv = out;
+ memcpy(prev, tmp, AES_BLOCK_SIZE);
+ iv2 = prev;
+ len -= AES_BLOCK_SIZE;
+ }
+ }
+ else
+ {
+ /* First backwards */
+ iv = ivec + AES_BLOCK_SIZE*2;
+ iv2 = ivec + AES_BLOCK_SIZE*3;
+ in += length;
+ out += length;
+ while (len >= AES_BLOCK_SIZE)
+ {
+ in -= AES_BLOCK_SIZE;
+ out -= AES_BLOCK_SIZE;
+ memcpy(tmp, in, AES_BLOCK_SIZE);
+ memcpy(tmp2, in, AES_BLOCK_SIZE);
+ for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
+ tmp[n] ^= iv2[n];
+ AES_decrypt(tmp, out, key);
+ for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
+ out[n] ^= iv[n];
+ memcpy(tmp3, tmp2, AES_BLOCK_SIZE);
+ iv = tmp3;
+ iv2 = out;
+ len -= AES_BLOCK_SIZE;
+ }
+
+ /* And now forwards */
+ iv = ivec;
+ iv2 = ivec + AES_BLOCK_SIZE;
+ len = length;
+ while (len >= AES_BLOCK_SIZE)
+ {
+ memcpy(tmp, out, AES_BLOCK_SIZE);
+ memcpy(tmp2, out, AES_BLOCK_SIZE);
+ for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
+ tmp[n] ^= iv2[n];
+ AES_decrypt(tmp, out, key);
+ for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
+ out[n] ^= iv[n];
+ memcpy(tmp3, tmp2, AES_BLOCK_SIZE);
+ iv = tmp3;
+ iv2 = out;
+ len -= AES_BLOCK_SIZE;
+ in += AES_BLOCK_SIZE;
+ out += AES_BLOCK_SIZE;
+ }
+ }
+ }
diff --git a/include/openssl/aes.h b/include/openssl/aes.h
index 11565854..0130fec5 100644
--- a/include/openssl/aes.h
+++ b/include/openssl/aes.h
@@ -138,6 +138,15 @@ OPENSSL_EXPORT void AES_cfb128_encrypt(const uint8_t *in, uint8_t *out,
size_t len, const AES_KEY *key,
uint8_t *ivec, int *num, int enc);
+/* NB: the IV is _two_ blocks long */
+OPENSSL_EXPORT void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
+ size_t length, const AES_KEY *key,
+ unsigned char *ivec, const int enc);
+/* NB: the IV is _four_ blocks long */
+OPENSSL_EXPORT void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
+ size_t length, const AES_KEY *key,
+ const AES_KEY *key2, const unsigned char *ivec,
+ const int enc);
// AES key wrap.
//
--
2.17.1

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,242 @@
From 02952ace408e331237a1ccd724f072b3e67ceb20 Mon Sep 17 00:00:00 2001
From: thermatk <thermatk@thermatk.com>
Date: Wed, 23 Jan 2019 22:16:34 +0100
Subject: [PATCH] only build what we need
---
CMakeLists.txt | 36 ---------------------
crypto/CMakeLists.txt | 74 -------------------------------------------
ssl/CMakeLists.txt | 18 ------------------
3 files changed, 128 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fd3532664..7fcfb1627 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -562,45 +562,9 @@ if(USE_CUSTOM_LIBCXX)
target_link_libraries(libcxx libcxxabi)
install(TARGETS libcxx EXPORT OpenSSLTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
-# Add minimal googletest targets. The provided one has many side-effects, and
-# googletest has a very straightforward build.
-add_library(boringssl_gtest third_party/googletest/src/gtest-all.cc)
-target_include_directories(boringssl_gtest PRIVATE third_party/googletest)
-
-include_directories(third_party/googletest/include)
-
-# Declare a dummy target to build all unit tests. Test targets should inject
-# themselves as dependencies next to the target definition.
-add_custom_target(all_tests)
-
-# On Windows, CRYPTO_TEST_DATA is too long to fit in command-line limits.
-# TODO(davidben): CMake 3.12 has a list(JOIN) command. Use that when we've
-# updated the minimum version.
-set(EMBED_TEST_DATA_ARGS "")
-foreach(arg ${CRYPTO_TEST_DATA})
- set(EMBED_TEST_DATA_ARGS "${EMBED_TEST_DATA_ARGS}${arg}\n")
-endforeach()
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/embed_test_data_args.txt"
- "${EMBED_TEST_DATA_ARGS}")
-
-add_custom_command(
- OUTPUT crypto_test_data.cc
- COMMAND ${GO_EXECUTABLE} run util/embed_test_data.go -file-list
- "${CMAKE_CURRENT_BINARY_DIR}/embed_test_data_args.txt" >
- "${CMAKE_CURRENT_BINARY_DIR}/crypto_test_data.cc"
- DEPENDS util/embed_test_data.go ${CRYPTO_TEST_DATA}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-
-add_library(crypto_test_data OBJECT crypto_test_data.cc)
-
add_subdirectory(crypto)
add_subdirectory(ssl)
-add_subdirectory(ssl/test)
-add_subdirectory(tool)
-add_subdirectory(util/fipstools)
-add_subdirectory(util/fipstools/acvp/modulewrapper)
-add_subdirectory(decrepit)
if(FUZZ)
if(LIBFUZZER_FROM_DEPS)
@@ -634,41 +598,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(HANDSHAKER_ARGS "-handshaker-path" $<TARGET_FILE:handshaker>)
endif()
-if(FIPS)
- add_custom_target(
- acvp_tests
- COMMAND ${GO_EXECUTABLE} build -o ${CMAKE_BINARY_DIR}/acvptool
- boringssl.googlesource.com/boringssl/util/fipstools/acvp/acvptool
- COMMAND ${GO_EXECUTABLE} build -o ${CMAKE_BINARY_DIR}/testmodulewrapper
- boringssl.googlesource.com/boringssl/util/fipstools/acvp/acvptool/testmodulewrapper
- COMMAND cd util/fipstools/acvp/acvptool/test &&
- ${GO_EXECUTABLE} run check_expected.go
- -tool ${CMAKE_BINARY_DIR}/acvptool
- -module-wrappers modulewrapper:$<TARGET_FILE:modulewrapper>,testmodulewrapper:${CMAKE_BINARY_DIR}/testmodulewrapper
- -tests tests.json
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- DEPENDS modulewrapper
- USES_TERMINAL)
-
- add_custom_target(
- fips_specific_tests_if_any
- DEPENDS acvp_tests
- )
-else()
- add_custom_target(fips_specific_tests_if_any)
-endif()
-
-add_custom_target(
- run_tests
- COMMAND ${GO_EXECUTABLE} run util/all_tests.go -build-dir
- ${CMAKE_BINARY_DIR}
- COMMAND cd ssl/test/runner &&
- ${GO_EXECUTABLE} test -shim-path $<TARGET_FILE:bssl_shim>
- ${HANDSHAKER_ARGS} ${RUNNER_ARGS}
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- DEPENDS all_tests bssl_shim handshaker fips_specific_tests_if_any
- USES_TERMINAL)
-
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT OpenSSLTargets
diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt
index e940f7d5f..f5221d70d 100644
--- a/crypto/CMakeLists.txt
+++ b/crypto/CMakeLists.txt
@@ -85,7 +85,6 @@ function(perlasm dest src)
endfunction()
add_subdirectory(fipsmodule)
-add_subdirectory(test)
if(FIPS_DELOCATE OR FIPS_SHARED)
SET_SOURCE_FILES_PROPERTIES(fipsmodule/bcm.o PROPERTIES EXTERNAL_OBJECT true)
@@ -466,97 +466,3 @@ endif()
if(USE_CUSTOM_LIBCXX)
target_link_libraries(crypto libcxx)
endif()
-
-# urandom_test is a separate binary because it needs to be able to observe the
-# PRNG initialisation, which means that it can't have other tests running before
-# it does.
-add_executable(
- urandom_test
-
- fipsmodule/rand/urandom_test.cc
-)
-
-target_link_libraries(urandom_test test_support_lib boringssl_gtest crypto)
-
-add_dependencies(urandom_test global_target)
-add_dependencies(all_tests urandom_test)
-
-add_executable(
- crypto_test
-
- abi_self_test.cc
- asn1/asn1_test.cc
- base64/base64_test.cc
- bio/bio_test.cc
- blake2/blake2_test.cc
- buf/buf_test.cc
- bytestring/bytestring_test.cc
- chacha/chacha_test.cc
- cipher_extra/aead_test.cc
- cipher_extra/cipher_test.cc
- compiler_test.cc
- conf/conf_test.cc
- constant_time_test.cc
- cpu_arm_linux_test.cc
- crypto_test.cc
- curve25519/ed25519_test.cc
- curve25519/spake25519_test.cc
- curve25519/x25519_test.cc
- ecdh_extra/ecdh_test.cc
- dh_extra/dh_test.cc
- digest_extra/digest_test.cc
- dsa/dsa_test.cc
- err/err_test.cc
- evp/evp_extra_test.cc
- evp/evp_test.cc
- evp/pbkdf_test.cc
- evp/scrypt_test.cc
- fipsmodule/aes/aes_test.cc
- fipsmodule/bn/bn_test.cc
- fipsmodule/cmac/cmac_test.cc
- fipsmodule/ec/ec_test.cc
- fipsmodule/ec/p256-nistz_test.cc
- fipsmodule/ecdsa/ecdsa_test.cc
- fipsmodule/md5/md5_test.cc
- fipsmodule/modes/gcm_test.cc
- fipsmodule/rand/ctrdrbg_test.cc
- fipsmodule/rand/fork_detect_test.cc
- fipsmodule/service_indicator/service_indicator_test.cc
- fipsmodule/sha/sha_test.cc
- hkdf/hkdf_test.cc
- hpke/hpke_test.cc
- hmac_extra/hmac_test.cc
- hrss/hrss_test.cc
- impl_dispatch_test.cc
- lhash/lhash_test.cc
- obj/obj_test.cc
- pem/pem_test.cc
- pkcs7/pkcs7_test.cc
- pkcs8/pkcs8_test.cc
- pkcs8/pkcs12_test.cc
- poly1305/poly1305_test.cc
- pool/pool_test.cc
- rand_extra/rand_test.cc
- refcount_test.cc
- rsa_extra/rsa_test.cc
- self_test.cc
- stack/stack_test.cc
- siphash/siphash_test.cc
- test/file_test_gtest.cc
- thread_test.cc
- trust_token/trust_token_test.cc
- x509/x509_test.cc
- x509/x509_time_test.cc
- x509v3/tab_test.cc
-
- $<TARGET_OBJECTS:crypto_test_data>
- $<TARGET_OBJECTS:boringssl_gtest_main>
-)
-
-add_dependencies(crypto_test global_target)
-
-target_link_libraries(crypto_test test_support_lib boringssl_gtest crypto)
-if(WIN32)
- target_link_libraries(crypto_test ws2_32)
-endif()
-add_dependencies(all_tests crypto_test)
diff --git a/ssl/CMakeLists.txt b/ssl/CMakeLists.txt
index 0fb532eae..f5cab9807 100644
--- a/ssl/CMakeLists.txt
+++ b/ssl/CMakeLists.txt
@@ -44,21 +44,3 @@ add_library(
add_dependencies(ssl global_target)
target_link_libraries(ssl crypto)
-
-add_executable(
- ssl_test
-
- span_test.cc
- ssl_test.cc
- ssl_c_test.c
-
- $<TARGET_OBJECTS:boringssl_gtest_main>
-)
-
-add_dependencies(ssl_test global_target)
-
-target_link_libraries(ssl_test test_support_lib boringssl_gtest ssl crypto)
-if(WIN32)
- target_link_libraries(ssl_test ws2_32)
-endif()
-add_dependencies(all_tests ssl_test)
--
2.20.1

View file

@ -0,0 +1,40 @@
From 6a841e89875400f2e2989f39b628dc9fa9654966 Mon Sep 17 00:00:00 2001
From: thermatk <thermatk@thermatk.com>
Date: Sat, 18 May 2019 22:39:24 +0200
Subject: [PATCH] Compilation magic
---
libavformat/isom.h | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/libavformat/isom.h b/libavformat/isom.h
index 69452cae8e..51fd2a917f 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -241,7 +241,7 @@ typedef struct MOVStreamContext {
} MOVStreamContext;
typedef struct MOVContext {
- const AVClass *class; ///< class for private options
+ const AVClass *clazz; ///< class for private options
AVFormatContext *fc;
int time_scale;
int64_t duration; ///< duration of the longest track
@@ -367,14 +367,5 @@ void ff_mov_write_chan(AVIOContext *pb, int64_t channel_layout);
* Compute codec id for 'lpcm' tag.
* See CoreAudioTypes and AudioStreamBasicDescription at Apple.
*/
-static inline enum AVCodecID ff_mov_get_lpcm_codec_id(int bps, int flags)
-{
- /* lpcm flags:
- * 0x1 = float
- * 0x2 = big-endian
- * 0x4 = signed
- */
- return ff_get_pcm_codec_id(bps, flags & 1, flags & 2, flags & 4 ? -1 : 0);
-}
#endif /* AVFORMAT_ISOM_H */
--
2.21.0

View file

@ -0,0 +1,584 @@
From cdc55ea354ab977ea2f94ea74fad0561b3a8fd93 Mon Sep 17 00:00:00 2001
From: thermatk <thermatk@thermatk.com>
Date: Sat, 26 Jun 2021 16:56:55 +0200
Subject: [PATCH] [PATCH] Compilation magic 2
---
libavcodec/get_bits.h | 221 ++--------------------------------
libavcodec/golomb.h | 269 ------------------------------------------
2 files changed, 13 insertions(+), 477 deletions(-)
diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h
index 66fb877..a0695d3 100644
--- a/libavcodec/get_bits.h
+++ b/libavcodec/get_bits.h
@@ -29,13 +29,9 @@
#include <stdint.h>
-#include "libavutil/common.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/log.h"
-#include "libavutil/avassert.h"
-#include "avcodec.h"
-#include "mathops.h"
-#include "vlc.h"
+#ifndef NEG_USR32
+# define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s)))
+#endif
/*
* Safe bitstream reading:
@@ -313,72 +309,12 @@ static inline void skip_remaining(GetBitContext *s, unsigned n)
}
#endif
-/**
- * Read MPEG-1 dc-style VLC (sign bit + mantissa with no MSB).
- * if MSB not set it is negative
- * @param n length in bits
- */
-static inline int get_xbits(GetBitContext *s, int n)
-{
-#if CACHED_BITSTREAM_READER
- int32_t cache = show_bits(s, 32);
- int sign = ~cache >> 31;
- skip_remaining(s, n);
-
- return ((((uint32_t)(sign ^ cache)) >> (32 - n)) ^ sign) - sign;
-#else
- register int sign;
- register int32_t cache;
- OPEN_READER(re, s);
- av_assert2(n>0 && n<=25);
- UPDATE_CACHE(re, s);
- cache = GET_CACHE(re, s);
- sign = ~cache >> 31;
- LAST_SKIP_BITS(re, s, n);
- CLOSE_READER(re, s);
- return (NEG_USR32(sign ^ cache, n) ^ sign) - sign;
-#endif
-}
-
-#if !CACHED_BITSTREAM_READER
-static inline int get_xbits_le(GetBitContext *s, int n)
-{
- register int sign;
- register int32_t cache;
- OPEN_READER(re, s);
- av_assert2(n>0 && n<=25);
- UPDATE_CACHE_LE(re, s);
- cache = GET_CACHE(re, s);
- sign = sign_extend(~cache, n) >> 31;
- LAST_SKIP_BITS(re, s, n);
- CLOSE_READER(re, s);
- return (zero_extend(sign ^ cache, n) ^ sign) - sign;
-}
-#endif
-
-static inline int get_sbits(GetBitContext *s, int n)
-{
- register int tmp;
-#if CACHED_BITSTREAM_READER
- av_assert2(n>0 && n<=25);
- tmp = sign_extend(get_bits(s, n), n);
-#else
- OPEN_READER(re, s);
- av_assert2(n>0 && n<=25);
- UPDATE_CACHE(re, s);
- tmp = SHOW_SBITS(re, s, n);
- LAST_SKIP_BITS(re, s, n);
- CLOSE_READER(re, s);
-#endif
- return tmp;
-}
-
/**
* Read 1-25 bits.
*/
static inline unsigned int get_bits(GetBitContext *s, int n)
{
- register unsigned int tmp;
+ unsigned int tmp;
#if CACHED_BITSTREAM_READER
av_assert2(n>0 && n<=32);
@@ -409,61 +345,6 @@ static inline unsigned int get_bits(GetBitContext *s, int n)
return tmp;
}
-/**
- * Read 0-25 bits.
- */
-static av_always_inline int get_bitsz(GetBitContext *s, int n)
-{
- return n ? get_bits(s, n) : 0;
-}
-
-static inline unsigned int get_bits_le(GetBitContext *s, int n)
-{
-#if CACHED_BITSTREAM_READER
- av_assert2(n>0 && n<=32);
- if (n > s->bits_left) {
- refill_32(s, 1);
- if (s->bits_left < 32)
- s->bits_left = n;
- }
-
- return get_val(s, n, 1);
-#else
- register int tmp;
- OPEN_READER(re, s);
- av_assert2(n>0 && n<=25);
- UPDATE_CACHE_LE(re, s);
- tmp = SHOW_UBITS_LE(re, s, n);
- LAST_SKIP_BITS(re, s, n);
- CLOSE_READER(re, s);
- return tmp;
-#endif
-}
-
-/**
- * Show 1-25 bits.
- */
-static inline unsigned int show_bits(GetBitContext *s, int n)
-{
- register unsigned int tmp;
-#if CACHED_BITSTREAM_READER
- if (n > s->bits_left)
-#ifdef BITSTREAM_READER_LE
- refill_32(s, 1);
-#else
- refill_32(s, 0);
-#endif
-
- tmp = show_val(s, n);
-#else
- OPEN_READER_NOSIZE(re, s);
- av_assert2(n>0 && n<=25);
- UPDATE_CACHE(re, s);
- tmp = SHOW_UBITS(re, s, n);
-#endif
- return tmp;
-}
-
static inline void skip_bits(GetBitContext *s, int n)
{
#if CACHED_BITSTREAM_READER
@@ -530,11 +411,6 @@ static inline unsigned int get_bits1(GetBitContext *s)
#endif
}
-static inline unsigned int show_bits1(GetBitContext *s)
-{
- return show_bits(s, 1);
-}
-
static inline void skip_bits1(GetBitContext *s)
{
skip_bits(s, 1);
@@ -584,31 +460,6 @@ static inline uint64_t get_bits64(GetBitContext *s, int n)
}
}
-/**
- * Read 0-32 bits as a signed integer.
- */
-static inline int get_sbits_long(GetBitContext *s, int n)
-{
- // sign_extend(x, 0) is undefined
- if (!n)
- return 0;
-
- return sign_extend(get_bits_long(s, n), n);
-}
-
-/**
- * Show 0-32 bits.
- */
-static inline unsigned int show_bits_long(GetBitContext *s, int n)
-{
- if (n <= MIN_CACHE_BITS) {
- return show_bits(s, n);
- } else {
- GetBitContext gb = *s;
- return get_bits_long(&gb, n);
- }
-}
-
static inline int check_marker(void *logctx, GetBitContext *s, const char *msg)
{
int bit = get_bits1(s);
@@ -772,62 +623,6 @@ static inline const uint8_t *align_get_bits(GetBitContext *s)
SKIP_BITS(name, gb, n); \
} while (0)
-/* Return the LUT element for the given bitstream configuration. */
-static inline int set_idx(GetBitContext *s, int code, int *n, int *nb_bits,
- VLC_TYPE (*table)[2])
-{
- unsigned idx;
-
- *nb_bits = -*n;
- idx = show_bits(s, *nb_bits) + code;
- *n = table[idx][1];
-
- return table[idx][0];
-}
-
-/**
- * Parse a vlc code.
- * @param bits is the number of bits which will be read at once, must be
- * identical to nb_bits in init_vlc()
- * @param max_depth is the number of times bits bits must be read to completely
- * read the longest vlc code
- * = (max_vlc_length + bits - 1) / bits
- * @returns the code parsed or -1 if no vlc matches
- */
-static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
- int bits, int max_depth)
-{
-#if CACHED_BITSTREAM_READER
- int nb_bits;
- unsigned idx = show_bits(s, bits);
- int code = table[idx][0];
- int n = table[idx][1];
-
- if (max_depth > 1 && n < 0) {
- skip_remaining(s, bits);
- code = set_idx(s, code, &n, &nb_bits, table);
- if (max_depth > 2 && n < 0) {
- skip_remaining(s, nb_bits);
- code = set_idx(s, code, &n, &nb_bits, table);
- }
- }
- skip_remaining(s, n);
-
- return code;
-#else
- int code;
-
- OPEN_READER(re, s);
- UPDATE_CACHE(re, s);
-
- GET_VLC(code, re, s, table, bits, max_depth);
-
- CLOSE_READER(re, s);
-
- return code;
-#endif
-}
-
static inline int decode012(GetBitContext *gb)
{
int n;
@@ -865,4 +660,14 @@ static inline int skip_1stop_8data_bits(GetBitContext *gb)
return 0;
}
+static inline unsigned int show_bits_long(GetBitContext *s, int n)
+{
+ if (n <= MIN_CACHE_BITS) {
+ return show_bits(s, n);
+ } else {
+ GetBitContext gb = *s;
+ return get_bits_long(&gb, n);
+ }
+}
+
#endif /* AVCODEC_GET_BITS_H */
diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h
index 7fd46a9..637111a 100644
--- a/libavcodec/golomb.h
+++ b/libavcodec/golomb.h
@@ -33,7 +33,6 @@
#include <stdint.h>
#include "get_bits.h"
-#include "put_bits.h"
#define INVALID_VLC 0x80000000
@@ -422,144 +421,6 @@ static inline int get_ur_golomb(GetBitContext *gb, int k, int limit,
#endif
}
-/**
- * read unsigned golomb rice code (jpegls).
- */
-static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit,
- int esc_len)
-{
- unsigned int buf;
- int log;
-
-#if CACHED_BITSTREAM_READER
- buf = show_bits_long(gb, 32);
-
- log = av_log2(buf);
-
- if (log - k >= 1 && 32 - log < limit) {
- buf >>= log - k;
- buf += (30 - log) << k;
- skip_bits_long(gb, 32 + k - log);
-
- return buf;
- } else {
- int i;
- for (i = 0;
- i < limit && get_bits1(gb) == 0 && get_bits_left(gb) > 0;
- i++);
-
- if (i < limit - 1) {
- buf = get_bits_long(gb, k);
-
- return buf + (i << k);
- } else if (i == limit - 1) {
- buf = get_bits_long(gb, esc_len);
-
- return buf + 1;
- } else
- return -1;
- }
-#else
- OPEN_READER(re, gb);
- UPDATE_CACHE(re, gb);
- buf = GET_CACHE(re, gb);
-
- log = av_log2(buf);
-
- av_assert2(k <= 31);
-
- if (log - k >= 32 - MIN_CACHE_BITS + (MIN_CACHE_BITS == 32) &&
- 32 - log < limit) {
- buf >>= log - k;
- buf += (30U - log) << k;
- LAST_SKIP_BITS(re, gb, 32 + k - log);
- CLOSE_READER(re, gb);
-
- return buf;
- } else {
- int i;
- for (i = 0; i + MIN_CACHE_BITS <= limit && SHOW_UBITS(re, gb, MIN_CACHE_BITS) == 0; i += MIN_CACHE_BITS) {
- if (gb->size_in_bits <= re_index) {
- CLOSE_READER(re, gb);
- return -1;
- }
- LAST_SKIP_BITS(re, gb, MIN_CACHE_BITS);
- UPDATE_CACHE(re, gb);
- }
- for (; i < limit && SHOW_UBITS(re, gb, 1) == 0; i++) {
- SKIP_BITS(re, gb, 1);
- }
- LAST_SKIP_BITS(re, gb, 1);
- UPDATE_CACHE(re, gb);
-
- if (i < limit - 1) {
- if (k) {
- if (k > MIN_CACHE_BITS - 1) {
- buf = SHOW_UBITS(re, gb, 16) << (k-16);
- LAST_SKIP_BITS(re, gb, 16);
- UPDATE_CACHE(re, gb);
- buf |= SHOW_UBITS(re, gb, k-16);
- LAST_SKIP_BITS(re, gb, k-16);
- } else {
- buf = SHOW_UBITS(re, gb, k);
- LAST_SKIP_BITS(re, gb, k);
- }
- } else {
- buf = 0;
- }
-
- buf += ((SUINT)i << k);
- } else if (i == limit - 1) {
- buf = SHOW_UBITS(re, gb, esc_len);
- LAST_SKIP_BITS(re, gb, esc_len);
-
- buf ++;
- } else {
- buf = -1;
- }
- CLOSE_READER(re, gb);
- return buf;
- }
-#endif
-}
-
-/**
- * read signed golomb rice code (ffv1).
- */
-static inline int get_sr_golomb(GetBitContext *gb, int k, int limit,
- int esc_len)
-{
- unsigned v = get_ur_golomb(gb, k, limit, esc_len);
- return (v >> 1) ^ -(v & 1);
-}
-
-/**
- * read signed golomb rice code (flac).
- */
-static inline int get_sr_golomb_flac(GetBitContext *gb, int k, int limit,
- int esc_len)
-{
- unsigned v = get_ur_golomb_jpegls(gb, k, limit, esc_len);
- return (v >> 1) ^ -(v & 1);
-}
-
-/**
- * read unsigned golomb rice code (shorten).
- */
-static inline unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k)
-{
- return get_ur_golomb_jpegls(gb, k, INT_MAX, 0);
-}
-
-/**
- * read signed golomb rice code (shorten).
- */
-static inline int get_sr_golomb_shorten(GetBitContext *gb, int k)
-{
- int uvar = get_ur_golomb_jpegls(gb, k + 1, INT_MAX, 0);
- return (uvar >> 1) ^ -(uvar & 1);
-}
-
#ifdef TRACE
static inline int get_ue(GetBitContext *s, const char *file, const char *func,
@@ -614,134 +475,4 @@ static inline int get_te(GetBitContext *s, int r, char *file, const char *func,
#endif /* TRACE */
-/**
- * write unsigned exp golomb code. 2^16 - 2 at most
- */
-static inline void set_ue_golomb(PutBitContext *pb, int i)
-{
- av_assert2(i >= 0);
- av_assert2(i <= 0xFFFE);
-
- if (i < 256)
- put_bits(pb, ff_ue_golomb_len[i], i + 1);
- else {
- int e = av_log2(i + 1);
- put_bits(pb, 2 * e + 1, i + 1);
- }
-}
-
-/**
- * write unsigned exp golomb code. 2^32-2 at most.
- */
-static inline void set_ue_golomb_long(PutBitContext *pb, uint32_t i)
-{
- av_assert2(i <= (UINT32_MAX - 1));
-
- if (i < 256)
- put_bits(pb, ff_ue_golomb_len[i], i + 1);
- else {
- int e = av_log2(i + 1);
- put_bits64(pb, 2 * e + 1, i + 1);
- }
-}
-
-/**
- * write truncated unsigned exp golomb code.
- */
-static inline void set_te_golomb(PutBitContext *pb, int i, int range)
-{
- av_assert2(range >= 1);
- av_assert2(i <= range);
-
- if (range == 2)
- put_bits(pb, 1, i ^ 1);
- else
- set_ue_golomb(pb, i);
-}
-
-/**
- * write signed exp golomb code. 16 bits at most.
- */
-static inline void set_se_golomb(PutBitContext *pb, int i)
-{
- i = 2 * i - 1;
- if (i < 0)
- i ^= -1; //FIXME check if gcc does the right thing
- set_ue_golomb(pb, i);
-}
-
-/**
- * write unsigned golomb rice code (ffv1).
- */
-static inline void set_ur_golomb(PutBitContext *pb, int i, int k, int limit,
- int esc_len)
-{
- int e;
-
- av_assert2(i >= 0);
-
- e = i >> k;
- if (e < limit)
- put_bits(pb, e + k + 1, (1 << k) + av_mod_uintp2(i, k));
- else
- put_bits(pb, limit + esc_len, i - limit + 1);
-}
-
-/**
- * write unsigned golomb rice code (jpegls).
- */
-static inline void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k,
- int limit, int esc_len)
-{
- int e;
-
- av_assert2(i >= 0);
-
- e = (i >> k) + 1;
- if (e < limit) {
- while (e > 31) {
- put_bits(pb, 31, 0);
- e -= 31;
- }
- put_bits(pb, e, 1);
- if (k)
- put_sbits(pb, k, i);
- } else {
- while (limit > 31) {
- put_bits(pb, 31, 0);
- limit -= 31;
- }
- put_bits(pb, limit, 1);
- put_bits(pb, esc_len, i - 1);
- }
-}
-
-/**
- * write signed golomb rice code (ffv1).
- */
-static inline void set_sr_golomb(PutBitContext *pb, int i, int k, int limit,
- int esc_len)
-{
- int v;
-
- v = -2 * i - 1;
- v ^= (v >> 31);
-
- set_ur_golomb(pb, v, k, limit, esc_len);
-}
-
-/**
- * write signed golomb rice code (flac).
- */
-static inline void set_sr_golomb_flac(PutBitContext *pb, int i, int k,
- int limit, int esc_len)
-{
- int v;
-
- v = -2 * i - 1;
- v ^= (v >> 31);
-
- set_ur_golomb_jpegls(pb, v, k, limit, esc_len);
-}
-
#endif /* AVCODEC_GOLOMB_H */
--
2.32.0