Loading crypto/include/internal/lhash.h +15 Changes for crypto/include/internal/lhash.h: 15 added lines, 0 removed lines. Original line number Diff line number Diff line /* * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #ifndef INTERNAL_LHASH_H # define INTERNAL_LHASH_H unsigned long openssl_lh_strcasehash(const char *); #endif crypto/lhash/lhash.c +23 Changes for crypto/lhash/lhash.c: 23 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -12,6 +12,8 @@ #include <stdlib.h> #include <openssl/crypto.h> #include <openssl/lhash.h> #include <ctype.h> #include "internal/lhash.h" #include "lhash_lcl.h" /* Loading Loading @@ -351,6 +353,27 @@ unsigned long OPENSSL_LH_strhash(const char *c) return ((ret >> 16) ^ ret); } unsigned long openssl_lh_strcasehash(const char *c) { unsigned long ret = 0; long n; unsigned long v; int r; if (c == NULL || *c == '\0') return ret; for (n = 0x100; *c != '\0'; n += 0x100) { v = n | tolower(*c); r = (int)((v >> 2) ^ v) & 0x0f; ret = (ret << r) | (ret >> (32 - r)); ret &= 0xFFFFFFFFL; ret ^= v * v; c++; } return (ret >> 16) ^ ret; } unsigned long OPENSSL_LH_num_items(const OPENSSL_LHASH *lh) { return lh ? lh->num_items : 0; Loading crypto/objects/o_names.c +15 −16 Changes for crypto/objects/o_names.c: 15 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -16,27 +16,26 @@ #include <openssl/objects.h> #include <openssl/safestack.h> #include <openssl/e_os2.h> #include <internal/thread_once.h> #include "internal/thread_once.h" #include "internal/lhash.h" #include "obj_lcl.h" #include "e_os.h" /* * We define this wrapper for two reasons. Firstly, later versions of * DEC C add linkage information to certain functions, which makes it * tricky to use them as values to regular function pointers. * Secondly, in the EDK2 build environment, the strcmp function is * actually an external function (AsciiStrCmp) with the Microsoft ABI, * so we can't transparently assign function pointers to it. * Arguably the latter is a stupidity of the UEFI environment, but * since the wrapper solves the DEC C issue too, let's just use the * same solution. * Secondly, in the EDK2 build environment, the strcasecmp function is * actually an external function with the Microsoft ABI, so we can't * transparently assign function pointers to it. */ #if defined(OPENSSL_SYS_VMS_DECC) || defined(OPENSSL_SYS_UEFI) static int obj_strcmp(const char *a, const char *b) static int obj_strcasecmp(const char *a, const char *b) { return strcmp(a, b); return strcasecmp(a, b); } #else #define obj_strcmp strcmp #define obj_strcasecmp strcasecmp #endif /* Loading Loading @@ -111,8 +110,8 @@ int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *), ret = 0; goto out; } name_funcs->hash_func = OPENSSL_LH_strhash; name_funcs->cmp_func = obj_strcmp; name_funcs->hash_func = openssl_lh_strcasehash; name_funcs->cmp_func = obj_strcasecmp; CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE); push = sk_NAME_FUNCS_push(name_funcs_stack, name_funcs); Loading Loading @@ -149,7 +148,7 @@ static int obj_name_cmp(const OBJ_NAME *a, const OBJ_NAME *b) ret = sk_NAME_FUNCS_value(name_funcs_stack, a->type)->cmp_func(a->name, b->name); } else ret = strcmp(a->name, b->name); ret = strcasecmp(a->name, b->name); } return ret; } Loading @@ -164,7 +163,7 @@ static unsigned long obj_name_hash(const OBJ_NAME *a) sk_NAME_FUNCS_value(name_funcs_stack, a->type)->hash_func(a->name); } else { ret = OPENSSL_LH_strhash(a->name); ret = openssl_lh_strcasehash(a->name); } ret ^= a->type; return ret; Loading Loading @@ -214,8 +213,6 @@ int OBJ_NAME_add(const char *name, int type, const char *data) if (!OBJ_NAME_init()) return 0; CRYPTO_THREAD_write_lock(lock); alias = type & OBJ_NAME_ALIAS; type &= ~OBJ_NAME_ALIAS; Loading @@ -230,6 +227,8 @@ int OBJ_NAME_add(const char *name, int type, const char *data) onp->type = type; onp->data = data; CRYPTO_THREAD_write_lock(lock); ret = lh_OBJ_NAME_insert(names_lh, onp); if (ret != NULL) { /* free things */ Loading test/evptests.txt +30 Changes for test/evptests.txt: 30 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -19271,3 +19271,33 @@ Result = KEYPAIR_MISMATCH PrivPubKeyPair = DSA-1024-BIS:DSA-1024-PUBLIC Result = KEYPAIR_MISMATCH # Some name is case insensitive tests Cipher = Aes-128-eCb Key = 2B7E151628AED2A6ABF7158809CF4F3C Plaintext = 6BC1BEE22E409F96E93D7E117393172A Ciphertext = 3AD77BB40D7A3660A89ECAF32466EF97 Cipher = AeS-128-cbC Key = 2B7E151628AED2A6ABF7158809CF4F3C IV = 73BED6B8E3C1743B7116E69E22229516 Plaintext = F69F2445DF4F9B17AD2B417BE66C3710 Ciphertext = 3FF1CAA1681FAC09120ECA307586E1A7 Cipher = aES-128-CTR Key = AE6852F8121067CC4BF7A5765577F39E IV = 00000030000000000000000000000001 Operation = ENCRYPT Plaintext = 53696E676C6520626C6F636B206D7367 Ciphertext = E4095D4FB7A7B3792D6175A3261311B8 Cipher = AES-128-GcM Key = 00000000000000000000000000000000 IV = 000000000000000000000000 AAD = Tag = ab6e47d42cec13bdf53a67b21257bddf Plaintext = 00000000000000000000000000000000 Ciphertext = 0388dace60b6a392f328c2b971b2fe78 Digest = shA512 Input = "abc" Output = ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f Loading
crypto/include/internal/lhash.h +15 Changes for crypto/include/internal/lhash.h: 15 added lines, 0 removed lines. Original line number Diff line number Diff line /* * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #ifndef INTERNAL_LHASH_H # define INTERNAL_LHASH_H unsigned long openssl_lh_strcasehash(const char *); #endif
crypto/lhash/lhash.c +23 Changes for crypto/lhash/lhash.c: 23 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -12,6 +12,8 @@ #include <stdlib.h> #include <openssl/crypto.h> #include <openssl/lhash.h> #include <ctype.h> #include "internal/lhash.h" #include "lhash_lcl.h" /* Loading Loading @@ -351,6 +353,27 @@ unsigned long OPENSSL_LH_strhash(const char *c) return ((ret >> 16) ^ ret); } unsigned long openssl_lh_strcasehash(const char *c) { unsigned long ret = 0; long n; unsigned long v; int r; if (c == NULL || *c == '\0') return ret; for (n = 0x100; *c != '\0'; n += 0x100) { v = n | tolower(*c); r = (int)((v >> 2) ^ v) & 0x0f; ret = (ret << r) | (ret >> (32 - r)); ret &= 0xFFFFFFFFL; ret ^= v * v; c++; } return (ret >> 16) ^ ret; } unsigned long OPENSSL_LH_num_items(const OPENSSL_LHASH *lh) { return lh ? lh->num_items : 0; Loading
crypto/objects/o_names.c +15 −16 Changes for crypto/objects/o_names.c: 15 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -16,27 +16,26 @@ #include <openssl/objects.h> #include <openssl/safestack.h> #include <openssl/e_os2.h> #include <internal/thread_once.h> #include "internal/thread_once.h" #include "internal/lhash.h" #include "obj_lcl.h" #include "e_os.h" /* * We define this wrapper for two reasons. Firstly, later versions of * DEC C add linkage information to certain functions, which makes it * tricky to use them as values to regular function pointers. * Secondly, in the EDK2 build environment, the strcmp function is * actually an external function (AsciiStrCmp) with the Microsoft ABI, * so we can't transparently assign function pointers to it. * Arguably the latter is a stupidity of the UEFI environment, but * since the wrapper solves the DEC C issue too, let's just use the * same solution. * Secondly, in the EDK2 build environment, the strcasecmp function is * actually an external function with the Microsoft ABI, so we can't * transparently assign function pointers to it. */ #if defined(OPENSSL_SYS_VMS_DECC) || defined(OPENSSL_SYS_UEFI) static int obj_strcmp(const char *a, const char *b) static int obj_strcasecmp(const char *a, const char *b) { return strcmp(a, b); return strcasecmp(a, b); } #else #define obj_strcmp strcmp #define obj_strcasecmp strcasecmp #endif /* Loading Loading @@ -111,8 +110,8 @@ int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *), ret = 0; goto out; } name_funcs->hash_func = OPENSSL_LH_strhash; name_funcs->cmp_func = obj_strcmp; name_funcs->hash_func = openssl_lh_strcasehash; name_funcs->cmp_func = obj_strcasecmp; CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE); push = sk_NAME_FUNCS_push(name_funcs_stack, name_funcs); Loading Loading @@ -149,7 +148,7 @@ static int obj_name_cmp(const OBJ_NAME *a, const OBJ_NAME *b) ret = sk_NAME_FUNCS_value(name_funcs_stack, a->type)->cmp_func(a->name, b->name); } else ret = strcmp(a->name, b->name); ret = strcasecmp(a->name, b->name); } return ret; } Loading @@ -164,7 +163,7 @@ static unsigned long obj_name_hash(const OBJ_NAME *a) sk_NAME_FUNCS_value(name_funcs_stack, a->type)->hash_func(a->name); } else { ret = OPENSSL_LH_strhash(a->name); ret = openssl_lh_strcasehash(a->name); } ret ^= a->type; return ret; Loading Loading @@ -214,8 +213,6 @@ int OBJ_NAME_add(const char *name, int type, const char *data) if (!OBJ_NAME_init()) return 0; CRYPTO_THREAD_write_lock(lock); alias = type & OBJ_NAME_ALIAS; type &= ~OBJ_NAME_ALIAS; Loading @@ -230,6 +227,8 @@ int OBJ_NAME_add(const char *name, int type, const char *data) onp->type = type; onp->data = data; CRYPTO_THREAD_write_lock(lock); ret = lh_OBJ_NAME_insert(names_lh, onp); if (ret != NULL) { /* free things */ Loading
test/evptests.txt +30 Changes for test/evptests.txt: 30 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -19271,3 +19271,33 @@ Result = KEYPAIR_MISMATCH PrivPubKeyPair = DSA-1024-BIS:DSA-1024-PUBLIC Result = KEYPAIR_MISMATCH # Some name is case insensitive tests Cipher = Aes-128-eCb Key = 2B7E151628AED2A6ABF7158809CF4F3C Plaintext = 6BC1BEE22E409F96E93D7E117393172A Ciphertext = 3AD77BB40D7A3660A89ECAF32466EF97 Cipher = AeS-128-cbC Key = 2B7E151628AED2A6ABF7158809CF4F3C IV = 73BED6B8E3C1743B7116E69E22229516 Plaintext = F69F2445DF4F9B17AD2B417BE66C3710 Ciphertext = 3FF1CAA1681FAC09120ECA307586E1A7 Cipher = aES-128-CTR Key = AE6852F8121067CC4BF7A5765577F39E IV = 00000030000000000000000000000001 Operation = ENCRYPT Plaintext = 53696E676C6520626C6F636B206D7367 Ciphertext = E4095D4FB7A7B3792D6175A3261311B8 Cipher = AES-128-GcM Key = 00000000000000000000000000000000 IV = 000000000000000000000000 AAD = Tag = ab6e47d42cec13bdf53a67b21257bddf Plaintext = 00000000000000000000000000000000 Ciphertext = 0388dace60b6a392f328c2b971b2fe78 Digest = shA512 Input = "abc" Output = ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f