scalarmult: check that the top bit is ignored
This commit is contained in:
parent
595e98a224
commit
b062a555da
1
.gitignore
vendored
1
.gitignore
vendored
@ -93,6 +93,7 @@ test/default/scalarmult
|
|||||||
test/default/scalarmult2
|
test/default/scalarmult2
|
||||||
test/default/scalarmult5
|
test/default/scalarmult5
|
||||||
test/default/scalarmult6
|
test/default/scalarmult6
|
||||||
|
test/default/scalarmult7
|
||||||
test/default/secretbox
|
test/default/secretbox
|
||||||
test/default/secretbox2
|
test/default/secretbox2
|
||||||
test/default/secretbox7
|
test/default/secretbox7
|
||||||
|
@ -157,6 +157,9 @@
|
|||||||
<ClCompile Include="..\..\..\..\test\default\scalarmult6.c">
|
<ClCompile Include="..\..\..\..\test\default\scalarmult6.c">
|
||||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\..\test\default\scalarmult7.c">
|
||||||
|
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\..\..\test\default\secretbox.c">
|
<ClCompile Include="..\..\..\..\test\default\secretbox.c">
|
||||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -91,6 +91,9 @@
|
|||||||
<ClCompile Include="..\..\..\..\test\default\scalarmult6.c">
|
<ClCompile Include="..\..\..\..\test\default\scalarmult6.c">
|
||||||
<Filter>src</Filter>
|
<Filter>src</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\..\test\default\scalarmult7.c">
|
||||||
|
<Filter>src</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\..\..\test\default\secretbox.c">
|
<ClCompile Include="..\..\..\..\test\default\secretbox.c">
|
||||||
<Filter>src</Filter>
|
<Filter>src</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -157,6 +157,9 @@
|
|||||||
<ClCompile Include="..\..\..\..\test\default\scalarmult6.c">
|
<ClCompile Include="..\..\..\..\test\default\scalarmult6.c">
|
||||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\..\test\default\scalarmult7.c">
|
||||||
|
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\..\..\test\default\secretbox.c">
|
<ClCompile Include="..\..\..\..\test\default\secretbox.c">
|
||||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -91,6 +91,9 @@
|
|||||||
<ClCompile Include="..\..\..\..\test\default\scalarmult6.c">
|
<ClCompile Include="..\..\..\..\test\default\scalarmult6.c">
|
||||||
<Filter>src</Filter>
|
<Filter>src</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\..\test\default\scalarmult7.c">
|
||||||
|
<Filter>src</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\..\..\test\default\secretbox.c">
|
<ClCompile Include="..\..\..\..\test\default\secretbox.c">
|
||||||
<Filter>src</Filter>
|
<Filter>src</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -157,6 +157,9 @@
|
|||||||
<ClCompile Include="..\..\..\..\test\default\scalarmult6.c">
|
<ClCompile Include="..\..\..\..\test\default\scalarmult6.c">
|
||||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\..\test\default\scalarmult7.c">
|
||||||
|
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\..\..\test\default\secretbox.c">
|
<ClCompile Include="..\..\..\..\test\default\secretbox.c">
|
||||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -91,6 +91,9 @@
|
|||||||
<ClCompile Include="..\..\..\..\test\default\scalarmult6.c">
|
<ClCompile Include="..\..\..\..\test\default\scalarmult6.c">
|
||||||
<Filter>src</Filter>
|
<Filter>src</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\..\test\default\scalarmult7.c">
|
||||||
|
<Filter>src</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\..\..\test\default\secretbox.c">
|
<ClCompile Include="..\..\..\..\test\default\secretbox.c">
|
||||||
<Filter>src</Filter>
|
<Filter>src</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -40,6 +40,7 @@ EXTRA_DIST = \
|
|||||||
scalarmult2.exp \
|
scalarmult2.exp \
|
||||||
scalarmult5.exp \
|
scalarmult5.exp \
|
||||||
scalarmult6.exp \
|
scalarmult6.exp \
|
||||||
|
scalarmult7.exp \
|
||||||
secretbox.exp \
|
secretbox.exp \
|
||||||
secretbox2.exp \
|
secretbox2.exp \
|
||||||
secretbox7.exp \
|
secretbox7.exp \
|
||||||
@ -98,6 +99,7 @@ DISTCLEANFILES = \
|
|||||||
scalarmult2.res \
|
scalarmult2.res \
|
||||||
scalarmult5.res \
|
scalarmult5.res \
|
||||||
scalarmult6.res \
|
scalarmult6.res \
|
||||||
|
scalarmult7.res \
|
||||||
secretbox.res \
|
secretbox.res \
|
||||||
secretbox2.res \
|
secretbox2.res \
|
||||||
secretbox7.res \
|
secretbox7.res \
|
||||||
@ -163,6 +165,7 @@ TESTS_TARGETS = \
|
|||||||
scalarmult2 \
|
scalarmult2 \
|
||||||
scalarmult5 \
|
scalarmult5 \
|
||||||
scalarmult6 \
|
scalarmult6 \
|
||||||
|
scalarmult7 \
|
||||||
secretbox \
|
secretbox \
|
||||||
secretbox2 \
|
secretbox2 \
|
||||||
secretbox7 \
|
secretbox7 \
|
||||||
@ -300,6 +303,9 @@ scalarmult5_LDADD = $(TESTS_LDADD)
|
|||||||
scalarmult6_SOURCE = cmptest.h scalarmult6.c
|
scalarmult6_SOURCE = cmptest.h scalarmult6.c
|
||||||
scalarmult6_LDADD = $(TESTS_LDADD)
|
scalarmult6_LDADD = $(TESTS_LDADD)
|
||||||
|
|
||||||
|
scalarmult7_SOURCE = cmptest.h scalarmult7.c
|
||||||
|
scalarmult7_LDADD = $(TESTS_LDADD)
|
||||||
|
|
||||||
secretbox_SOURCE = cmptest.h secretbox.c
|
secretbox_SOURCE = cmptest.h secretbox.c
|
||||||
secretbox_LDADD = $(TESTS_LDADD)
|
secretbox_LDADD = $(TESTS_LDADD)
|
||||||
|
|
||||||
|
31
test/default/scalarmult7.c
Normal file
31
test/default/scalarmult7.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
#define TEST_NAME "scalarmult7"
|
||||||
|
#include "cmptest.h"
|
||||||
|
|
||||||
|
unsigned char p1[32] = {
|
||||||
|
0x72, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54,
|
||||||
|
0x74, 0x8b, 0x7d, 0xdc, 0xb4, 0x3e, 0xf7, 0x5a,
|
||||||
|
0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38, 0x1a, 0xf4,
|
||||||
|
0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0xea
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned char p2[32] = {
|
||||||
|
0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54,
|
||||||
|
0x74, 0x8b, 0x7d, 0xdc, 0xb4, 0x3e, 0xf7, 0x5a,
|
||||||
|
0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38, 0x1a, 0xf4,
|
||||||
|
0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned char scalar[32];
|
||||||
|
unsigned char out1[32];
|
||||||
|
unsigned char out2[32];
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
scalar[0] = 1U;
|
||||||
|
crypto_scalarmult_curve25519(out1, scalar, p1);
|
||||||
|
crypto_scalarmult_curve25519(out2, scalar, p2);
|
||||||
|
printf("%d\n", !!memcmp(out1, out2, 32));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
1
test/default/scalarmult7.exp
Normal file
1
test/default/scalarmult7.exp
Normal file
@ -0,0 +1 @@
|
|||||||
|
1
|
Loading…
Reference in New Issue
Block a user