[llvm-branch-commits] [compiler-rt] release/19.x: [compiler-rt] Remove SHA2 interceptions for NetBSD/Free… (PR #111725)
David CARLIER via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Oct 9 10:42:13 PDT 2024
https://github.com/devnexen created https://github.com/llvm/llvm-project/pull/111725
…BSD. (#110246)
For backport #111724
To Fix #110215
Interceptors introduced with 18a7ebda99044473fdbce6376993714ff54e6690
>From cb632327b87e78506d6d91d1d7244e5a5f5c87e6 Mon Sep 17 00:00:00 2001
From: David CARLIER <devnexen at gmail.com>
Date: Wed, 9 Oct 2024 05:47:00 +0100
Subject: [PATCH] release/19.x: [compiler-rt] Remove SHA2 interceptions for
NetBSD/FreeBSD. (#110246)
To Fix #110215
Interceptors introduced with 18a7ebda99044473fdbce6376993714ff54e6690
---
.../sanitizer_common_interceptors.inc | 180 ---------------
.../sanitizer_platform_interceptors.h | 2 -
.../TestCases/FreeBSD/md5.cpp | 119 ----------
.../TestCases/FreeBSD/sha2.cpp | 214 ------------------
.../sanitizer_common/TestCases/NetBSD/md5.cpp | 114 ----------
.../TestCases/NetBSD/sha2.cpp | 206 -----------------
6 files changed, 835 deletions(-)
delete mode 100644 compiler-rt/test/sanitizer_common/TestCases/FreeBSD/md5.cpp
delete mode 100644 compiler-rt/test/sanitizer_common/TestCases/FreeBSD/sha2.cpp
delete mode 100644 compiler-rt/test/sanitizer_common/TestCases/NetBSD/md5.cpp
delete mode 100644 compiler-rt/test/sanitizer_common/TestCases/NetBSD/sha2.cpp
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 49c9dcbef358ff..7a7af7936af315 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -8823,83 +8823,6 @@ INTERCEPTOR(char *, RMD160Data, u8 *data, SIZE_T len, char *buf) {
#define INIT_RMD160
#endif
-#if SANITIZER_INTERCEPT_MD5
-INTERCEPTOR(void, MD5Init, void *context) {
- void *ctx;
- COMMON_INTERCEPTOR_ENTER(ctx, MD5Init, context);
- REAL(MD5Init)(context);
- if (context)
- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, context, MD5_CTX_sz);
-}
-
-INTERCEPTOR(void, MD5Update, void *context, const unsigned char *data,
- unsigned int len) {
- void *ctx;
- COMMON_INTERCEPTOR_ENTER(ctx, MD5Update, context, data, len);
- if (data && len > 0)
- COMMON_INTERCEPTOR_READ_RANGE(ctx, data, len);
- if (context)
- COMMON_INTERCEPTOR_READ_RANGE(ctx, context, MD5_CTX_sz);
- REAL(MD5Update)(context, data, len);
- if (context)
- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, context, MD5_CTX_sz);
-}
-
-INTERCEPTOR(void, MD5Final, unsigned char digest[16], void *context) {
- void *ctx;
- COMMON_INTERCEPTOR_ENTER(ctx, MD5Final, digest, context);
- if (context)
- COMMON_INTERCEPTOR_READ_RANGE(ctx, context, MD5_CTX_sz);
- REAL(MD5Final)(digest, context);
- if (digest)
- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, digest, sizeof(unsigned char) * 16);
-}
-
-INTERCEPTOR(char *, MD5End, void *context, char *buf) {
- void *ctx;
- COMMON_INTERCEPTOR_ENTER(ctx, MD5End, context, buf);
- if (context)
- COMMON_INTERCEPTOR_READ_RANGE(ctx, context, MD5_CTX_sz);
- char *ret = REAL(MD5End)(context, buf);
- if (ret)
- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, MD5_return_length);
- return ret;
-}
-
-INTERCEPTOR(char *, MD5File, const char *filename, char *buf) {
- void *ctx;
- COMMON_INTERCEPTOR_ENTER(ctx, MD5File, filename, buf);
- if (filename)
- COMMON_INTERCEPTOR_READ_RANGE(ctx, filename, internal_strlen(filename) + 1);
- char *ret = REAL(MD5File)(filename, buf);
- if (ret)
- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, MD5_return_length);
- return ret;
-}
-
-INTERCEPTOR(char *, MD5Data, const unsigned char *data, unsigned int len,
- char *buf) {
- void *ctx;
- COMMON_INTERCEPTOR_ENTER(ctx, MD5Data, data, len, buf);
- if (data && len > 0)
- COMMON_INTERCEPTOR_READ_RANGE(ctx, data, len);
- char *ret = REAL(MD5Data)(data, len, buf);
- if (ret)
- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, MD5_return_length);
- return ret;
-}
-
-#define INIT_MD5 \
- COMMON_INTERCEPT_FUNCTION(MD5Init); \
- COMMON_INTERCEPT_FUNCTION(MD5Update); \
- COMMON_INTERCEPT_FUNCTION(MD5Final); \
- COMMON_INTERCEPT_FUNCTION(MD5End); \
- COMMON_INTERCEPT_FUNCTION(MD5File); \
- COMMON_INTERCEPT_FUNCTION(MD5Data)
-#else
-#define INIT_MD5
-#endif
-
#if SANITIZER_INTERCEPT_FSEEK
INTERCEPTOR(int, fseek, __sanitizer_FILE *stream, long int offset, int whence) {
void *ctx;
@@ -9030,107 +8953,6 @@ INTERCEPTOR(char *, MD2Data, const unsigned char *data, unsigned int len,
#define INIT_MD2
#endif
-#if SANITIZER_INTERCEPT_SHA2
-#define SHA2_INTERCEPTORS(LEN, SHA2_STATE_T) \
- INTERCEPTOR(void, SHA##LEN##_Init, void *context) { \
- void *ctx; \
- COMMON_INTERCEPTOR_ENTER(ctx, SHA##LEN##_Init, context); \
- REAL(SHA##LEN##_Init)(context); \
- if (context) \
- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, context, SHA##LEN##_CTX_sz); \
- } \
- INTERCEPTOR(void, SHA##LEN##_Update, void *context, \
- const u8 *data, SIZE_T len) { \
- void *ctx; \
- COMMON_INTERCEPTOR_ENTER(ctx, SHA##LEN##_Update, context, data, len); \
- if (data && len > 0) \
- COMMON_INTERCEPTOR_READ_RANGE(ctx, data, len); \
- if (context) \
- COMMON_INTERCEPTOR_READ_RANGE(ctx, context, SHA##LEN##_CTX_sz); \
- REAL(SHA##LEN##_Update)(context, data, len); \
- if (context) \
- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, context, SHA##LEN##_CTX_sz); \
- } \
- INTERCEPTOR(void, SHA##LEN##_Final, u8 digest[LEN/8], \
- void *context) { \
- void *ctx; \
- CHECK_EQ(SHA##LEN##_digest_length, LEN/8); \
- COMMON_INTERCEPTOR_ENTER(ctx, SHA##LEN##_Final, digest, context); \
- if (context) \
- COMMON_INTERCEPTOR_READ_RANGE(ctx, context, SHA##LEN##_CTX_sz); \
- REAL(SHA##LEN##_Final)(digest, context); \
- if (digest) \
- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, digest, \
- sizeof(digest[0]) * \
- SHA##LEN##_digest_length); \
- } \
- INTERCEPTOR(char *, SHA##LEN##_End, void *context, char *buf) { \
- void *ctx; \
- COMMON_INTERCEPTOR_ENTER(ctx, SHA##LEN##_End, context, buf); \
- if (context) \
- COMMON_INTERCEPTOR_READ_RANGE(ctx, context, SHA##LEN##_CTX_sz); \
- char *ret = REAL(SHA##LEN##_End)(context, buf); \
- if (ret) \
- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, SHA##LEN##_return_length); \
- return ret; \
- } \
- INTERCEPTOR(char *, SHA##LEN##_File, const char *filename, char *buf) { \
- void *ctx; \
- COMMON_INTERCEPTOR_ENTER(ctx, SHA##LEN##_File, filename, buf); \
- if (filename) \
- COMMON_INTERCEPTOR_READ_RANGE(ctx, filename, internal_strlen(filename) + 1);\
- char *ret = REAL(SHA##LEN##_File)(filename, buf); \
- if (ret) \
- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, SHA##LEN##_return_length); \
- return ret; \
- } \
- INTERCEPTOR(char *, SHA##LEN##_FileChunk, const char *filename, char *buf, \
- OFF_T offset, OFF_T length) { \
- void *ctx; \
- COMMON_INTERCEPTOR_ENTER(ctx, SHA##LEN##_FileChunk, filename, buf, offset, \
- length); \
- if (filename) \
- COMMON_INTERCEPTOR_READ_RANGE(ctx, filename, internal_strlen(filename) + 1);\
- char *ret = REAL(SHA##LEN##_FileChunk)(filename, buf, offset, length); \
- if (ret) \
- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, SHA##LEN##_return_length); \
- return ret; \
- } \
- INTERCEPTOR(char *, SHA##LEN##_Data, u8 *data, SIZE_T len, char *buf) { \
- void *ctx; \
- COMMON_INTERCEPTOR_ENTER(ctx, SHA##LEN##_Data, data, len, buf); \
- if (data && len > 0) \
- COMMON_INTERCEPTOR_READ_RANGE(ctx, data, len); \
- char *ret = REAL(SHA##LEN##_Data)(data, len, buf); \
- if (ret) \
- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, SHA##LEN##_return_length); \
- return ret; \
- }
-
-SHA2_INTERCEPTORS(224, u32)
-SHA2_INTERCEPTORS(256, u32)
-SHA2_INTERCEPTORS(384, u64)
-SHA2_INTERCEPTORS(512, u64)
-
-#define INIT_SHA2_INTECEPTORS(LEN) \
- COMMON_INTERCEPT_FUNCTION(SHA##LEN##_Init); \
- COMMON_INTERCEPT_FUNCTION(SHA##LEN##_Update); \
- COMMON_INTERCEPT_FUNCTION(SHA##LEN##_Final); \
- COMMON_INTERCEPT_FUNCTION(SHA##LEN##_End); \
- COMMON_INTERCEPT_FUNCTION(SHA##LEN##_File); \
- COMMON_INTERCEPT_FUNCTION(SHA##LEN##_FileChunk); \
- COMMON_INTERCEPT_FUNCTION(SHA##LEN##_Data)
-
-#define INIT_SHA2 \
- INIT_SHA2_INTECEPTORS(224); \
- INIT_SHA2_INTECEPTORS(256); \
- INIT_SHA2_INTECEPTORS(384); \
- INIT_SHA2_INTECEPTORS(512)
-#undef SHA2_INTERCEPTORS
-#else
-#define INIT_SHA2
-#endif
-
#if SANITIZER_INTERCEPT_VIS
INTERCEPTOR(char *, vis, char *dst, int c, int flag, int nextc) {
void *ctx;
@@ -10588,10 +10410,8 @@ static void InitializeCommonInterceptors() {
INIT_SHA1;
INIT_MD4;
INIT_RMD160;
- INIT_MD5;
INIT_FSEEK;
INIT_MD2;
- INIT_SHA2;
INIT_VIS;
INIT_CDB;
INIT_GETFSENT;
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
index 7d7ed9bc07ccfe..05cd2d71cbbae6 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -559,10 +559,8 @@
#define SANITIZER_INTERCEPT_SHA1 SI_NETBSD
#define SANITIZER_INTERCEPT_MD4 SI_NETBSD
#define SANITIZER_INTERCEPT_RMD160 SI_NETBSD
-#define SANITIZER_INTERCEPT_MD5 (SI_NETBSD || SI_FREEBSD)
#define SANITIZER_INTERCEPT_FSEEK (SI_NETBSD || SI_FREEBSD)
#define SANITIZER_INTERCEPT_MD2 SI_NETBSD
-#define SANITIZER_INTERCEPT_SHA2 (SI_NETBSD || SI_FREEBSD)
#define SANITIZER_INTERCEPT_CDB SI_NETBSD
#define SANITIZER_INTERCEPT_VIS (SI_NETBSD || SI_FREEBSD)
#define SANITIZER_INTERCEPT_POPEN SI_POSIX
diff --git a/compiler-rt/test/sanitizer_common/TestCases/FreeBSD/md5.cpp b/compiler-rt/test/sanitizer_common/TestCases/FreeBSD/md5.cpp
deleted file mode 100644
index 13325880a023a1..00000000000000
--- a/compiler-rt/test/sanitizer_common/TestCases/FreeBSD/md5.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-// RUN: %clangxx -O0 -g %s -o %t -lmd && %run %t 2>&1 | FileCheck %s
-
-#include <sys/param.h>
-
-#include <assert.h>
-#include <md5.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-void test1() {
- MD5_CTX ctx;
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
- uint8_t digest[MD5_DIGEST_LENGTH];
- size_t entropysz = sizeof(entropy);
- size_t digestsz = sizeof(digest);
-
- MD5Init(&ctx);
- MD5Update(&ctx, entropy, entropysz);
- MD5Final(digest, &ctx);
-
- printf("test1: '");
- for (size_t i = 0; i < digestsz; i++)
- printf("%02x", digest[i]);
- printf("'\n");
-}
-
-void test2() {
- MD5_CTX ctx;
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
- char digest[MD5_DIGEST_STRING_LENGTH];
- size_t entropysz = sizeof(entropy);
-
- MD5Init(&ctx);
- MD5Update(&ctx, entropy, entropysz);
- char *p = MD5End(&ctx, digest);
- assert(p);
-
- printf("test2: '%s'\n", digest);
-}
-
-void test3() {
- MD5_CTX ctx;
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
- size_t entropysz = sizeof(entropy);
-
- MD5Init(&ctx);
- MD5Update(&ctx, entropy, entropysz);
- char *p = MD5End(&ctx, NULL);
- assert(strlen(p) == MD5_DIGEST_STRING_LENGTH - 1);
-
- printf("test3: '%s'\n", p);
-
- free(p);
-}
-
-void test4() {
- char digest[MD5_DIGEST_STRING_LENGTH];
-
- char *p = MD5File("/etc/fstab", digest);
- assert(p == digest);
-
- printf("test4: '%s'\n", p);
-}
-
-void test5() {
- char *p = MD5File("/etc/fstab", NULL);
- assert(strlen(p) == MD5_DIGEST_STRING_LENGTH - 1);
-
- printf("test5: '%s'\n", p);
-
- free(p);
-}
-
-void test6() {
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
- char digest[MD5_DIGEST_STRING_LENGTH];
- size_t entropysz = sizeof(entropy);
-
- char *p = MD5Data(entropy, entropysz, digest);
- assert(p == digest);
-
- printf("test6: '%s'\n", p);
-}
-
-void test7() {
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
- size_t entropysz = sizeof(entropy);
-
- char *p = MD5Data(entropy, entropysz, NULL);
- assert(strlen(p) == MD5_DIGEST_STRING_LENGTH - 1);
-
- printf("test7: '%s'\n", p);
-
- free(p);
-}
-
-int main(void) {
- printf("MD5\n");
-
- test1();
- test2();
- test3();
- test4();
- test5();
- test6();
- test7();
-
- // CHECK: MD5
- // CHECK: test1: '86e65b1ef4a830af347ac05ab4f0e999'
- // CHECK: test2: '86e65b1ef4a830af347ac05ab4f0e999'
- // CHECK: test3: '86e65b1ef4a830af347ac05ab4f0e999'
- // CHECK: test4: '{{.*}}'
- // CHECK: test5: '{{.*}}'
- // CHECK: test6: '86e65b1ef4a830af347ac05ab4f0e999'
- // CHECK: test7: '86e65b1ef4a830af347ac05ab4f0e999'
-
- return 0;
-}
diff --git a/compiler-rt/test/sanitizer_common/TestCases/FreeBSD/sha2.cpp b/compiler-rt/test/sanitizer_common/TestCases/FreeBSD/sha2.cpp
deleted file mode 100644
index 3012aca7d72072..00000000000000
--- a/compiler-rt/test/sanitizer_common/TestCases/FreeBSD/sha2.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-// RUN: %clangxx -O0 -g %s -DSHASIZE=224 -o %t -lmd && %run %t 2>&1 | FileCheck %s -check-prefix=CHECK-224
-// RUN: %clangxx -O0 -g %s -DSHASIZE=256 -o %t -lmd && %run %t 2>&1 | FileCheck %s -check-prefix=CHECK-256
-// RUN: %clangxx -O0 -g %s -DSHASIZE=384 -o %t -lmd && %run %t 2>&1 | FileCheck %s -check-prefix=CHECK-384
-// RUN: %clangxx -O0 -g %s -DSHASIZE=512 -o %t -lmd && %run %t 2>&1 | FileCheck %s -check-prefix=CHECK-512
-
-#include <sys/param.h>
-
-#include <assert.h>
-#include <sha224.h>
-#include <sha256.h>
-#include <sha384.h>
-#include <sha512.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef SHASIZE
-#error SHASIZE must be defined
-#endif
-
-#define _SHA_CTX(x) SHA##x##_CTX
-#define SHA_CTX(x) _SHA_CTX(x)
-
-#define _SHA_DIGEST_LENGTH(x) SHA##x##_DIGEST_LENGTH
-#define SHA_DIGEST_LENGTH(x) _SHA_DIGEST_LENGTH(x)
-
-#define _SHA_DIGEST_STRING_LENGTH(x) SHA##x##_DIGEST_STRING_LENGTH
-#define SHA_DIGEST_STRING_LENGTH(x) _SHA_DIGEST_STRING_LENGTH(x)
-
-#define _SHA_Init(x) SHA##x##_Init
-#define SHA_Init(x) _SHA_Init(x)
-
-#define _SHA_Update(x) SHA##x##_Update
-#define SHA_Update(x) _SHA_Update(x)
-
-#define _SHA_Final(x) SHA##x##_Final
-#define SHA_Final(x) _SHA_Final(x)
-
-#define _SHA_End(x) SHA##x##_End
-#define SHA_End(x) _SHA_End(x)
-
-#define _SHA_File(x) SHA##x##_File
-#define SHA_File(x) _SHA_File(x)
-
-#define _SHA_FileChunk(x) SHA##x##_FileChunk
-#define SHA_FileChunk(x) _SHA_FileChunk(x)
-
-#define _SHA_Data(x) SHA##x##_Data
-#define SHA_Data(x) _SHA_Data(x)
-
-void test1() {
- SHA_CTX(SHASIZE) ctx;
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
- uint8_t digest[SHA_DIGEST_LENGTH(SHASIZE)];
- size_t entropysz = sizeof(entropy);
- size_t digestsz = sizeof(digest);
-
- SHA_Init(SHASIZE)(&ctx);
- SHA_Update(SHASIZE)(&ctx, entropy, entropysz);
- SHA_Final(SHASIZE)(digest, &ctx);
-
- printf("test1: '");
- for (size_t i = 0; i < digestsz; i++)
- printf("%02x", digest[i]);
- printf("'\n");
-}
-
-void test2() {
- SHA_CTX(SHASIZE) ctx;
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
- char digest[SHA_DIGEST_STRING_LENGTH(SHASIZE)];
- size_t entropysz = sizeof(entropy);
-
- SHA_Init(SHASIZE)(&ctx);
- SHA_Update(SHASIZE)(&ctx, entropy, entropysz);
- char *p = SHA_End(SHASIZE)(&ctx, digest);
- assert(p == digest);
-
- printf("test2: '%s'\n", digest);
-}
-
-void test3() {
- SHA_CTX(SHASIZE) ctx;
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
- size_t entropysz = sizeof(entropy);
-
- SHA_Init(SHASIZE)(&ctx);
- SHA_Update(SHASIZE)(&ctx, entropy, entropysz);
- char *p = SHA_End(SHASIZE)(&ctx, NULL);
- assert(strlen(p) == SHA_DIGEST_STRING_LENGTH(SHASIZE) - 1);
-
- printf("test3: '%s'\n", p);
-
- free(p);
-}
-
-void test4() {
- char digest[SHA_DIGEST_STRING_LENGTH(SHASIZE)];
-
- char *p = SHA_File(SHASIZE)("/etc/fstab", digest);
- assert(p == digest);
-
- printf("test4: '%s'\n", p);
-}
-
-void test5() {
- char *p = SHA_File(SHASIZE)("/etc/fstab", NULL);
- assert(strlen(p) == SHA_DIGEST_STRING_LENGTH(SHASIZE) - 1);
-
- printf("test5: '%s'\n", p);
-
- free(p);
-}
-
-void test6() {
- char digest[SHA_DIGEST_STRING_LENGTH(SHASIZE)];
-
- char *p = SHA_FileChunk(SHASIZE)("/etc/fstab", digest, 10, 20);
- assert(p == digest);
-
- printf("test6: '%s'\n", p);
-}
-
-void test7() {
- char *p = SHA_FileChunk(SHASIZE)("/etc/fstab", NULL, 10, 20);
- assert(strlen(p) == SHA_DIGEST_STRING_LENGTH(SHASIZE) - 1);
-
- printf("test7: '%s'\n", p);
-
- free(p);
-}
-
-void test8() {
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
- char digest[SHA_DIGEST_STRING_LENGTH(SHASIZE)];
- size_t entropysz = sizeof(entropy);
-
- char *p = SHA_Data(SHASIZE)(entropy, entropysz, digest);
- assert(p == digest);
-
- printf("test8: '%s'\n", p);
-}
-
-void test9() {
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
- size_t entropysz = sizeof(entropy);
-
- char *p = SHA_Data(SHASIZE)(entropy, entropysz, NULL);
- assert(strlen(p) == SHA_DIGEST_STRING_LENGTH(SHASIZE) - 1);
-
- printf("test9: '%s'\n", p);
-
- free(p);
-}
-
-int main(void) {
- printf("SHA%d\n", SHASIZE);
-
- test1();
- test2();
- test3();
- test4();
- test5();
- test6();
- test7();
- test8();
- test9();
-
- // CHECK-224: SHA224
- // CHECK-224: test1: '760dfb93100a6bf5996c90f678e529dc945bb2f74a211eedcf0f3a48'
- // CHECK-224: test2: '760dfb93100a6bf5996c90f678e529dc945bb2f74a211eedcf0f3a48'
- // CHECK-224: test3: '760dfb93100a6bf5996c90f678e529dc945bb2f74a211eedcf0f3a48'
- // CHECK-224: test4: '{{.*}}'
- // CHECK-224: test5: '{{.*}}'
- // CHECK-224: test6: '{{.*}}'
- // CHECK-224: test7: '{{.*}}'
- // CHECK-224: test8: '760dfb93100a6bf5996c90f678e529dc945bb2f74a211eedcf0f3a48'
- // CHECK-224: test9: '760dfb93100a6bf5996c90f678e529dc945bb2f74a211eedcf0f3a48'
-
- // CHECK-256: SHA256
- // CHECK-256: test1: 'bb000ddd92a0a2a346f0b531f278af06e370f86932ccafccc892d68d350f80f8'
- // CHECK-256: test2: 'bb000ddd92a0a2a346f0b531f278af06e370f86932ccafccc892d68d350f80f8'
- // CHECK-256: test3: 'bb000ddd92a0a2a346f0b531f278af06e370f86932ccafccc892d68d350f80f8'
- // CHECK-256: test4: '{{.*}}'
- // CHECK-256: test5: '{{.*}}'
- // CHECK-256: test6: '{{.*}}'
- // CHECK-256: test7: '{{.*}}'
- // CHECK-256: test8: 'bb000ddd92a0a2a346f0b531f278af06e370f86932ccafccc892d68d350f80f8'
- // CHECK-256: test9: 'bb000ddd92a0a2a346f0b531f278af06e370f86932ccafccc892d68d350f80f8'
-
- // CHECK-384: SHA384
- // CHECK-384: test1: 'f450c023b168ebd56ff916ca9b1f1f0010b8c592d28205cc91fa3056f629eed108e8bac864f01ca37a3edee596739e12'
- // CHECK-384: test2: 'f450c023b168ebd56ff916ca9b1f1f0010b8c592d28205cc91fa3056f629eed108e8bac864f01ca37a3edee596739e12'
- // CHECK-384: test3: 'f450c023b168ebd56ff916ca9b1f1f0010b8c592d28205cc91fa3056f629eed108e8bac864f01ca37a3edee596739e12'
- // CHECK-384: test4: '{{.*}}'
- // CHECK-384: test5: '{{.*}}'
- // CHECK-384: test6: '{{.*}}'
- // CHECK-384: test7: '{{.*}}'
- // CHECK-384: test8: 'f450c023b168ebd56ff916ca9b1f1f0010b8c592d28205cc91fa3056f629eed108e8bac864f01ca37a3edee596739e12'
- // CHECK-384: test9: 'f450c023b168ebd56ff916ca9b1f1f0010b8c592d28205cc91fa3056f629eed108e8bac864f01ca37a3edee596739e12'
-
- // CHECK-512: SHA512
- // CHECK-512: test1: '0e3f68731c0e2a6a4eab5d713c9a80dc78086b5fa7d2b5ab127277958e68d1b1dee1882b083b0106cd4319de42c0c8f452871364f5baa8a6379690612c6b844e'
- // CHECK-512: test2: '0e3f68731c0e2a6a4eab5d713c9a80dc78086b5fa7d2b5ab127277958e68d1b1dee1882b083b0106cd4319de42c0c8f452871364f5baa8a6379690612c6b844e'
- // CHECK-512: test3: '0e3f68731c0e2a6a4eab5d713c9a80dc78086b5fa7d2b5ab127277958e68d1b1dee1882b083b0106cd4319de42c0c8f452871364f5baa8a6379690612c6b844e'
- // CHECK-512: test4: '{{.*}}'
- // CHECK-512: test5: '{{.*}}'
- // CHECK-512: test6: '{{.*}}'
- // CHECK-512: test7: '{{.*}}'
- // CHECK-512: test8: '0e3f68731c0e2a6a4eab5d713c9a80dc78086b5fa7d2b5ab127277958e68d1b1dee1882b083b0106cd4319de42c0c8f452871364f5baa8a6379690612c6b844e'
- // CHECK-512: test9: '0e3f68731c0e2a6a4eab5d713c9a80dc78086b5fa7d2b5ab127277958e68d1b1dee1882b083b0106cd4319de42c0c8f452871364f5baa8a6379690612c6b844e'
-
- return 0;
-}
diff --git a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/md5.cpp b/compiler-rt/test/sanitizer_common/TestCases/NetBSD/md5.cpp
deleted file mode 100644
index aee21681800d89..00000000000000
--- a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/md5.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
-
-#include <sys/param.h>
-
-#include <assert.h>
-#include <endian.h>
-#include <md5.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-void test1() {
- MD5_CTX ctx;
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
- uint8_t digest[MD5_DIGEST_LENGTH];
-
- MD5Init(&ctx);
- MD5Update(&ctx, entropy, __arraycount(entropy));
- MD5Final(digest, &ctx);
-
- printf("test1: '");
- for (size_t i = 0; i < __arraycount(digest); i++)
- printf("%02x", digest[i]);
- printf("'\n");
-}
-
-void test2() {
- MD5_CTX ctx;
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
- char digest[MD5_DIGEST_STRING_LENGTH];
-
- MD5Init(&ctx);
- MD5Update(&ctx, entropy, __arraycount(entropy));
- char *p = MD5End(&ctx, digest);
- assert(p);
-
- printf("test2: '%s'\n", digest);
-}
-
-void test3() {
- MD5_CTX ctx;
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
-
- MD5Init(&ctx);
- MD5Update(&ctx, entropy, __arraycount(entropy));
- char *p = MD5End(&ctx, NULL);
- assert(strlen(p) == MD5_DIGEST_STRING_LENGTH - 1);
-
- printf("test3: '%s'\n", p);
-
- free(p);
-}
-
-void test4() {
- char digest[MD5_DIGEST_STRING_LENGTH];
-
- char *p = MD5File("/etc/fstab", digest);
- assert(p == digest);
-
- printf("test4: '%s'\n", p);
-}
-
-void test5() {
- char *p = MD5File("/etc/fstab", NULL);
- assert(strlen(p) == MD5_DIGEST_STRING_LENGTH - 1);
-
- printf("test5: '%s'\n", p);
-
- free(p);
-}
-
-void test6() {
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
- char digest[MD5_DIGEST_STRING_LENGTH];
-
- char *p = MD5Data(entropy, __arraycount(entropy), digest);
- assert(p == digest);
-
- printf("test6: '%s'\n", p);
-}
-
-void test7() {
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
-
- char *p = MD5Data(entropy, __arraycount(entropy), NULL);
- assert(strlen(p) == MD5_DIGEST_STRING_LENGTH - 1);
-
- printf("test7: '%s'\n", p);
-
- free(p);
-}
-
-int main(void) {
- printf("MD5\n");
-
- test1();
- test2();
- test3();
- test4();
- test5();
- test6();
- test7();
-
- // CHECK: MD5
- // CHECK: test1: '86e65b1ef4a830af347ac05ab4f0e999'
- // CHECK: test2: '86e65b1ef4a830af347ac05ab4f0e999'
- // CHECK: test3: '86e65b1ef4a830af347ac05ab4f0e999'
- // CHECK: test4: '{{.*}}'
- // CHECK: test5: '{{.*}}'
- // CHECK: test6: '86e65b1ef4a830af347ac05ab4f0e999'
- // CHECK: test7: '86e65b1ef4a830af347ac05ab4f0e999'
-
- return 0;
-}
diff --git a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/sha2.cpp b/compiler-rt/test/sanitizer_common/TestCases/NetBSD/sha2.cpp
deleted file mode 100644
index e905e3b610fd37..00000000000000
--- a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/sha2.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-// RUN: %clangxx -O0 -g %s -DSHASIZE=224 -o %t && %run %t 2>&1 | FileCheck %s -check-prefix=CHECK-224
-// RUN: %clangxx -O0 -g %s -DSHASIZE=256 -o %t && %run %t 2>&1 | FileCheck %s -check-prefix=CHECK-256
-// RUN: %clangxx -O0 -g %s -DSHASIZE=384 -o %t && %run %t 2>&1 | FileCheck %s -check-prefix=CHECK-384
-// RUN: %clangxx -O0 -g %s -DSHASIZE=512 -o %t && %run %t 2>&1 | FileCheck %s -check-prefix=CHECK-512
-
-#include <sys/param.h>
-
-#include <assert.h>
-#include <endian.h>
-#include <sha2.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef SHASIZE
-#error SHASIZE must be defined
-#endif
-
-#define _SHA_CTX(x) SHA##x##_CTX
-#define SHA_CTX(x) _SHA_CTX(x)
-
-#define _SHA_DIGEST_LENGTH(x) SHA##x##_DIGEST_LENGTH
-#define SHA_DIGEST_LENGTH(x) _SHA_DIGEST_LENGTH(x)
-
-#define _SHA_DIGEST_STRING_LENGTH(x) SHA##x##_DIGEST_STRING_LENGTH
-#define SHA_DIGEST_STRING_LENGTH(x) _SHA_DIGEST_STRING_LENGTH(x)
-
-#define _SHA_Init(x) SHA##x##_Init
-#define SHA_Init(x) _SHA_Init(x)
-
-#define _SHA_Update(x) SHA##x##_Update
-#define SHA_Update(x) _SHA_Update(x)
-
-#define _SHA_Final(x) SHA##x##_Final
-#define SHA_Final(x) _SHA_Final(x)
-
-#define _SHA_End(x) SHA##x##_End
-#define SHA_End(x) _SHA_End(x)
-
-#define _SHA_File(x) SHA##x##_File
-#define SHA_File(x) _SHA_File(x)
-
-#define _SHA_FileChunk(x) SHA##x##_FileChunk
-#define SHA_FileChunk(x) _SHA_FileChunk(x)
-
-#define _SHA_Data(x) SHA##x##_Data
-#define SHA_Data(x) _SHA_Data(x)
-
-void test1() {
- SHA_CTX(SHASIZE) ctx;
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
- uint8_t digest[SHA_DIGEST_LENGTH(SHASIZE)];
-
- SHA_Init(SHASIZE)(&ctx);
- SHA_Update(SHASIZE)(&ctx, entropy, __arraycount(entropy));
- SHA_Final(SHASIZE)(digest, &ctx);
-
- printf("test1: '");
- for (size_t i = 0; i < __arraycount(digest); i++)
- printf("%02x", digest[i]);
- printf("'\n");
-}
-
-void test2() {
- SHA_CTX(SHASIZE) ctx;
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
- char digest[SHA_DIGEST_STRING_LENGTH(SHASIZE)];
-
- SHA_Init(SHASIZE)(&ctx);
- SHA_Update(SHASIZE)(&ctx, entropy, __arraycount(entropy));
- char *p = SHA_End(SHASIZE)(&ctx, digest);
- assert(p == digest);
-
- printf("test2: '%s'\n", digest);
-}
-
-void test3() {
- SHA_CTX(SHASIZE) ctx;
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
-
- SHA_Init(SHASIZE)(&ctx);
- SHA_Update(SHASIZE)(&ctx, entropy, __arraycount(entropy));
- char *p = SHA_End(SHASIZE)(&ctx, NULL);
- assert(strlen(p) == SHA_DIGEST_STRING_LENGTH(SHASIZE) - 1);
-
- printf("test3: '%s'\n", p);
-
- free(p);
-}
-
-void test4() {
- char digest[SHA_DIGEST_STRING_LENGTH(SHASIZE)];
-
- char *p = SHA_File(SHASIZE)("/etc/fstab", digest);
- assert(p == digest);
-
- printf("test4: '%s'\n", p);
-}
-
-void test5() {
- char *p = SHA_File(SHASIZE)("/etc/fstab", NULL);
- assert(strlen(p) == SHA_DIGEST_STRING_LENGTH(SHASIZE) - 1);
-
- printf("test5: '%s'\n", p);
-
- free(p);
-}
-
-void test6() {
- char digest[SHA_DIGEST_STRING_LENGTH(SHASIZE)];
-
- char *p = SHA_FileChunk(SHASIZE)("/etc/fstab", digest, 10, 20);
- assert(p == digest);
-
- printf("test6: '%s'\n", p);
-}
-
-void test7() {
- char *p = SHA_FileChunk(SHASIZE)("/etc/fstab", NULL, 10, 20);
- assert(strlen(p) == SHA_DIGEST_STRING_LENGTH(SHASIZE) - 1);
-
- printf("test7: '%s'\n", p);
-
- free(p);
-}
-
-void test8() {
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
- char digest[SHA_DIGEST_STRING_LENGTH(SHASIZE)];
-
- char *p = SHA_Data(SHASIZE)(entropy, __arraycount(entropy), digest);
- assert(p == digest);
-
- printf("test8: '%s'\n", p);
-}
-
-void test9() {
- uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
-
- char *p = SHA_Data(SHASIZE)(entropy, __arraycount(entropy), NULL);
- assert(strlen(p) == SHA_DIGEST_STRING_LENGTH(SHASIZE) - 1);
-
- printf("test9: '%s'\n", p);
-
- free(p);
-}
-
-int main(void) {
- printf("SHA" ___STRING(SHASIZE) "\n");
-
- test1();
- test2();
- test3();
- test4();
- test5();
- test6();
- test7();
- test8();
- test9();
-
- // CHECK-224: SHA224
- // CHECK-224: test1: '760dfb93100a6bf5996c90f678e529dc945bb2f74a211eedcf0f3a48'
- // CHECK-224: test2: '760dfb93100a6bf5996c90f678e529dc945bb2f74a211eedcf0f3a48'
- // CHECK-224: test3: '760dfb93100a6bf5996c90f678e529dc945bb2f74a211eedcf0f3a48'
- // CHECK-224: test4: '{{.*}}'
- // CHECK-224: test5: '{{.*}}'
- // CHECK-224: test6: '{{.*}}'
- // CHECK-224: test7: '{{.*}}'
- // CHECK-224: test8: '760dfb93100a6bf5996c90f678e529dc945bb2f74a211eedcf0f3a48'
- // CHECK-224: test9: '760dfb93100a6bf5996c90f678e529dc945bb2f74a211eedcf0f3a48'
-
- // CHECK-256: SHA256
- // CHECK-256: test1: 'bb000ddd92a0a2a346f0b531f278af06e370f86932ccafccc892d68d350f80f8'
- // CHECK-256: test2: 'bb000ddd92a0a2a346f0b531f278af06e370f86932ccafccc892d68d350f80f8'
- // CHECK-256: test3: 'bb000ddd92a0a2a346f0b531f278af06e370f86932ccafccc892d68d350f80f8'
- // CHECK-256: test4: '{{.*}}'
- // CHECK-256: test5: '{{.*}}'
- // CHECK-256: test6: '{{.*}}'
- // CHECK-256: test7: '{{.*}}'
- // CHECK-256: test8: 'bb000ddd92a0a2a346f0b531f278af06e370f86932ccafccc892d68d350f80f8'
- // CHECK-256: test9: 'bb000ddd92a0a2a346f0b531f278af06e370f86932ccafccc892d68d350f80f8'
-
- // CHECK-384: SHA384
- // CHECK-384: test1: 'f450c023b168ebd56ff916ca9b1f1f0010b8c592d28205cc91fa3056f629eed108e8bac864f01ca37a3edee596739e12'
- // CHECK-384: test2: 'f450c023b168ebd56ff916ca9b1f1f0010b8c592d28205cc91fa3056f629eed108e8bac864f01ca37a3edee596739e12'
- // CHECK-384: test3: 'f450c023b168ebd56ff916ca9b1f1f0010b8c592d28205cc91fa3056f629eed108e8bac864f01ca37a3edee596739e12'
- // CHECK-384: test4: '{{.*}}'
- // CHECK-384: test5: '{{.*}}'
- // CHECK-384: test6: '{{.*}}'
- // CHECK-384: test7: '{{.*}}'
- // CHECK-384: test8: 'f450c023b168ebd56ff916ca9b1f1f0010b8c592d28205cc91fa3056f629eed108e8bac864f01ca37a3edee596739e12'
- // CHECK-384: test9: 'f450c023b168ebd56ff916ca9b1f1f0010b8c592d28205cc91fa3056f629eed108e8bac864f01ca37a3edee596739e12'
-
- // CHECK-512: SHA512
- // CHECK-512: test1: '0e3f68731c0e2a6a4eab5d713c9a80dc78086b5fa7d2b5ab127277958e68d1b1dee1882b083b0106cd4319de42c0c8f452871364f5baa8a6379690612c6b844e'
- // CHECK-512: test2: '0e3f68731c0e2a6a4eab5d713c9a80dc78086b5fa7d2b5ab127277958e68d1b1dee1882b083b0106cd4319de42c0c8f452871364f5baa8a6379690612c6b844e'
- // CHECK-512: test3: '0e3f68731c0e2a6a4eab5d713c9a80dc78086b5fa7d2b5ab127277958e68d1b1dee1882b083b0106cd4319de42c0c8f452871364f5baa8a6379690612c6b844e'
- // CHECK-512: test4: '{{.*}}'
- // CHECK-512: test5: '{{.*}}'
- // CHECK-512: test6: '{{.*}}'
- // CHECK-512: test7: '{{.*}}'
- // CHECK-512: test8: '0e3f68731c0e2a6a4eab5d713c9a80dc78086b5fa7d2b5ab127277958e68d1b1dee1882b083b0106cd4319de42c0c8f452871364f5baa8a6379690612c6b844e'
- // CHECK-512: test9: '0e3f68731c0e2a6a4eab5d713c9a80dc78086b5fa7d2b5ab127277958e68d1b1dee1882b083b0106cd4319de42c0c8f452871364f5baa8a6379690612c6b844e'
-
- return 0;
-}
More information about the llvm-branch-commits
mailing list