1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-19 10:05:05 -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 GitHub
parent 81dcedf501
commit 890905f946
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 58 additions and 36 deletions

View File

@ -268,6 +268,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

@ -623,6 +623,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

@ -268,6 +268,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

@ -623,6 +623,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

@ -268,6 +268,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

@ -623,6 +623,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

@ -268,6 +268,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

@ -623,6 +623,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

@ -268,6 +268,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

@ -623,6 +623,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

@ -292,6 +292,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

@ -623,6 +623,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

@ -221,6 +221,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

@ -623,6 +623,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

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

View File

@ -516,6 +516,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

@ -614,6 +614,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

@ -94,6 +94,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

@ -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

@ -9,24 +9,6 @@
#include "ladder.S"
#if defined(__linux__) && defined(__ELF__)
#if defined(__CET__)
.section .note.gnu.property,"a"
.p2align 3
.long 1f - 0f
.long 4f - 1f
.long 5
0:
.string "GNU"
1:
.p2align 3
.long 0xc0000002
.long 3f - 2f
2:
.long __CET__
3:
.p2align 3
4:
#endif
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -1,5 +1,6 @@
#ifdef HAVE_AMD64_ASM
#include "private/asm_cet.h"
#include "salsa20_xmm6-asm_namespace.h"
.text
@ -17,6 +18,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
@ -58,6 +61,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
@ -958,23 +962,5 @@ jmp ._bytesbetween1and255
#endif
#if defined(__linux__) && defined(__ELF__)
#if defined(__CET__)
.section .note.gnu.property,"a"
.p2align 3
.long 1f - 0f
.long 4f - 1f
.long 5
0:
.string "GNU"
1:
.p2align 3
.long 0xc0000002
.long 3f - 2f
2:
.long __CET__
3:
.p2align 3
4:
#endif
.section .note.GNU-stack,"",%progbits
#endif

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