1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-19 18:15:18 -07:00

Add proper CET support (followup to #1290) (#1291)

This commit is contained in:
Frank Denis 2023-07-19 18:27:36 +02:00 committed by Frank Denis
parent f3bd149feb
commit 4f099fc593
26 changed files with 68 additions and 2 deletions

View File

@ -260,6 +260,7 @@
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\ed25519_ref10_fe_25_5.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\ed25519_ref10_fe_51.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\sse2_64_32.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\asm_cet.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\common.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\mutex.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\chacha20_ietf_ext.h" />

View File

@ -569,6 +569,9 @@
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\sse2_64_32.h">
<Filter>include\sodium\private</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\asm_cet.h">
<Filter>include\sodium\private</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\common.h">
<Filter>include\sodium\private</Filter>
</ClInclude>

View File

@ -260,6 +260,7 @@
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\ed25519_ref10_fe_25_5.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\ed25519_ref10_fe_51.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\sse2_64_32.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\asm_cet.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\common.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\mutex.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\chacha20_ietf_ext.h" />

View File

@ -569,6 +569,9 @@
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\sse2_64_32.h">
<Filter>include\sodium\private</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\asm_cet.h">
<Filter>include\sodium\private</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\common.h">
<Filter>include\sodium\private</Filter>
</ClInclude>

View File

@ -260,6 +260,7 @@
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\ed25519_ref10_fe_25_5.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\ed25519_ref10_fe_51.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\sse2_64_32.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\asm_cet.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\common.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\mutex.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\chacha20_ietf_ext.h" />

View File

@ -569,6 +569,9 @@
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\sse2_64_32.h">
<Filter>include\sodium\private</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\asm_cet.h">
<Filter>include\sodium\private</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\common.h">
<Filter>include\sodium\private</Filter>
</ClInclude>

View File

@ -260,6 +260,7 @@
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\ed25519_ref10_fe_25_5.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\ed25519_ref10_fe_51.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\sse2_64_32.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\asm_cet.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\common.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\mutex.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\chacha20_ietf_ext.h" />

View File

@ -569,6 +569,9 @@
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\sse2_64_32.h">
<Filter>include\sodium\private</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\asm_cet.h">
<Filter>include\sodium\private</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\common.h">
<Filter>include\sodium\private</Filter>
</ClInclude>

View File

@ -260,6 +260,7 @@
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\ed25519_ref10_fe_25_5.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\ed25519_ref10_fe_51.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\sse2_64_32.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\asm_cet.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\common.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\mutex.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\chacha20_ietf_ext.h" />

View File

@ -569,6 +569,9 @@
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\sse2_64_32.h">
<Filter>include\sodium\private</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\asm_cet.h">
<Filter>include\sodium\private</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\common.h">
<Filter>include\sodium\private</Filter>
</ClInclude>

View File

@ -260,6 +260,7 @@
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\ed25519_ref10_fe_25_5.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\ed25519_ref10_fe_51.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\sse2_64_32.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\asm_cet.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\common.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\mutex.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\chacha20_ietf_ext.h" />

View File

@ -569,6 +569,9 @@
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\sse2_64_32.h">
<Filter>include\sodium\private</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\asm_cet.h">
<Filter>include\sodium\private</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\common.h">
<Filter>include\sodium\private</Filter>
</ClInclude>

View File

@ -260,6 +260,7 @@
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\ed25519_ref10_fe_25_5.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\ed25519_ref10_fe_51.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\sse2_64_32.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\asm_cet.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\common.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\mutex.h" />
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\chacha20_ietf_ext.h" />

View File

@ -569,6 +569,9 @@
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\sse2_64_32.h">
<Filter>include\sodium\private</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\asm_cet.h">
<Filter>include\sodium\private</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\src\libsodium\include\sodium\private\common.h">
<Filter>include\sodium\private</Filter>
</ClInclude>

7
configure vendored
View File

@ -19767,6 +19767,13 @@ then :
fi
ac_fn_c_check_header_compile "$LINENO" "cet.h" "ac_cv_header_cet_h" "$ac_includes_default"
if test "x$ac_cv_header_cet_h" = xyes
then :
printf "%s\n" "#define HAVE_CET_H 1" >>confdefs.h
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if _xgetbv() is available" >&5
printf %s "checking if _xgetbv() is available... " >&6; }

View File

