mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-25 08:37:13 +09:00
Add crypto_aead_aes256gcm_aesni_is_available()
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "crypto_aead_aes256gcm_aesni.h"
|
||||
#include "export.h"
|
||||
#include "runtime.h"
|
||||
#include "utils.h"
|
||||
|
||||
#if defined(HAVE_WMMINTRIN_H) || \
|
||||
@@ -798,6 +799,12 @@ crypto_aead_aes256gcm_aesni_decrypt(unsigned char *m,
|
||||
(m, mlen_p, nsec, c, clen, ad, adlen, npub, &ctx);
|
||||
}
|
||||
|
||||
int
|
||||
crypto_aead_aes256gcm_aesni_is_available(void)
|
||||
{
|
||||
return sodium_runtime_has_pclmul() & sodium_runtime_has_aesni();
|
||||
}
|
||||
|
||||
size_t
|
||||
crypto_aead_aes256gcm_keybytes(void)
|
||||
{
|
||||
@@ -828,4 +835,12 @@ crypto_aead_aes256gcm_statebytes(void)
|
||||
return sizeof(crypto_aead_aes256gcm_state);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int
|
||||
crypto_aead_aes256gcm_aesni_is_available(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_aesni_is_available(void);
|
||||
|
||||
#define crypto_aead_aes256gcm_KEYBYTES 32U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_aead_aes256gcm_keybytes(void);
|
||||
|
||||
@@ -3095,7 +3095,7 @@ tv(void)
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
if (sodium_runtime_has_aesni() && sodium_runtime_has_pclmul()) {
|
||||
if (crypto_aead_aes256gcm_aesni_is_available()) {
|
||||
tv();
|
||||
}
|
||||
printf("OK\n");
|
||||
|
||||
Reference in New Issue
Block a user