a684152a2f
We only ever compute it for odd (actually, prime) modulus as part of BN_mod_sqrt. If we cared, we could probably drop this from most binaries. This is used to when modular square root needs Tonelli-Shanks. Modular square root is only used for compressed coordinates. Of our supported curves (I'm handwaiving away EC_GROUP_new_curve_GFp here[*]), only P-224 needs the full Tonelli-Shanks algorithm (p is 1 mod 8). That computes the Legendre symbol a bunch to find a non-square mod p. But p is known at compile-time, so we can just hard-code a sample non-square. Sadly, BN_mod_sqrt has some callers outside of crypto/ec, so there's also that. Anyway, it's also not that large of a function. [*] Glancing through SEC 2 and Brainpool, secp224r1 is the only curve listed in either document whose prime is not either 3 mod 4 or 5 mod 8. Even 5 mod 8 is rare: only secp224k1. It's unlikely anyone would notice if we broke annoying primes. Though OpenSSL does support "WTLS" curves which has an additional 1 mod 8 case. Change-Id: If36aa78c0d41253ec024f2d90692949515356cd1 Reviewed-on: https://boringssl-review.googlesource.com/15425 Reviewed-by: Adam Langley <agl@google.com>
88 lines
1.3 KiB
CMake
88 lines
1.3 KiB
CMake
include_directories(../../include)
|
|
|
|
if (${ARCH} STREQUAL "x86_64")
|
|
set(
|
|
BN_ARCH_SOURCES
|
|
|
|
x86_64-mont.${ASM_EXT}
|
|
x86_64-mont5.${ASM_EXT}
|
|
rsaz-avx2.${ASM_EXT}
|
|
|
|
rsaz_exp.c
|
|
)
|
|
endif()
|
|
|
|
if (${ARCH} STREQUAL "x86")
|
|
set(
|
|
BN_ARCH_SOURCES
|
|
|
|
bn-586.${ASM_EXT}
|
|
co-586.${ASM_EXT}
|
|
x86-mont.${ASM_EXT}
|
|
)
|
|
endif()
|
|
|
|
if (${ARCH} STREQUAL "arm")
|
|
set(
|
|
BN_ARCH_SOURCES
|
|
|
|
armv4-mont.${ASM_EXT}
|
|
)
|
|
endif()
|
|
|
|
if (${ARCH} STREQUAL "aarch64")
|
|
set(
|
|
BN_ARCH_SOURCES
|
|
|
|
armv8-mont.${ASM_EXT}
|
|
)
|
|
endif()
|
|
|
|
add_library(
|
|
bn
|
|
|
|
OBJECT
|
|
|
|
add.c
|
|
asm/x86_64-gcc.c
|
|
bn.c
|
|
bn_asn1.c
|
|
cmp.c
|
|
convert.c
|
|
ctx.c
|
|
div.c
|
|
exponentiation.c
|
|
generic.c
|
|
gcd.c
|
|
jacobi.c
|
|
montgomery.c
|
|
montgomery_inv.c
|
|
mul.c
|
|
prime.c
|
|
random.c
|
|
shift.c
|
|
sqrt.c
|
|
|
|
${BN_ARCH_SOURCES}
|
|
)
|
|
|
|
perlasm(x86_64-mont.${ASM_EXT} asm/x86_64-mont.pl)
|
|
perlasm(x86_64-mont5.${ASM_EXT} asm/x86_64-mont5.pl)
|
|
perlasm(rsaz-avx2.${ASM_EXT} asm/rsaz-avx2.pl)
|
|
perlasm(bn-586.${ASM_EXT} asm/bn-586.pl)
|
|
perlasm(co-586.${ASM_EXT} asm/co-586.pl)
|
|
perlasm(x86-mont.${ASM_EXT} asm/x86-mont.pl)
|
|
perlasm(armv4-mont.${ASM_EXT} asm/armv4-mont.pl)
|
|
perlasm(armv8-mont.${ASM_EXT} asm/armv8-mont.pl)
|
|
|
|
add_executable(
|
|
bn_test
|
|
|
|
bn_test.cc
|
|
|
|
$<TARGET_OBJECTS:test_support>
|
|
)
|
|
|
|
target_link_libraries(bn_test crypto)
|
|
add_dependencies(all_tests bn_test)
|