@ -585,6 +585,7 @@ AC_SUBST(CFLAGS_PCLMUL)
AC_SUBST(CFLAGS_RDRAND)
AC_CHECK_HEADERS([sys/mman.h sys/param.h sys/random.h intrin.h])
AC_CHECK_HEADERS([cet.h])
AC_MSG_CHECKING([if _xgetbv() is available])
AC_LINK_IFELSE(

View File

@ -498,6 +498,7 @@
<ClInclude Include="src\libsodium\include\sodium\private\ed25519_ref10_fe_25_5.h" />
<ClInclude Include="src\libsodium\include\sodium\private\ed25519_ref10_fe_51.h" />
<ClInclude Include="src\libsodium\include\sodium\private\sse2_64_32.h" />
<ClInclude Include="src\libsodium\include\sodium\private\asm_cet.h" />
<ClInclude Include="src\libsodium\include\sodium\private\common.h" />
<ClInclude Include="src\libsodium\include\sodium\private\mutex.h" />
<ClInclude Include="src\libsodium\include\sodium\private\chacha20_ietf_ext.h" />

View File

@ -560,6 +560,9 @@
<ClInclude Include="src\libsodium\include\sodium\private\sse2_64_32.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\libsodium\include\sodium\private\asm_cet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\libsodium\include\sodium\private\common.h">
<Filter>Header Files</Filter>
</ClInclude>

View File

@ -82,6 +82,7 @@ libsodium_la_SOURCES = \
crypto_stream/salsa20/stream_salsa20.h \
crypto_stream/xsalsa20/stream_xsalsa20.c \
crypto_verify/sodium/verify.c \
include/sodium/private/asm_cet.h \
include/sodium/private/chacha20_ietf_ext.h \
include/sodium/private/common.h \
include/sodium/private/ed25519_ref10.h \

View File

@ -326,7 +326,7 @@ am__libsodium_la_SOURCES_DIST = \
crypto_stream/salsa20/stream_salsa20.c \
crypto_stream/salsa20/stream_salsa20.h \
crypto_stream/xsalsa20/stream_xsalsa20.c \
crypto_verify/sodium/verify.c \
crypto_verify/sodium/verify.c include/sodium/private/asm_cet.h \
include/sodium/private/chacha20_ietf_ext.h \
include/sodium/private/common.h \
include/sodium/private/ed25519_ref10.h \
@ -990,7 +990,7 @@ libsodium_la_SOURCES = \
crypto_stream/salsa20/stream_salsa20.c \
crypto_stream/salsa20/stream_salsa20.h \
crypto_stream/xsalsa20/stream_xsalsa20.c \
crypto_verify/sodium/verify.c \
crypto_verify/sodium/verify.c include/sodium/private/asm_cet.h \
include/sodium/private/chacha20_ietf_ext.h \
include/sodium/private/common.h \
include/sodium/private/ed25519_ref10.h \

View File

@ -3,6 +3,7 @@
/*
This file is basically amd64-51/fe25519_mul.s.
*/
#include "private/asm_cet.h"
#include "fe51_namespace.h"
#include "consts_namespace.h"
.text
@ -19,6 +20,8 @@ ASM_HIDE_SYMBOL _fe51_mul
#endif
fe51_mul:
_fe51_mul:
_CET_ENDBR
mov %rsp,%r11
and $31,%r11
add $96,%r11

View File

@ -4,6 +4,7 @@
This file is adapted from amd64-51/fe25519_square.s:
Adding loop to perform n squares.
*/
#include "private/asm_cet.h"
#include "fe51_namespace.h"
#include "consts_namespace.h"
.p2align 5
@ -21,6 +22,7 @@ ASM_HIDE_SYMBOL _fe51_nsquare
fe51_nsquare:
_fe51_nsquare:
_CET_ENDBR
mov %rsp,%r11
and $31,%r11
add $64,%r11

View File

@ -4,6 +4,7 @@
This file is the result of merging
amd64-51/fe25519_pack.c and amd64-51/fe25519_freeze.s.
*/
#include "private/asm_cet.h"
#include "fe51_namespace.h"
#include "consts_namespace.h"
.p2align 5
@ -21,6 +22,7 @@ ASM_HIDE_SYMBOL _fe51_pack
fe51_pack:
_fe51_pack:
_CET_ENDBR
mov %rsp,%r11
and $31,%r11
add $32,%r11

View File

@ -1,5 +1,6 @@
#ifdef IN_SANDY2X
#include "private/asm_cet.h"
#include "ladder_namespace.h"
#include "consts_namespace.h"
.p2align 5
@ -17,6 +18,7 @@ ASM_HIDE_SYMBOL _ladder
ladder:
_ladder:
_CET_ENDBR
mov %rsp,%r11
and $31,%r11
add $1856,%r11

View File

@ -1,5 +1,7 @@
#ifdef HAVE_AMD64_ASM
#include "private/asm_cet.h"
.text
.p2align 5
@ -15,6 +17,8 @@ ASM_HIDE_SYMBOL _stream_salsa20_xmm6
#endif
stream_salsa20_xmm6:
_stream_salsa20_xmm6:
_CET_ENDBR
mov %rsp,%r11
and $31,%r11
add $512,%r11
@ -56,6 +60,7 @@ ASM_HIDE_SYMBOL _stream_salsa20_xmm6_xor_ic
stream_salsa20_xmm6_xor_ic:
_stream_salsa20_xmm6_xor_ic:
_CET_ENDBR
mov %rsp,%r11
and $31,%r11
add $512,%r11

View File

@ -0,0 +1,11 @@
#ifndef asm_cet_H
#define asm_cet_H 1
#if HAVE_CET_H
# include <cet.h>
#endif
#ifndef _CET_ENDBR
# define _CET_ENDBR
#endif
#endif