Compiled libgcrypt 1.7.8 with bleading edge clang-5 ( 5.0.0 (trunk 305735)) and UBSan on Ubuntu 16.04 x64. Used the following flags:
-O2 -fno-omit-frame-pointer -g -fsanitize=address -fsanitize=undefined -fsanitize=integer -fsanitize-coverage=trace-pc-guard -fno-sanitize-recover=undefined -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize-undefined-trap-on-error -fno-sanitize-recover=all
Ran the following test:
libgcrypt-1.7.8/tests/dsa-rfc6979
Illegal instruction
Program received signal SIGILL, Illegal instruction. 0x00000000005415fb in prepare_macpads (a=<optimized out>, key=<optimized out>, keylen=<optimized out>) at md.c:681 681 if (!a->ctx->list) (gdb) bt #0 0x00000000005415fb in prepare_macpads (a=<optimized out>, key=<optimized out>, keylen=<optimized out>) at md.c:681 #1 _gcry_md_setkey (hd=0x616000000680, key=0x603000000490, keylen=20) at md.c:797 #2 0x000000000068f636 in _gcry_dsa_gen_rfc6979_k (r_k=0x7fffffffd6c0, dsa_q=0x603000000250, dsa_x=0x6030000000a0, h1=0xffffffffa94 "", hlen=20, halgo=2, extraloops=2147448832) at dsa-common.c:234 #3 0x000000000051c97f in sign (r=0x6030000003a0, s=0x6030000003d0, input=0x6030000001c0, skey=0x7fffffffd8a0, flags=-10072, hashalgo=2) at dsa.c:627 #4 0x000000000051adbc in dsa_sign (r_sig=<optimized out>, s_data=<optimized out>, keyparms=<optimized out>) at dsa.c:1061 #5 0x0000000000558b83 in _gcry_pk_sign (r_sig=0x7fffffffdb40, s_hash=0x60b000000040, s_skey=<optimized out>) at pubkey.c:430 #6 0x00000000004e849e in gcry_pk_sign (result=0x7fffffffdb40, data=0x60b000000040, skey=0x619000000080) at visibility.c:996 #7 0x00000000004e4a04 in check_dsa_rfc6979 () at dsa-rfc6979.c:984 #8 main (argc=<optimized out>, argv=<optimized out>) at dsa-rfc6979.c:1027
libgcrypt-1.7.8/tests/hmac also crashes in a similar fashion:
Program received signal SIGILL, Illegal instruction. 0x00000000005413eb in prepare_macpads (a=<optimized out>, key=<optimized out>, keylen=<optimized out>) at md.c:681 681 if (!a->ctx->list) (gdb) bt #0 0x00000000005413eb in prepare_macpads (a=<optimized out>, key=<optimized out>, keylen=<optimized out>) at md.c:681 #1 _gcry_md_setkey (hd=0x619000000080, key=0x7fffffffdb80, keylen=64) at md.c:797 #2 0x00000000004e8dfe in gcry_md_setkey (hd=0x619000000080, key=0x7fffffffdb80, keylen=64) at visibility.c:1275 #3 0x00000000004e5484 in check_one_mac (algo=2, key=<optimized out>, keylen=<optimized out>, data=<optimized out>, datalen=9, expect=<optimized out>) at hmac.c:84 #4 0x00000000004e4875 in check_hmac () at hmac.c:121 #5 main (argc=<optimized out>, argv=<optimized out>) at hmac.c:225