= arc4random 呼び出しの流れ
OpenSSL を切ってよければ arc4random.c/h と chacha.c/h を削除してもいいはず、と思ったので、どう呼び出しているか追いかけてみるテスト
== LibreSSL
arc4random.c/h あり
{{{
RAND_bytes() -> libressl/crypto/rand/rand_lib.c RAND_bytes()
arc4random_buf() -> ttxssh/arc4random.c arc4random_buf()
_rs_random_buf() -> ttxssh/arc4random.c _rs_random_buf()
_rs_stir_if_needed() -> ttxssh/arc4random.c _rs_stir_if_needed()
_rs_stir() -> ttxssh/arc4random.c _rs_stir()
getentropy() -> ttxssh/arc4random.c getentropy()
※ここが RAND_bytes() だと無限ループになる
}}}
{{{
randombytes() -> ttxssh/ed25519_crypto_api.h arc4random_buf()
arc4random_buf() -> ttxssh/arc4random.c arc4random_buf()
以下同じ
}}}
{{{
arc4random() -> ttxssh/arc4random.c arc4random()
_rs_random_u32() -> ttxssh/arc4random.c _rs_random_u32()
_rs_stir_if_needed() -> ttxssh/arc4random.c _rs_stir_if_needed()
以下同じ
}}}
== LibreSSL
arc4random.c/h をプロジェクトから削除、ファイルはそのまま、#include はそのまま(include は自前で本体はライブラリまかせる・ちぐはぐ)
{{{
RAND_bytes() -> libressl/crypto/rand/rand_lib.c RAND_bytes()
arc4random_buf() -> libressl/crypto/compat/arc4random.c arc4random_buf()
_rs_random_buf() -> libressl/crypto/compat/arc4random.c _rs_random_buf()
_rs_stir_if_needed() -> libressl/crypto/compat/arc4random.c _rs_stir_if_needed()
_rs_stir() -> libressl/crypto/compat/arc4random.c _rs_stir()
getentropy() -> libressl/crypto/compat/getentropy_win.c getentropy()
}}}
{{{
randombytes() -> ttxssh/ed25519_crypto_api.h arc4random_buf()
arc4random_buf() -> libressl/crypto/compat/arc4random.c _rs_random_buf()
以下同じ
}}}
{{{
arc4random() -> libressl/crypto/compat/arc4random.c arc4random()
_rs_random_u32() -> libressl/crypto/compat/arc4random.c _rs_random_u32()
_rs_stir_if_needed() -> libressl/crypto/compat/arc4random.c _rs_stir_if_needed()
以下同じ
}}}
== LibreSSL
arc4random.c/h をプロジェクトから削除、#include を変更(ファイル削除と同等)(すべてライブラリまかせ)
#include <compat/stdlib.h> に変更
{{{
RAND_bytes() -> libressl/crypto/rand/rand_lib.c RAND_bytes()
arc4random_buf() -> libressl/crypto/compat/arc4random.c arc4random_buf()
_rs_random_buf() -> libressl/crypto/compat/arc4random.c _rs_random_buf()
_rs_stir_if_needed() -> libressl/crypto/compat/arc4random.c _rs_stir_if_needed()
_rs_stir() -> libressl/crypto/compat/arc4random.c _rs_stir()
getentropy() -> libressl/crypto/compat/getentropy_win.c getentropy()
}}}
{{{
randombytes() -> ttxssh/ed25519_crypto_api.h arc4random_buf()
arc4random_buf() -> libressl/crypto/compat/arc4random.c _rs_random_buf()
以下同じ
}}}
{{{
arc4random() -> libressl/crypto/compat/arc4random.c arc4random()
_rs_random_u32() -> libressl/crypto/compat/arc4random.c _rs_random_u32()
_rs_stir_if_needed() -> libressl/crypto/compat/arc4random.c _rs_stir_if_needed()
以下同じ
}}}
== OpenSSL
arc4random.c/h あり
{{{
RAND_bytes -> openssl/crypto/rand/rand_lib.c RAND_bytes()
RAND_bytes_ex() -> openssl/crypto/rand/rand_lib.c RAND_bytes_ex()
EVP_RAND_generate() -> openssl/crypto/evp/evp_rand.c EVP_RAND_generate()
}}}
{{{
arc4random_buf() -> ttxssh/arc4random.c arc4random_buf()
_rs_random_buf() -> _rs_random_buf()
_rs_stir_if_needed() -> ttxssh/arc4random.c _rs_stir_if_needed()
_rs_stir() -> ttxssh/arc4random.c _rs_stir()
RAND_bytes() -> openssl/crypto/rand/rand_lib.c RAND_bytes()
以下同じ
}}}
{{{
arc4random() -> ttxssh/arc4random.c arc4random()
_rs_random_u32() -> ttxssh/arc4random.c _rs_random_u32()
_rs_stir_if_needed() -> ttxssh/arc4random.c _rs_stir_if_needed()
以下同じ
}}}
= libressl
{{{
libressl\crypto\rand\rand_lib.c(87): RAND_bytes(unsigned char *buf, int num)
libressl\include\openssl\rand.h(93): int RAND_bytes(unsigned char *buf, int num);
libressl\crypto\compat\getentropy_win.c(29): int getentropy(void *buf, size_t len);
libressl\include\compat\unistd.h(57): int getentropy(void *buf, size_t buflen);
libressl\crypto\compat\arc4random.c(86): _rs_stir(void)
libressl\crypto\compat\arc4random.c(180): arc4random(void)
libressl\crypto\compat\arc4random.c(191): arc4random_buf(void *buf, size_t n)
libressl\include\compat\stdlib.h(23): uint32_t arc4random(void);
libressl\include\compat\stdlib.h(24): void arc4random_buf(void *_buf, size_t n);
}}}