Add 'crypto/libecc/' from commit '736d663976d1768533badbf06581481d01fade4c'

git-subtree-dir: crypto/libecc
git-subtree-mainline: f59bb61e1e
git-subtree-split: 736d663976
(cherry picked from commit f0865ec990)
This commit is contained in:
Kyle Evans 2025-01-01 15:11:18 -06:00
parent c876932bba
commit 539736e08c
344 changed files with 959066 additions and 0 deletions

View file

@ -0,0 +1,26 @@
name: CIFuzz
on: [pull_request]
jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'libecc'
dry-run: false
language: c++
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'libecc'
fuzz-seconds: 300
dry-run: false
language: c++
- name: Upload Crash
uses: actions/upload-artifact@v3
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts

View file

@ -0,0 +1,57 @@
name: libecc
# Run this workflow every time a new commit pushed to your repository
on: push
jobs:
compilation_tests:
runs-on: ubuntu-22.04
strategy:
#max-parallel: 10
matrix:
cc: [gcc, clang, g++, clang++]
blinding: [0, 1]
complete: [0, 1]
ladder: [0, 1]
cryptofuzz: [0, 1]
optflags: ["-O3", "-O2", "-O1"]
steps:
# Checkout repository
- name: checkout repository
uses: actions/checkout@v2
# Run actions
# libecc compilation tests
- name: libecc compilation tests
env:
CC: ${{ matrix.cc }}
BLINDING: ${{ matrix.blinding }}
COMPLETE: ${{ matrix.complete }}
LADDER: ${{ matrix.ladder }}
CRYPTOFUZZ: ${{ matrix.cryptofuzz }}
EXTRA_LIB_CFLAGS: ${{ matrix.optflags }}
EXTRA_BIN_CFLAGS: ${{ matrix.optflags }}
shell: bash
run: |
# Compilation tests of all cases
#
make && cd src/arithmetic_tests/ && make clean && make bin && make clean && cd -;
cd src/examples/ && make clean && make && cd - && make clean;
make 16;
cd src/examples/ && make clean && make 16 && cd - && make clean;
make 32;
cd src/examples/ && make clean && make 32 && cd - && make clean;
make 64;
cd src/examples/ && make clean && make 64 && cd - && make clean;
# We perform one test with the sanitizers
USE_SANITIZERS=1 make;
cd src/examples/ && make clean && USE_SANITIZERS=1 make && cd - && make clean;
#
make debug;
cd src/examples/ && make clean && make debug && cd - && make clean;
make debug16;
cd src/examples/ && make clean && make debug16 && cd - && make clean;
make debug32;
cd src/examples/ && make clean && make debug32 && cd - && make clean;
make debug64;
cd src/examples/ && make clean && make debug64 && cd - && make clean;
continue-on-error: false

View file

@ -0,0 +1,55 @@
name: libecc
# Run this workflow every time a new commit pushed to your repository
on: push
jobs:
cross_arch_tests:
runs-on: ubuntu-20.04
strategy:
#max-parallel: 10
matrix:
blinding: [0, 1]
complete: [1]
ladder: [1]
#cross_target: [arm-linux-gnueabi, arm-linux-gnueabihf, aarch64-linux-gnu, powerpc64le-linux-gnu, mipsel-linux-gnu, i686-w64-mingw32, x86_64-w64-mingw32, i386-apple-darwin, x86_64-apple-darwin, x86_64h-apple-darwin]
cross_target: [arm-linux-gnueabi, arm-linux-gnueabihf, aarch64-linux-gnu, powerpc64le-linux-gnu, mipsel-linux-gnu, i686-w64-mingw32, x86_64-w64-mingw32]
cross_size: [16, 32, 64]
steps:
# Add swap because of possible out of memory issues
- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 10
# Checkout repository
- name: checkout repository
uses: actions/checkout@v2
# Run actions
# Cross build and cross run tests
- name: libecc cross-arch tests
env:
BLINDING: ${{ matrix.blinding }}
COMPLETE: ${{ matrix.complete }}
LADDER: ${{ matrix.ladder }}
CROSS_TARGET: ${{ matrix.cross_target }}
CROSS_SIZE: ${{ matrix.cross_size }}
CRYPTOFUZZ: 1
shell: bash
run: |
# Install stuff
sudo apt-get update;
# This oddity is due to ubuntu (18.04 and 20.04) issue with wine32 in
# githbub actions runners ...
sudo apt-get -y install software-properties-common;
sudo apt-add-repository "ppa:ondrej/php" -y;
sudo dpkg --add-architecture i386;
sudo apt-get update;
sudo apt-get -y install qemu-user-static wine-stable wine32 wine64;
# Cross build jobs
docker pull multiarch/crossbuild;
sh scripts/crossbuild.sh -triplet "${CROSS_TARGET}" "${CROSS_SIZE}";
# Check for errors
[ ! -z "$(ls -A scripts/crossbuild_out/error_log/)" ] && exit -1;
# Test generated cross binaries through qemu-static;
sh scripts/crossrun.sh -triplet "${CROSS_TARGET}" "${CROSS_SIZE}";
continue-on-error: false

View file

@ -0,0 +1,39 @@
name: libecc
# Run this workflow every time a new commit pushed to your repository
on: push
jobs:
examples:
runs-on: ubuntu-22.04
strategy:
#max-parallel: 10
matrix:
cc: [gcc, clang]
blinding: [0, 1]
cryptofuzz: [1]
steps:
# Checkout repository
- name: checkout repository
uses: actions/checkout@v2
# Run actions
# libecc examples tests
- name: libecc examples tests
env:
CC: ${{ matrix.cc }}
BLINDING: ${{ matrix.blinding }}
CRYPTOFUZZ: ${{ matrix.cryptofuzz }}
ASSERT_PRINT: 1
# We want to parallelize self tests
OPENMP_SELF_TESTS: 1
shell: bash
run: |
# Install OpenMP
sudo apt-get update;
sudo apt-get -y install libomp-dev;
# Compile and compile the tests
#
EXTRA_CFLAGS="-DUSER_NN_BIT_LEN=4096" make && cd src/examples/ && EXTRA_CFLAGS="-DUSER_NN_BIT_LEN=4096" make && ./sig/rsa/rsa && ./sig/dsa/dsa && ./sig/kcdsa/kcdsa && ./sig/sdsa/sdsa && ./sig/gostr34_10_94/gostr34_10_94 && ./sss/sss && ./basic/curve_basic_examples && ./basic/curve_ecdh && make clean && cd - && make clean;
make 32 && cd src/examples/ && make 32 && ./sss/sss && ./basic/curve_basic_examples && ./basic/curve_ecdh && make clean && cd - && make clean;
make 16 && cd src/examples/ && make 16 && ./sss/sss && ./basic/curve_basic_examples && ./basic/curve_ecdh && make clean && cd - && make clean;
continue-on-error: false

View file

@ -0,0 +1,37 @@
name: libecc
# Run this workflow every time a new commit pushed to your repository
on: push
jobs:
compilation_tests:
runs-on: ubuntu-22.04
strategy:
#max-parallel: 10
matrix:
cc: [gcc, clang, g++, clang++]
blinding: [0, 1]
complete: [0, 1]
ladder: [0, 1]
cryptofuzz: [0, 1]
optflags: ["-O3", "-O2", "-O1"]
steps:
# Checkout repository
- name: checkout repository
uses: actions/checkout@v2
# Run actions
# libecc compilation tests using meson
- name: libecc meson compilation tests
shell: bash
run: |
sudo apt-get update;
sudo apt-get -y install python3-pip;
pip install meson;
pip install ninja;
pip install dunamai;
# Compilation tests of all cases
#
rm -rf builddir/ && meson setup -Dwith_wordsize=16 builddir && cd builddir && meson dist && cd -;
rm -rf builddir/ && meson setup -Dwith_wordsize=32 builddir && cd builddir && meson dist && cd -;
rm -rf builddir/ && meson setup -Dwith_wordsize=64 builddir && cd builddir && meson dist && cd -;
continue-on-error: false

View file

@ -0,0 +1,43 @@
name: libecc
# Run this workflow every time a new commit pushed to your repository
on: push
jobs:
runtime_tests:
runs-on: ubuntu-22.04
strategy:
#max-parallel: 10
matrix:
cc: [gcc, clang]
blinding: [0, 1]
cryptofuzz: [1]
steps:
# Checkout repository
- name: checkout repository
uses: actions/checkout@v2
# Run actions
# libecc python tests
- name: libecc python tests
env:
CC: ${{ matrix.cc }}
BLINDING: ${{ matrix.blinding }}
CRYPTOFUZZ: ${{ matrix.cryptofuzz }}
ASSERT_PRINT: 1
# We want to parallelize self tests
OPENMP_SELF_TESTS: 1
shell: bash
run: |
# Install Python2 and OpenMP
sudo apt-get update;
sudo apt-get -y install python2 libomp-dev;
# Test our Python libecc expanding script
# Python3
echo "y" | python3 scripts/expand_libecc.py --remove-all && PYTHON=python3 sh scripts/gen_curves_tests.sh && make clean && make && ./build/ec_self_tests vectors rand;
# Clean
echo "y" | python3 scripts/expand_libecc.py --remove-all && make clean;
# Python2
echo "y" | python2 scripts/expand_libecc.py --remove-all && PYTHON=python2 sh scripts/gen_curves_tests.sh && make clean && make && ./build/ec_self_tests vectors rand;
# Clean
echo "y" | python2 scripts/expand_libecc.py --remove-all && make clean;
continue-on-error: false

View file

@ -0,0 +1,39 @@
name: libecc
# Run this workflow every time a new commit pushed to your repository
on: push
jobs:
runtime_tests:
runs-on: ubuntu-22.04
strategy:
#max-parallel: 10
matrix:
cc: [gcc, clang]
blinding: [1]
cryptofuzz: [1]
wordsize: [64, 32, 16]
steps:
# Checkout repository
- name: checkout repository
uses: actions/checkout@v2
# Run actions
# libecc runtime tests
- name: libecc runtime tests
env:
CC: ${{ matrix.cc }}
BLINDING: ${{ matrix.blinding }}
CRYPTOFUZZ: ${{ matrix.cryptofuzz }}
ASSERT_PRINT: 1
# We want to parallelize self tests
OPENMP_SELF_TESTS: 1
WORDSIZE: ${{ matrix.wordsize }}
shell: bash
run: |
# Install OpenMP
sudo apt-get update;
sudo apt-get -y install libomp-dev;
# Vanilla tests
#
make "${WORDSIZE}" && ./build/ec_self_tests vectors rand;
continue-on-error: false

4
crypto/libecc/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
*.o
*.d
*~
*.su

287
crypto/libecc/.travis.yml Normal file
View file

@ -0,0 +1,287 @@
language: c
os: linux
dist:
- bionic
env:
global:
# COVERITY_SCAN_TOKEN
- secure: "jhz0JLrLjWABZfT/mWiwuddUMvJNdrkIWJEqFGtGLO/x/nbiFD8ooHl/Sb+JSOsr8obXYMVmO+7ubTOLeqAbfaqS/5OZSQZjKAl4G6vGK40qY8cm1F7PTv5H3533XJGG6u4SZkMMlecz1UwsdmQ/5uabhzZwa9vMhuWJPkFy6uwvv09+r7cu8p4sN1KKfkIqIwpdpWmoOoltxfLPKkaIuxhftKDCYrcpd9K82NfXm/9Whxfra35Wq9IcxZXfNt6QKw0OLGnwR70hQZrRsd0bQAzeerWHCnqAbY2neNtMjiV905GJkUaCvWTF6P2ZbTCzN3Jy6wGz/LMSyztnWy/0pa9+dEWdCOZPLsrg+BTcBZNwPBho/Lg/diA/8Dz9plDirvogTpz6O0vzqmLRTVUp6uqBsTAnPHvNS1iz7hUwwvuItSAWOywVeVlpZ2mxUsOUyVzp2iZ9VEr4yk15LLbeYTPIMY2QbwBuG6TkgYn5EiCwsaQlSmPeyJlkc2a5tji2Rgms0wcpOReBxyKKN30LqZyac+bdlkwl6IqzaSWGz0wle68+1vNura+a909kGONLAx/0dbBzL1t5pFrJfDN7brBuk1wJuurecn8owdts4iPMaowpje79BG2hTQot969Ig00j4mhg1BJv5kk7c/mO3TqbDW8tPAto5tcWrYfELu4="
before_install:
- echo -n | openssl s_client -connect https://scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
addons:
apt:
update: true
packages:
- make
- gcc
- clang
- qemu-user-static
- wine-stable
- wine32
- wine64
- python3
coverity_scan:
project:
name: "rb-anssi/libecc_local"
description: "Build submitted via Travis CI of libecc"
notification_email: ryadbenadjila@gmail.com
build_command: make
branch_pattern: coverity_scan
cache:
apt: true
# We use docker for the cross-build
services:
- docker
# All our jobs
env:
matrix:
# Python libecc expand script test
- TEST_PYTHON_EXPAND_SCRIPT=1
# Vanilla tests (on native plaform)
- BLINDING=0 COMPLETE=0 CROSS_BUILD=0 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=0 LADDER=1
- BLINDING=0 COMPLETE=1 CROSS_BUILD=0 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=0 LADDER=1
- CC=clang BLINDING=0 COMPLETE=0 CROSS_BUILD=0 LADDER=1
- CC=clang BLINDING=1 COMPLETE=0 CROSS_BUILD=0 LADDER=1
- CC=clang BLINDING=0 COMPLETE=1 CROSS_BUILD=0 LADDER=1
- CC=clang BLINDING=1 COMPLETE=1 CROSS_BUILD=0 LADDER=1
- BLINDING=0 COMPLETE=0 CROSS_BUILD=0 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=0 LADDER=0
- BLINDING=0 COMPLETE=1 CROSS_BUILD=0 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=0 LADDER=0
- CC=clang BLINDING=0 COMPLETE=0 CROSS_BUILD=0 LADDER=0
- CC=clang BLINDING=1 COMPLETE=0 CROSS_BUILD=0 LADDER=0
- CC=clang BLINDING=0 COMPLETE=1 CROSS_BUILD=0 LADDER=0
- CC=clang BLINDING=1 COMPLETE=1 CROSS_BUILD=0 LADDER=0
# Cross compilation tests (using docker and qemu-static)
# arm-linux-gnueabi
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=16 LADDER=1
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=16 LADDER=1
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=32 LADDER=1
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=32 LADDER=1
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=64 LADDER=1
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=64 LADDER=1
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=16 LADDER=0
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=16 LADDER=0
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=32 LADDER=0
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=32 LADDER=0
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=64 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=64 LADDER=0
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=64 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabi CROSS_SIZE=64 LADDER=0
# arm-linux-gnueabihf
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=16 LADDER=1
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=16 LADDER=1
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=32 LADDER=1
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=32 LADDER=1
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=64 LADDER=1
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=64 LADDER=1
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=16 LADDER=0
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=16 LADDER=0
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=32 LADDER=0
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=32 LADDER=0
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=64 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=64 LADDER=0
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=64 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=arm-linux-gnueabihf CROSS_SIZE=64 LADDER=0
# powerpc64le-linux-gnu
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=16 LADDER=1
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=16 LADDER=1
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=32 LADDER=1
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=32 LADDER=1
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=64 LADDER=1
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=64 LADDER=1
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=16 LADDER=0
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=16 LADDER=0
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=32 LADDER=0
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=32 LADDER=0
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=64 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=64 LADDER=0
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=64 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=powerpc64le-linux-gnu CROSS_SIZE=64 LADDER=0
# aarch64-linux-gnu
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=16 LADDER=1
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=16 LADDER=1
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=32 LADDER=1
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=32 LADDER=1
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=64 LADDER=1
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=64 LADDER=1
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=16 LADDER=0
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=16 LADDER=0
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=32 LADDER=0
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=32 LADDER=0
- BLINDING=0 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=64 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=64 LADDER=0
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=64 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=aarch64-linux-gnu CROSS_SIZE=64 LADDER=0
# mipsel-linux-gnu
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=mipsel-linux-gnu CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=mipsel-linux-gnu CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=mipsel-linux-gnu CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=mipsel-linux-gnu CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=mipsel-linux-gnu CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=mipsel-linux-gnu CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=mipsel-linux-gnu CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=mipsel-linux-gnu CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=mipsel-linux-gnu CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=mipsel-linux-gnu CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=mipsel-linux-gnu CROSS_SIZE=64 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=mipsel-linux-gnu CROSS_SIZE=64 LADDER=0
# i386-apple-darwin
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=i386-apple-darwin CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=i386-apple-darwin CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=i386-apple-darwin CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=i386-apple-darwin CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=i386-apple-darwin CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=i386-apple-darwin CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=i386-apple-darwin CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=i386-apple-darwin CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=i386-apple-darwin CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=i386-apple-darwin CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=i386-apple-darwin CROSS_SIZE=64 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=i386-apple-darwin CROSS_SIZE=64 LADDER=0
# x86_64-apple-darwin
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64-apple-darwin CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64-apple-darwin CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64-apple-darwin CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64-apple-darwin CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64-apple-darwin CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64-apple-darwin CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64-apple-darwin CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64-apple-darwin CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64-apple-darwin CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64-apple-darwin CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64-apple-darwin CROSS_SIZE=64 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64-apple-darwin CROSS_SIZE=64 LADDER=0
# x86_64h-apple-darwin
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64h-apple-darwin CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64h-apple-darwin CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64h-apple-darwin CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64h-apple-darwin CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64h-apple-darwin CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64h-apple-darwin CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64h-apple-darwin CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64h-apple-darwin CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64h-apple-darwin CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64h-apple-darwin CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64h-apple-darwin CROSS_SIZE=64 LADDER=0
- BLINDING=0 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64h-apple-darwin CROSS_SIZE=64 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64h-apple-darwin CROSS_SIZE=64 LADDER=0
# i686-w64-mingw32
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=i686-w64-mingw32 CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=i686-w64-mingw32 CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=i686-w64-mingw32 CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=i686-w64-mingw32 CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=i686-w64-mingw32 CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=i686-w64-mingw32 CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=i686-w64-mingw32 CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=i686-w64-mingw32 CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=i686-w64-mingw32 CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=i686-w64-mingw32 CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=i686-w64-mingw32 CROSS_SIZE=64 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=i686-w64-mingw32 CROSS_SIZE=64 LADDER=0
# x86_64-w64-mingw32
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64-w64-mingw32 CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64-w64-mingw32 CROSS_SIZE=16 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64-w64-mingw32 CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64-w64-mingw32 CROSS_SIZE=32 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64-w64-mingw32 CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64-w64-mingw32 CROSS_SIZE=64 LADDER=1
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64-w64-mingw32 CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64-w64-mingw32 CROSS_SIZE=16 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64-w64-mingw32 CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64-w64-mingw32 CROSS_SIZE=32 LADDER=0
- BLINDING=1 COMPLETE=0 CROSS_BUILD=1 CROSS_TARGET=x86_64-w64-mingw32 CROSS_SIZE=64 LADDER=0
- BLINDING=1 COMPLETE=1 CROSS_BUILD=1 CROSS_TARGET=x86_64-w64-mingw32 CROSS_SIZE=64 LADDER=0
script:
# Coverity scan static analysis
- if [ "${COVERITY_SCAN_BRANCH}" == 1 ]; then make; fi
- if [ "${COVERITY_SCAN_BRANCH}" == 1 ]; then exit 0; fi
# Test our Python libecc expanding script
# Python2
- if [ "${TEST_PYTHON_EXPAND_SCRIPT}" == 1 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then echo "y" | python2 scripts/expand_libecc.py --remove-all && PYTHON=python2 sh scripts/gen_curves_tests.sh && make clean && make && ./build/ec_self_tests vectors && ./build/ec_self_tests rand; fi;
# Python3
- if [ "${TEST_PYTHON_EXPAND_SCRIPT}" == 1 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then echo "y" | python3 scripts/expand_libecc.py --remove-all && PYTHON=python3 sh scripts/gen_curves_tests.sh && make clean && make && ./build/ec_self_tests vectors && ./build/ec_self_tests rand; fi;
# Clean
- if [ "${TEST_PYTHON_EXPAND_SCRIPT}" == 1 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then echo "y" | python2 scripts/expand_libecc.py --remove-all && make clean; fi;
# Vanilla tests
- if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then git fetch origin refs/pull/${TRAVIS_PULL_REQUEST}/head && git checkout FETCH_HEAD; fi
- if [ "${CROSS_BUILD}" = 0 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then make && ./build/ec_self_tests vectors && ./build/ec_self_tests rand && cd src/arithmetic_tests/ && make clean && make && make clean && cd -; fi
- if [ "${CROSS_BUILD}" = 0 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then cd src/examples/ && make clean && make && cd - && make clean; fi
- if [ "${CROSS_BUILD}" = 0 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then make 16 && ./build/ec_self_tests vectors && ./build/ec_self_tests rand && cd src/arithmetic_tests/ && make clean && make 16 && make clean && cd -; fi
- if [ "${CROSS_BUILD}" = 0 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then cd src/examples/ && make clean && make 16 && cd - && make clean; fi
- if [ "${CROSS_BUILD}" = 0 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then make 32 && ./build/ec_self_tests vectors && ./build/ec_self_tests rand && cd src/arithmetic_tests/ && make clean && make 32 && make clean && cd -; fi
- if [ "${CROSS_BUILD}" = 0 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then cd src/examples/ && make clean && make 32 && cd - && make clean; fi
- if [ "${CROSS_BUILD}" = 0 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then make 64 && ./build/ec_self_tests vectors && ./build/ec_self_tests rand && cd src/arithmetic_tests/ && make clean && make 64 && make clean && cd -; fi
- if [ "${CROSS_BUILD}" = 0 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then cd src/examples/ && make clean && make 64 && cd - && make clean; fi
- if [ "${CROSS_BUILD}" = 0 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then make debug && ./build/ec_self_tests vectors && ./build/ec_self_tests rand && cd src/arithmetic_tests/ && make clean && make debug && make clean && cd -; fi
- if [ "${CROSS_BUILD}" = 0 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then cd src/examples/ && make clean && make debug && cd - && make clean; fi
- if [ "${CROSS_BUILD}" = 0 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then make debug16 && ./build/ec_self_tests vectors && ./build/ec_self_tests rand && cd src/arithmetic_tests/ && make clean && make debug16 && make clean && cd -; fi
- if [ "${CROSS_BUILD}" = 0 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then cd src/examples/ && make clean && make debug16 && cd - && make clean; fi
- if [ "${CROSS_BUILD}" = 0 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then make debug32 && ./build/ec_self_tests vectors && ./build/ec_self_tests rand && cd src/arithmetic_tests/ && make clean && make debug32 && make clean && cd -; fi
- if [ "${CROSS_BUILD}" = 0 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then cd src/examples/ && make clean && make debug32 && cd - && make clean; fi
- if [ "${CROSS_BUILD}" = 0 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then make debug64 && ./build/ec_self_tests vectors && ./build/ec_self_tests rand && cd src/arithmetic_tests/ && make clean && make debug64 && make clean && cd -; fi
- if [ "${CROSS_BUILD}" = 0 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then cd src/examples/ && make clean && make debug64 && cd - && make clean; fi
# Cross build jobs
- if [ "${CROSS_BUILD}" = 1 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then docker pull multiarch/crossbuild; fi
- if [ "${CROSS_BUILD}" = 1 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then sh scripts/crossbuild.sh -triplet "${CROSS_TARGET}" "${CROSS_SIZE}"; fi
# Test generated cross binaries through qemu-static
- if [ "${CROSS_BUILD}" = 1 ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then sh scripts/crossrun.sh -triplet "${CROSS_TARGET}" "${CROSS_SIZE}"; fi
notifications:
email:
recipients:
- ryadbenadjila@gmail.com
on_success: never
on_failure: always
on_pull_requests: always

50
crypto/libecc/LICENSE Normal file
View file

@ -0,0 +1,50 @@
The files in this project are provided under a dual BSD/GPLv2 license. When
using or redistributing this software, you may do so under either license.
GPLv2 License summary
---------------------
Copyright (C) 2017
All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BSD License
-----------
Copyright (C) 2017
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

175
crypto/libecc/Makefile Normal file
View file

@ -0,0 +1,175 @@
.SUFFIXES:
# Where to put generated objects
BUILD_DIR ?= build
# Default to the previous behaviour and keep generated .o & .d files next to the source code
OBJ_DIR ?=.
include common.mk
# Static libraries to build
LIBS = $(LIBARITH) $(LIBEC) $(LIBSIGN)
# Compile dynamic libraries if the user asked to
ifeq ($(WITH_DYNAMIC_LIBS),1)
LIBS += $(LIBARITH_DYN) $(LIBEC_DYN) $(LIBSIGN_DYN)
endif
# Executables to build
TESTS_EXEC = $(BUILD_DIR)/ec_self_tests $(BUILD_DIR)/ec_utils
# We also compile executables with dynamic linking if asked to
ifeq ($(WITH_DYNAMIC_LIBS),1)
TESTS_EXEC += $(BUILD_DIR)/ec_self_tests_dyn $(BUILD_DIR)/ec_utils_dyn
endif
EXEC_TO_CLEAN = $(BUILD_DIR)/ec_self_tests $(BUILD_DIR)/ec_utils $(BUILD_DIR)/ec_self_tests_dyn $(BUILD_DIR)/ec_utils_dyn
# all and clean, as you might expect
all: $(LIBS) $(TESTS_EXEC)
# Default object files extension
OBJ_FILES_EXTENSION ?= o
clean:
@rm -f $(LIBS) $(EXEC_TO_CLEAN)
@find $(OBJ_DIR)/ -name '*.$(OBJ_FILES_EXTENSION)' -exec rm -f '{}' \;
@find $(OBJ_DIR)/ -name '*.d' -exec rm -f '{}' \;
@find $(BUILD_DIR)/ -name '*.a' -exec rm -f '{}' \;
@find $(BUILD_DIR)/ -name '*.so' -exec rm -f '{}' \;
@find . -name '*~' -exec rm -f '{}' \;
# --- Source Code ---
# external dependencies
EXT_DEPS_SRC = $(wildcard src/external_deps/*.c)
# utils module (for the ARITH layer, we only need
# NN and FP - and not curves - related stuff. Same goes
# for EC and SIGN. Hence the distinction between three
# sets of utils objects.
UTILS_ARITH_SRC = src/utils/utils.c src/utils/utils_rand.c
UTILS_ARITH_SRC += $(wildcard src/utils/*_nn.c)
UTILS_ARITH_SRC += $(wildcard src/utils/*_fp.c)
UTILS_ARITH_SRC += $(wildcard src/utils/*_buf.c)
UTILS_EC_SRC = $(wildcard src/utils/*_curves.c)
UTILS_SIGN_SRC = $(wildcard src/utils/*_keys.c)
# nn module
NN_SRC = $(wildcard src/nn/n*.c)
# fp module
FP_SRC = $(wildcard src/fp/fp*.c)
# curve module
CURVES_SRC = $(wildcard src/curves/*.c)
# Hash module
HASH_SRC = $(wildcard src/hash/sha*.c) $(wildcard src/hash/bash*.c) src/hash/hash_algs.c src/hash/sm3.c src/hash/streebog.c src/hash/ripemd160.c src/hash/belt-hash.c src/hash/hmac.c
# Key/Signature/Verification/ECDH module
SIG_SRC = $(wildcard src/sig/*dsa.c) src/sig/ecdsa_common.c src/sig/ecsdsa_common.c src/sig/sig_algs.c src/sig/sm2.c src/sig/bign_common.c src/sig/bign.c src/sig/dbign.c src/sig/bip0340.c
ECDH_SRC = $(wildcard src/ecdh/*.c)
KEY_SRC = src/sig/ec_key.c
# Test elements
TESTS_OBJECTS_CORE_SRC = src/tests/ec_self_tests_core.c
TESTS_OBJECTS_SELF_SRC = src/tests/ec_self_tests.c
TESTS_OBJECTS_UTILS_SRC = src/tests/ec_utils.c
# --- Static Libraries ---
LIBARITH_SRC = $(FP_SRC) $(NN_SRC) $(UTILS_ARITH_SRC)
LIBARITH_OBJECTS = $(patsubst %,$(OBJ_DIR)/%.$(OBJ_FILES_EXTENSION),$(basename $(LIBARITH_SRC)))
$(LIBARITH): $(LIBARITH_OBJECTS)
$(VERBOSE_MAKE)$(CROSS_COMPILE)$(AR) $(AR_FLAGS) $@ $^
$(VERBOSE_MAKE)$(CROSS_COMPILE)$(RANLIB) $(RANLIB_FLAGS) $@
LIBEC_SRC = $(LIBARITH_SRC) $(CURVES_SRC) $(UTILS_EC_SRC)
LIBEC_OBJECTS = $(patsubst %,$(OBJ_DIR)/%.$(OBJ_FILES_EXTENSION),$(basename $(LIBEC_SRC)))
$(LIBEC): $(LIBEC_OBJECTS)
$(VERBOSE_MAKE)$(CROSS_COMPILE)$(AR) $(AR_FLAGS) $@ $^
$(VERBOSE_MAKE)$(CROSS_COMPILE)$(RANLIB) $(RANLIB_FLAGS) $@
LIBSIGN_SRC = $(LIBEC_SRC) $(HASH_SRC) $(SIG_SRC) $(KEY_SRC) $(UTILS_SIGN_SRC) $(ECDH_SRC)
LIBSIGN_OBJECTS = $(patsubst %,$(OBJ_DIR)/%.$(OBJ_FILES_EXTENSION),$(basename $(LIBSIGN_SRC)))
$(LIBSIGN): $(LIBSIGN_OBJECTS)
$(VERBOSE_MAKE)$(CROSS_COMPILE)$(AR) $(AR_FLAGS) $@ $^
$(VERBOSE_MAKE)$(CROSS_COMPILE)$(RANLIB) $(RANLIB_FLAGS) $@
# --- Dynamic Libraries ---
$(LIBARITH_DYN): $(LIBARITH_OBJECTS)
$(VERBOSE_MAKE)$(CROSS_COMPILE)$(CC) $(LIB_CFLAGS) $(LIB_DYN_LDFLAGS) $^ -o $@
$(LIBEC_DYN): $(LIBEC_OBJECTS)
$(VERBOSE_MAKE)$(CROSS_COMPILE)$(CC) $(LIB_CFLAGS) $(LIB_DYN_LDFLAGS) $^ -o $@
$(LIBSIGN_DYN): $(LIBSIGN_OBJECTS)
$(VERBOSE_MAKE)$(CROSS_COMPILE)$(CC) $(LIB_CFLAGS) $(LIB_DYN_LDFLAGS) $^ -o $@
# --- Executables (Static linkage with libsign object files) ---
EC_SELF_TESTS_SRC = $(TESTS_OBJECTS_CORE_SRC) $(TESTS_OBJECTS_SELF_SRC) $(EXT_DEPS_SRC)
EC_SELF_TESTS_OBJECTS = $(patsubst %,$(OBJ_DIR)/%.$(OBJ_FILES_EXTENSION),$(basename $(EC_SELF_TESTS_SRC)))
$(BUILD_DIR)/ec_self_tests: $(EC_SELF_TESTS_OBJECTS) $(LIBSIGN_OBJECTS)
$(VERBOSE_MAKE)$(CROSS_COMPILE)$(CC) $(BIN_CFLAGS) $(BIN_LDFLAGS) $^ -o $@
EC_UTILS_SRC = $(TESTS_OBJECTS_CORE_SRC) $(TESTS_OBJECTS_UTILS_SRC) $(EXT_DEPS_SRC)
EC_UTILS_OBJECTS = $(patsubst %,$(OBJ_DIR)/%.$(OBJ_FILES_EXTENSION),$(basename $(EC_UTILS_SRC)))
$(BUILD_DIR)/ec_utils: $(EC_UTILS_SRC) $(LIBSIGN_OBJECTS)
$(VERBOSE_MAKE)$(CROSS_COMPILE)$(CC) $(BIN_CFLAGS) $(BIN_LDFLAGS) -DWITH_STDLIB $^ -o $@
# --- Excutables (Dynamic linkage with libsign shared library) ---
$(BUILD_DIR)/ec_self_tests_dyn: $(EC_SELF_TESTS_OBJECTS)
$(VERBOSE_MAKE)$(CROSS_COMPILE)$(CC) $(BIN_CFLAGS) $(BIN_LDFLAGS) -L$(BUILD_DIR) $^ -lsign -o $@
$(BUILD_DIR)/ec_utils_dyn: $(EC_UTILS_OBJECTS)
$(VERBOSE_MAKE)$(CROSS_COMPILE)$(CC) $(BIN_CFLAGS) $(BIN_LDFLAGS) -L$(BUILD_DIR) -DWITH_STDLIB $^ -lsign -o $@
.PHONY: all clean 16 32 64 debug debug16 debug32 debug64 force_arch32 force_arch64
# All source files, used to construct general rules
SRC += $(EXT_DEPS_SRC) $(UTILS_ARITH_SRC) $(UTILS_EC_SRC) $(UTILS_SIGN_SRC)
SRC += $(NN_SRC) $(FP_SRC) $(CURVES_SRC) $(HASH_SRC) $(SIG_SRC) $(ECDH_SRC)
SRC += $(KEY_SRC) $(TESTS_OBJECTS_CORE_SRC) $(TESTS_OBJECTS_SELF_SRC)
SRC += $(TESTS_OBJECTS_UTILS_SRC)
# All object files
OBJS = $(patsubst %,$(OBJ_DIR)/%.$(OBJ_FILES_EXTENSION),$(basename $(SRC)))
# General dependency rule between .o and .d files
DEPS = $(OBJS:.$(OBJ_FILES_EXTENSION)=.d)
# General rule for creating .o (and .d) file from .c
$(OBJ_DIR)/%.$(OBJ_FILES_EXTENSION): %.c
$(VERBOSE_MAKE)$(CROSS_COMPILE)$(CC) -c $(LIB_CFLAGS) -o $@ $<
# Populate the directory structure to contain the .o and .d files, if necessary
$(shell mkdir -p $(dir $(OBJS)) >/dev/null)
$(shell mkdir -p $(BUILD_DIR) >/dev/null)
# Make a note of the MAKEFILE_LIST at this stage of parsing the Makefile
# It is important here to use the ':=' operator so it is evaluated only once,
# and to do this before all the DEPS files are included as makefiles.
MAKEFILES:=$(MAKEFILE_LIST)
# Make object files depend on all makefiles used - this forces a rebuild if any
# of the makefiles are changed
$(OBJS) : $(MAKEFILES)
# Dep files are makefiles that keep track of which header files are used by the
# c source code. Include them to allow them to work correctly.
-include $(DEPS)

1345
crypto/libecc/README.md Normal file

File diff suppressed because it is too large Load diff

3
crypto/libecc/build/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
# Ignore all files generated in this folder except this file
*
!.gitignore

349
crypto/libecc/common.mk Normal file
View file

@ -0,0 +1,349 @@
# Detect mingw, since some versions throw a warning with the -fPIC option
# (which would be caught as an error in our case with -Werror)
# The ELF PIE related hardening flags are also non sense for Windows
MINGW := $(shell $(CROSS_COMPILE)$(CC) -dumpmachine 2>&1 | grep -v mingw)
# Detect Mac OS compilers: these usually don't like ELF pie related flags ...
APPLE := $(shell $(CROSS_COMPILE)$(CC) -dumpmachine 2>&1 | grep -v apple)
SYS_ROOT :=
ifneq ($(MINGW),)
FPIC_CFLAG=-fPIC
ifneq ($(APPLE),)
FPIE_CFLAG=-fPIE
FPIE_LDFLAGS=-pie -Wl,-z,relro,-z,now
endif
endif
ifeq ($(APPLE),)
SYS_ROOT_PATH := $(shell xcode-select --print-path)
ifneq ($(SYS_ROOT_PATH),)
SYS_ROOT_PATH := $(SYS_ROOT_PATH)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
SYS_ROOT := --sysroot=$(SYS_ROOT_PATH)
$(info Using MacOS SDK $(SYS_ROOT_PATH))
endif
endif
# NOTE: with mingw, FORTIFY_SOURCE=2 must be used
# in conjuction with stack-protector as check functions
# are implemented in libssp
STACK_PROT_FLAG=-fstack-protector-strong
FORTIFY_FLAGS=-D_FORTIFY_SOURCE=2
# The first goal here is to define a meaningful set of CFLAGS based on compiler,
# debug mode, expected word size (16, 32, 64), etc. Those are then used to
# define two differents kinds of CFLAGS we will use for building our library
# (LIB_CFLAGS) and binaries (BIN_CFLAGS) objects.
# Detect if we are using clang or gcc
CLANG := $(shell $(CROSS_COMPILE)$(CC) -v 2>&1 | grep clang)
ifneq ($(CLANG),)
# get clang version e.g. 14.1.3
CLANG_VERSION := $(shell $(CROSS_COMPILE)$(CC) -dumpversion)
# convert to single number e.g. 14 * 100 + 1
CLANG_VERSION := $(shell echo $(CLANG_VERSION) | cut -f1-2 -d. | sed -e 's/\./*100+/g')
# Calculate value - e.g. 1401
CLANG_VERSION := $(shell echo $$(($(CLANG_VERSION))))
# Comparison results (true if true, empty if false)
CLANG_VERSION_GTE_12 := $(shell [ $(CLANG_VERSION) -ge 1200 ] && echo true)
CLANG_VERSION_GTE_13 := $(shell [ $(CLANG_VERSION) -ge 1300 ] && echo true)
CLANG_VERSION_GTE_16 := $(shell [ $(CLANG_VERSION) -ge 1600 ] && echo true)
CLANG_VERSION_GTE_17 := $(shell [ $(CLANG_VERSION) -ge 1700 ] && echo true)
endif
# Default warning flags
# -Werror: treat warnings as errors
#
# Pedantic mode: enable more warnings
# -Wshadow: warn the user if a variable declaration shadows one from a parent context
# -Wdouble-promotion: warn about implicit conversion from float to double
# -Wformat=2: warn about format string vulnerabilities
# -fno-common: disallow global variables with same name and type
# -Wconversion: warn about implicit conversion
# -Wformat-security: warn about format string vulnerabilities
WARNING_CFLAGS = -Werror
ifeq ($(PEDANTIC),1)
WARNING_CFLAGS += -Wshadow -Wdouble-promotion -Wformat=2 -fno-common -Wconversion -Wformat-security
endif
# Disable certain warnings:
# -Wno-unused-parameter: commonly a false positive. Functions may be required to have a certain signature.
# -Wno-declaration-after-statement: our C standard supports declaration after statements
WARNING_CFLAGS += -Wno-unused-parameter -Wno-declaration-after-statement
# When compiler is *explicitly* set to clang, use its -Weverything option by
# default but disable the sepcific options we cannot support:
#
# -Wno-reserved-id-macro: our header files use __XXX___ protection macros.
# -Wno-padded: padding warnings
# -Wno-packed: warning about packed structure we want to keep that way
# -Wno-covered-switch-default
# -Wno-used-but-marked-unused
#
ifneq ($(CLANG),)
WARNING_CFLAGS += -Weverything \
-Wno-reserved-id-macro -Wno-padded \
-Wno-packed -Wno-covered-switch-default \
-Wno-used-but-marked-unused -Wno-switch-enum
# Add warnings if we are in pedantic mode
ifeq ($(PEDANTIC),1)
WARNING_CFLAGS += -Walloca -Wcast-qual -Wnull-dereference -Wstack-protector -Wvla -Warray-bounds -Warray-bounds-pointer-arithmetic -Wassign-enum -Wbad-function-cast -Wconditional-uninitialized -Wfloat-equal -Wformat-type-confusion -Widiomatic-parentheses -Wimplicit-fallthrough -Wloop-analysis -Wpointer-arith -Wshift-sign-overflow -Wshorten-64-to-32 -Wtautological-constant-in-range-compare -Wunreachable-code-aggressive -Wthread-safety -Wthread-safety-beta -Wcomma
endif
ifeq ($(CLANG_VERSION_GTE_13), true)
# We have to do this because the '_' prefix seems now reserved to builtins
WARNING_CFLAGS += -Wno-reserved-identifier
endif
ifeq ($(CLANG_VERSION_GTE_16), true)
# NOTE: XXX: this is really a shame to remove this, but
# we have to wait until this is less sensitive and false positive
# prone to use it!
WARNING_CFLAGS += -Wno-unsafe-buffer-usage
endif
else
WARNING_CFLAGS += -W -Wextra -Wall -Wunreachable-code
# Add warnings if we are in pedantic mode
ifeq ($(PEDANTIC),1)
WARNING_CFLAGS += -Wpedantic -Wformat-overflow=2 -Wformat-truncation=2 -Wnull-dereference -Wstack-protector -Wtrampolines -Walloca -Wvla -Warray-bounds=2 -Wimplicit-fallthrough=3 -Wshift-overflow=2 -Wcast-qual -Wstringop-overflow=4 -Warith-conversion -Wlogical-op -Wduplicated-cond -Wduplicated-branches -Wformat-signedness -Wstrict-overflow=2 -Wundef -Wstrict-prototypes -Wswitch-default -Wcast-align=strict -Wjump-misses-init
endif
endif
ifeq ($(WNOERROR), 1)
# Sometimes "-Werror" might be too much, this can be overriden
WARNING_CFLAGS := $(subst -Werror,,$(WARNING_CFLAGS))
endif
# If the user has overridden the CFLAGS or LDFLAGS, let's detect it
# and adapt our compilation process
ifdef CFLAGS
USER_DEFINED_CFLAGS = $(CFLAGS)
endif
ifdef LDFLAGS
USER_DEFINED_LDFLAGS = $(LDFLAGS)
endif
CFLAGS ?= $(WARNING_CFLAGS) $(SYS_ROOT) -pedantic -fno-builtin -std=c99 \
$(FORTIFY_FLAGS) $(STACK_PROT_FLAG) -O3
LDFLAGS ?=
# Default AR and RANLIB if not overriden by user
AR ?= ar
RANLIB ?= ranlib
# Default AR flags and RANLIB flags if not overriden by user
AR_FLAGS ?= rcs
RANLIB_FLAGS ?=
# Our debug flags
DEBUG_CFLAGS = -DDEBUG -O -g
ifeq ($(VERBOSE_INNER_VALUES),1)
CFLAGS += -DVERBOSE_INNER_VALUES
endif
# Default all and clean target that will be expanded
# later in the Makefile
all:
clean:
debug: CFLAGS += $(DEBUG_CFLAGS)
debug: clean all
# Force 64-bit word size
64: CFLAGS += -DWORDSIZE=64
64: clean all
debug64: CFLAGS += -DWORDSIZE=64 $(DEBUG_CFLAGS)
debug64: clean all
# Force 32-bit word size
32: CFLAGS += -DWORDSIZE=32
32: clean all
debug32: CFLAGS += -DWORDSIZE=32 $(DEBUG_CFLAGS)
debug32: clean all
# Force 16-bit word size
16: CFLAGS += -DWORDSIZE=16
16: clean all
debug16: CFLAGS += -DWORDSIZE=16 $(DEBUG_CFLAGS)
debug16: clean all
# Force to compile with 64-bit arch
force_arch64: CFLAGS += -m64
force_arch64: clean all
# Force to compile with 32-bit arch
force_arch32: CFLAGS += -m32
force_arch32: clean all
# By default, we use an stdlib
ifneq ($(LIBECC_NOSTDLIB),1)
CFLAGS += -DWITH_STDLIB
endif
# Let's now define the two kinds of CFLAGS we will use for building our
# library (LIB_CFLAGS) and binaries (BIN_CFLAGS) objects.
# If the user has not overriden the CFLAGS, we add the usual gcc/clang
# flags to produce binaries compatible with hardening technologies.
ifndef USER_DEFINED_CFLAGS
BIN_CFLAGS ?= $(CFLAGS) $(FPIE_CFLAG) -MMD -MP
LIB_CFLAGS ?= $(CFLAGS) $(FPIC_CFLAG) -MMD -MP -ffreestanding
else
BIN_CFLAGS ?= $(USER_DEFINED_CFLAGS)
LIB_CFLAGS ?= $(USER_DEFINED_CFLAGS)
endif
ifndef USER_DEFINED_LDFLAGS
BIN_LDFLAGS ?= $(LDFLAGS) $(FPIE_LDFLAGS)
else
BIN_LDFLAGS ?= $(USER_DEFINED_LDFLAGS)
endif
# If the user wants to add extra flags to the existing flags,
# check it and add them
ifdef EXTRA_LIB_CFLAGS
LIB_CFLAGS += $(EXTRA_LIB_CFLAGS)
endif
ifdef EXTRA_LIB_DYN_LDFLAGS
LIB_DYN_LDFLAGS += $(EXTRA_LIB_DYN_LDFLAGS)
endif
ifdef EXTRA_BIN_CFLAGS
BIN_CFLAGS += $(EXTRA_BIN_CFLAGS)
endif
ifdef EXTRA_BIN_LDFLAGS
BIN_LDFLAGS += $(EXTRA_BIN_LDFLAGS)
endif
ifdef EXTRA_CFLAGS
CFLAGS += $(EXTRA_CFLAGS)
endif
ifdef EXTRA_LDFLAGS
LDFLAGS += $(EXTRA_LDFLAGS)
endif
# Add the include folder
LIBECC_INCLUDE_FOLDER = include/
LIB_CFLAGS += -I$(LIBECC_INCLUDE_FOLDER)
BIN_CFLAGS += -I$(LIBECC_INCLUDE_FOLDER)
# Static libraries to produce or link to
LIBARITH = $(BUILD_DIR)/libarith.a
LIBEC = $(BUILD_DIR)/libec.a
LIBSIGN = $(BUILD_DIR)/libsign.a
# Compile dynamic libraries if the user asked to
ifeq ($(WITH_DYNAMIC_LIBS),1)
# Dynamic libraries to produce or link to
LIBARITH_DYN = $(BUILD_DIR)/libarith.so
LIBEC_DYN = $(BUILD_DIR)/libec.so
LIBSIGN_DYN = $(BUILD_DIR)/libsign.so
# The ld flags to generate shared librarie
ifeq ($(APPLE),)
LIB_DYN_LDFLAGS ?= -shared -Wl,-undefined,dynamic_lookup
else
LIB_DYN_LDFLAGS ?= -shared -Wl,-z,relro,-z,now
endif
endif
# Do we want to use blinding to secure signature against some side channels?
ifeq ($(BLINDING),1)
CFLAGS += -DUSE_SIG_BLINDING
endif
# Use complete formulas for point addition and doubling
# NOTE: complete formulas are used as default since they are
# more resilient against side channel attacks and they do not
# have a major performance impact
ifeq ($(COMPLETE),0)
CFLAGS += -DNO_USE_COMPLETE_FORMULAS
endif
# Force Double and Add always usage
ifeq ($(ADALWAYS), 1)
CFLAGS += -DUSE_DOUBLE_ADD_ALWAYS
endif
ifeq ($(ADALWAYS), 0)
CFLAGS += -DUSE_MONTY_LADDER
endif
# Force Montgomery Ladder always usage
ifeq ($(LADDER), 1)
CFLAGS += -DUSE_MONTY_LADDER
endif
ifeq ($(LADDER), 0)
CFLAGS += -DUSE_DOUBLE_ADD_ALWAYS
endif
# Force small stack usage
ifeq ($(SMALLSTACK), 1)
CFLAGS += -DUSE_SMALL_STACK
endif
# Are we sure we will not execute known
# vectors self tests?
ifeq ($(NOKNOWNTESTS), 1)
CFLAGS += -DNO_KNOWN_VECTORS
endif
# Specific version for fuzzing with Cryptofuzz
# Allow raw signature and verification APIs
# which is DANGEROUS. Do not activate in production
# mode!
ifeq ($(CRYPTOFUZZ), 1)
CFLAGS += -DUSE_CRYPTOFUZZ
endif
ifeq ($(ASSERT_PRINT), 1)
CFLAGS += -DUSE_ASSERT_PRINT
endif
# By default, we want to catch all unused functions return values by
# triggering a warning. We deactivate this is we are asked to by the user.
ifneq ($(NO_WARN_UNUSED_RET), 1)
CFLAGS += -DUSE_WARN_UNUSED_RET
endif
# Do we want to use clang or gcc sanitizers?
ifeq ($(USE_SANITIZERS),1)
CFLAGS += -fsanitize=undefined -fsanitize=address -fsanitize=leak
ifneq ($(CLANG),)
# Clang version < 12 do not support unsigned-shift-base
ifeq ($(CLANG_VERSION_GTE_12), true)
CFLAGS += -fsanitize=integer -fno-sanitize=unsigned-integer-overflow -fno-sanitize=unsigned-shift-base
endif
endif
endif
# Do we want to use the ISO14888-3 version of the
# ECRDSA algorithm with discrepancies from the Russian
# RFC references?
ifeq ($(USE_ISO14888_3_ECRDSA),1)
CFLAGS += -DUSE_ISO14888_3_ECRDSA
endif
# Do we have a C++ compiler instead of a C compiler?
GPP := $(shell $(CROSS_COMPILE)$(CC) -v 2>&1 | grep g++)
CLANGPP := $(shell echo $(CROSS_COMPILE)$(CC) | grep clang++)
# g++ case
ifneq ($(GPP),)
CFLAGS := $(patsubst -std=c99, -std=c++2a, $(CFLAGS))
CFLAGS += -Wno-deprecated
# Remove C++ unused pedantic flags
CFLAGS := $(patsubst -Wstrict-prototypes,,$(CFLAGS))
CFLAGS := $(patsubst -Wjump-misses-init,,$(CFLAGS))
CFLAGS := $(patsubst -Wduplicated-branches,,$(CFLAGS))
CFLAGS := $(patsubst -Wno-declaration-after-statement,,$(CFLAGS))
endif
# clang++ case
ifneq ($(CLANGPP),)
CFLAGS := $(patsubst -std=c99, -std=c++2a, $(CFLAGS))
CFLAGS += -Wno-deprecated -Wno-c++98-c++11-c++14-c++17-compat-pedantic -Wno-old-style-cast -Wno-zero-as-null-pointer-constant -Wno-c++98-compat-pedantic
endif
# Makefile verbosity
ifeq ($(VERBOSE),1)
VERBOSE_MAKE=
else
VERBOSE_MAKE=@
endif
# Self tests parallelization
ifeq ($(OPENMP_SELF_TESTS),1)
CFLAGS += -DWITH_OPENMP_SELF_TESTS -fopenmp
LDFLAGS += -fopenmp
endif

View file

@ -0,0 +1,136 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __AFF_PT_H__
#define __AFF_PT_H__
#include <libecc/fp/fp.h>
#include <libecc/fp/fp_sqrt.h>
#include <libecc/curves/ec_shortw.h>
#include <libecc/curves/ec_montgomery.h>
#include <libecc/curves/ec_edwards.h>
typedef struct {
fp x;
fp y;
ec_shortw_crv_src_t crv;
word_t magic;
} aff_pt;
typedef aff_pt *aff_pt_t;
typedef const aff_pt_t aff_pt_src_t;
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_check_initialized(aff_pt_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_init(aff_pt_t in, ec_shortw_crv_src_t curve);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_init_from_coords(aff_pt_t in,
ec_shortw_crv_src_t curve,
fp_src_t xcoord, fp_src_t ycoord);
void aff_pt_uninit(aff_pt_t in);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_y_from_x(fp_t y1, fp_t y2, fp_src_t x, ec_shortw_crv_src_t curve);
ATTRIBUTE_WARN_UNUSED_RET int is_on_shortw_curve(fp_src_t x, fp_src_t y, ec_shortw_crv_src_t curve, int *on_curve);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_is_on_curve(aff_pt_src_t pt, int *on_curve);
ATTRIBUTE_WARN_UNUSED_RET int ec_shortw_aff_copy(aff_pt_t out, aff_pt_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int ec_shortw_aff_cmp(aff_pt_src_t in1, aff_pt_src_t in2, int *cmp);
ATTRIBUTE_WARN_UNUSED_RET int ec_shortw_aff_eq_or_opp(aff_pt_src_t in1, aff_pt_src_t in2,
int *eq_or_opp);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_import_from_buf(aff_pt_t pt,
const u8 *pt_buf,
u16 pt_buf_len, ec_shortw_crv_src_t crv);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_export_to_buf(aff_pt_src_t pt, u8 *pt_buf, u32 pt_buf_len);
/*** Edwards curves related ***/
typedef struct {
fp x;
fp y;
ec_edwards_crv_src_t crv;
word_t magic;
} aff_pt_edwards;
typedef aff_pt_edwards *aff_pt_edwards_t;
typedef const aff_pt_edwards_t aff_pt_edwards_src_t;
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_edwards_check_initialized(aff_pt_edwards_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_edwards_init(aff_pt_edwards_t in, ec_edwards_crv_src_t curve);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_edwards_init_from_coords(aff_pt_edwards_t in,
ec_edwards_crv_src_t curve,
fp_src_t ucoord, fp_src_t vcoord);
void aff_pt_edwards_uninit(aff_pt_edwards_t in);
ATTRIBUTE_WARN_UNUSED_RET int is_on_edwards_curve(fp_src_t u, fp_src_t v, ec_edwards_crv_src_t curve, int *on_curve);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_edwards_is_on_curve(aff_pt_edwards_src_t pt, int *on_curve);
ATTRIBUTE_WARN_UNUSED_RET int ec_edwards_aff_copy(aff_pt_edwards_t out, aff_pt_edwards_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int ec_edwards_aff_cmp(aff_pt_edwards_src_t in1, aff_pt_edwards_src_t in2, int *cmp);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_edwards_import_from_buf(aff_pt_edwards_t pt,
const u8 *pt_buf,
u16 pt_buf_len, ec_edwards_crv_src_t crv);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_edwards_export_to_buf(aff_pt_edwards_src_t pt, u8 *pt_buf, u32 pt_buf_len);
ATTRIBUTE_WARN_UNUSED_RET int curve_edwards_to_montgomery(ec_edwards_crv_src_t edwards_crv, ec_montgomery_crv_t montgomery_crv, fp_src_t alpha_edwards);
ATTRIBUTE_WARN_UNUSED_RET int curve_edwards_montgomery_check(ec_edwards_crv_src_t edwards_crv, ec_montgomery_crv_src_t montgomery_crv, fp_src_t alpha_edwards);
ATTRIBUTE_WARN_UNUSED_RET int curve_montgomery_to_edwards(ec_montgomery_crv_src_t montgomery_crv, ec_edwards_crv_t edwards_crv, fp_src_t alpha_edwards);
ATTRIBUTE_WARN_UNUSED_RET int curve_edwards_to_shortw(ec_edwards_crv_src_t edwards_crv, ec_shortw_crv_t shortw_crv, fp_src_t alpha_edwards);
ATTRIBUTE_WARN_UNUSED_RET int curve_edwards_shortw_check(ec_edwards_crv_src_t edwards_crv, ec_shortw_crv_src_t shortw_crv, fp_src_t alpha_edwards);
ATTRIBUTE_WARN_UNUSED_RET int curve_shortw_to_edwards(ec_shortw_crv_src_t shortw_crv, ec_edwards_crv_t edwards_crv, fp_src_t alpha_montgomery, fp_src_t gamma_montgomery, fp_src_t alpha_edwards);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_edwards_to_shortw(aff_pt_edwards_src_t in_edwards, ec_shortw_crv_src_t shortw_crv, aff_pt_t out_shortw, fp_src_t alpha_edwards);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_shortw_to_edwards(aff_pt_src_t in_shortw, ec_edwards_crv_src_t edwards_crv, aff_pt_edwards_t out_edwards, fp_src_t alpha_edwards);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_edwards_y_from_x(fp_t y1, fp_t y2, fp_src_t x, ec_edwards_crv_src_t crv);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_edwards_x_from_y(fp_t x1, fp_t x2, fp_src_t y, ec_edwards_crv_src_t crv);
/*** Montgomery curves related ***/
typedef struct {
fp u;
fp v;
ec_montgomery_crv_src_t crv;
word_t magic;
} aff_pt_montgomery;
typedef aff_pt_montgomery *aff_pt_montgomery_t;
typedef const aff_pt_montgomery_t aff_pt_montgomery_src_t;
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_montgomery_check_initialized(aff_pt_montgomery_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_montgomery_init(aff_pt_montgomery_t in, ec_montgomery_crv_src_t curve);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_montgomery_init_from_coords(aff_pt_montgomery_t in,
ec_montgomery_crv_src_t curve,
fp_src_t ucoord, fp_src_t vcoord);
void aff_pt_montgomery_uninit(aff_pt_montgomery_t in);
ATTRIBUTE_WARN_UNUSED_RET int is_on_montgomery_curve(fp_src_t u, fp_src_t v, ec_montgomery_crv_src_t curve, int *on_curve);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_montgomery_is_on_curve(aff_pt_montgomery_src_t pt, int *on_curve);
ATTRIBUTE_WARN_UNUSED_RET int ec_montgomery_aff_copy(aff_pt_montgomery_t out, aff_pt_montgomery_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int ec_montgomery_aff_cmp(aff_pt_montgomery_src_t in1, aff_pt_montgomery_src_t in2, int *cmp);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_montgomery_import_from_buf(aff_pt_montgomery_t pt,
const u8 *pt_buf,
u16 pt_buf_len, ec_montgomery_crv_src_t crv);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_montgomery_export_to_buf(aff_pt_montgomery_src_t pt, u8 *pt_buf, u32 pt_buf_len);
ATTRIBUTE_WARN_UNUSED_RET int curve_montgomery_to_shortw(ec_montgomery_crv_src_t montgomery_crv, ec_shortw_crv_t shortw_crv);
ATTRIBUTE_WARN_UNUSED_RET int curve_montgomery_shortw_check(ec_montgomery_crv_src_t montgomery_crv, ec_shortw_crv_src_t shortw_crv);
ATTRIBUTE_WARN_UNUSED_RET int curve_shortw_to_montgomery(ec_shortw_crv_src_t shortw_crv, ec_montgomery_crv_t montgomery_crv, fp_src_t alpha_montgomery, fp_src_t gamma_montgomery);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_montgomery_to_shortw(aff_pt_montgomery_src_t in_montgomery, ec_shortw_crv_src_t shortw_crv, aff_pt_t out_shortw);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_shortw_to_montgomery(aff_pt_src_t in_shortw, ec_montgomery_crv_src_t montgomery_crv, aff_pt_montgomery_t out_montgomery);
/*****/
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_edwards_to_montgomery(aff_pt_edwards_src_t in_edwards, ec_montgomery_crv_src_t montgomery_crv, aff_pt_montgomery_t out_montgomery, fp_src_t alpha);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_montgomery_to_edwards(aff_pt_montgomery_src_t in_montgomery, ec_edwards_crv_src_t edwards_crv, aff_pt_edwards_t out_edwards, fp_src_t alpha);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_montgomery_v_from_u(fp_t v1, fp_t v2, fp_src_t u, ec_montgomery_crv_src_t crv);
#endif /* __AFF_PT_H__ */

View file

@ -0,0 +1,31 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __CURVES_H__
#define __CURVES_H__
#include <libecc/curves/ec_params.h>
ATTRIBUTE_WARN_UNUSED_RET int ec_get_curve_params_by_name(const u8 *ec_name, u8 ec_name_len,
const ec_str_params **ec_params);
ATTRIBUTE_WARN_UNUSED_RET int ec_get_curve_params_by_type(ec_curve_type ec_type,
const ec_str_params **ec_params);
ATTRIBUTE_WARN_UNUSED_RET int ec_get_curve_type_by_name(const u8 *ec_name, u8 ec_name_len,
ec_curve_type *ec_type);
ATTRIBUTE_WARN_UNUSED_RET int ec_get_curve_name_by_type(const ec_curve_type ec_type, u8 *out, u8 outlen);
ATTRIBUTE_WARN_UNUSED_RET int ec_check_curve_type_and_name(const ec_curve_type ec_type,
const u8 *ec_name, u8 ec_name_len);
#endif /* __CURVES_H__ */

View file

@ -0,0 +1,248 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __CURVES_LIST_H__
#define __CURVES_LIST_H__
#include <libecc/lib_ecc_config.h>
#include <libecc/lib_ecc_types.h>
#include <libecc/words/words.h>
#include <libecc/curves/known/ec_params_brainpoolp192r1.h>
#include <libecc/curves/known/ec_params_brainpoolp224r1.h>
#include <libecc/curves/known/ec_params_brainpoolp256r1.h>
#include <libecc/curves/known/ec_params_brainpoolp384r1.h>
#include <libecc/curves/known/ec_params_brainpoolp512r1.h>
#include <libecc/curves/known/ec_params_secp192r1.h>
#include <libecc/curves/known/ec_params_secp224r1.h>
#include <libecc/curves/known/ec_params_secp256r1.h>
#include <libecc/curves/known/ec_params_secp384r1.h>
#include <libecc/curves/known/ec_params_secp521r1.h>
#include <libecc/curves/known/ec_params_frp256v1.h>
#include <libecc/curves/known/ec_params_gost256.h>
#include <libecc/curves/known/ec_params_gost512.h>
#include <libecc/curves/known/ec_params_sm2p192test.h>
#include <libecc/curves/known/ec_params_sm2p256test.h>
#include <libecc/curves/known/ec_params_sm2p256v1.h>
#include <libecc/curves/known/ec_params_wei25519.h>
#include <libecc/curves/known/ec_params_wei448.h>
#include <libecc/curves/known/ec_params_gost_R3410_2012_256_paramSetA.h>
#include <libecc/curves/known/ec_params_secp256k1.h>
#include <libecc/curves/known/ec_params_gost_R3410_2001_TestParamSet.h>
#include <libecc/curves/known/ec_params_gost_R3410_2001_CryptoPro_A_ParamSet.h>
#include <libecc/curves/known/ec_params_gost_R3410_2001_CryptoPro_B_ParamSet.h>
#include <libecc/curves/known/ec_params_gost_R3410_2001_CryptoPro_C_ParamSet.h>
#include <libecc/curves/known/ec_params_gost_R3410_2001_CryptoPro_XchA_ParamSet.h>
#include <libecc/curves/known/ec_params_gost_R3410_2001_CryptoPro_XchB_ParamSet.h>
#include <libecc/curves/known/ec_params_gost_R3410_2012_256_paramSetA.h>
#include <libecc/curves/known/ec_params_gost_R3410_2012_256_paramSetB.h>
#include <libecc/curves/known/ec_params_gost_R3410_2012_256_paramSetC.h>
#include <libecc/curves/known/ec_params_gost_R3410_2012_256_paramSetD.h>
#include <libecc/curves/known/ec_params_gost_R3410_2012_512_paramSetTest.h>
#include <libecc/curves/known/ec_params_gost_R3410_2012_512_paramSetA.h>
#include <libecc/curves/known/ec_params_gost_R3410_2012_512_paramSetB.h>
#include <libecc/curves/known/ec_params_gost_R3410_2012_512_paramSetC.h>
#include <libecc/curves/known/ec_params_secp192k1.h>
#include <libecc/curves/known/ec_params_secp224k1.h>
#include <libecc/curves/known/ec_params_brainpoolp192t1.h>
#include <libecc/curves/known/ec_params_brainpoolp224t1.h>
#include <libecc/curves/known/ec_params_brainpoolp256t1.h>
#include <libecc/curves/known/ec_params_brainpoolp320r1.h>
#include <libecc/curves/known/ec_params_brainpoolp320t1.h>
#include <libecc/curves/known/ec_params_brainpoolp384t1.h>
#include <libecc/curves/known/ec_params_brainpoolp512t1.h>
#include <libecc/curves/known/ec_params_bign256v1.h>
#include <libecc/curves/known/ec_params_bign384v1.h>
#include <libecc/curves/known/ec_params_bign512v1.h>
/* ADD curves header here */
/* XXX: Do not remove the comment above, as it is
* used by external tools as a placeholder to add or
* remove automatically generated code.
*/
#ifndef CURVES_MAX_P_BIT_LEN
#error "Max p bit length is 0; did you disable all curves in lib_ecc_config.h?"
#endif
#if (CURVES_MAX_P_BIT_LEN > 65535)
#error "Prime field length (in bytes) MUST fit on an u16!"
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#error "Max q bit length is 0; did you disable all curves in lib_ecc_config.h?"
#endif
#if (CURVES_MAX_Q_BIT_LEN > 65535)
#error "Generator order length (in bytes) MUST fit on an u16!"
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#error "Max curve order bit length is 0; did you disable all curves in lib_ecc_config.h?"
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN > 65535)
#error "Curve order length (in bytes) MUST fit on an u16!"
#endif
typedef struct {
ec_curve_type type;
const ec_str_params *params;
} ec_mapping;
static const ec_mapping ec_maps[] = {
#ifdef WITH_CURVE_FRP256V1
{.type = FRP256V1,.params = &frp256v1_str_params},
#endif /* WITH_CURVE_FRP256V1 */
#ifdef WITH_CURVE_SECP192R1
{.type = SECP192R1,.params = &secp192r1_str_params},
#endif /* WITH_CURVE_SECP192R1 */
#ifdef WITH_CURVE_SECP224R1
{.type = SECP224R1,.params = &secp224r1_str_params},
#endif /* WITH_CURVE_SECP224R1 */
#ifdef WITH_CURVE_SECP256R1
{.type = SECP256R1,.params = &secp256r1_str_params},
#endif /* WITH_CURVE_SECP256R1 */
#ifdef WITH_CURVE_SECP384R1
{.type = SECP384R1,.params = &secp384r1_str_params},
#endif /* WITH_CURVE_SECP384R1 */
#ifdef WITH_CURVE_SECP521R1
{.type = SECP521R1,.params = &secp521r1_str_params},
#endif /* WITH_CURVE_SECP521R1 */
#ifdef WITH_CURVE_BRAINPOOLP192R1
{.type = BRAINPOOLP192R1,.params = &brainpoolp192r1_str_params},
#endif /* WITH_CURVE_BRAINPOOLP192R1 */
#ifdef WITH_CURVE_BRAINPOOLP224R1
{.type = BRAINPOOLP224R1,.params = &brainpoolp224r1_str_params},
#endif /* WITH_CURVE_BRAINPOOLP224R1 */
#ifdef WITH_CURVE_BRAINPOOLP256R1
{.type = BRAINPOOLP256R1,.params = &brainpoolp256r1_str_params},
#endif /* WITH_CURVE_BRAINPOOLP256R1 */
#ifdef WITH_CURVE_BRAINPOOLP384R1
{.type = BRAINPOOLP384R1,.params = &brainpoolp384r1_str_params},
#endif /* WITH_CURVE_BRAINPOOLP384R1 */
#ifdef WITH_CURVE_BRAINPOOLP512R1
{.type = BRAINPOOLP512R1,.params = &brainpoolp512r1_str_params},
#endif /* WITH_CURVE_BRAINPOOLP512R1 */
#ifdef WITH_CURVE_GOST256
{.type = GOST256,.params = &GOST_256bits_curve_str_params},
#endif /* WITH_CURVE_GOST256 */
#ifdef WITH_CURVE_GOST512
{.type = GOST512,.params = &GOST_512bits_curve_str_params},
#endif /* WITH_CURVE_GOST512 */
#ifdef WITH_CURVE_SM2P256TEST
{.type = SM2P256TEST,.params = &sm2p256test_str_params},
#endif /* WITH_CURVE_SM2P256TEST */
#ifdef WITH_CURVE_SM2P256V1
{.type = SM2P256V1,.params = &sm2p256v1_str_params},
#endif /* WITH_CURVE_SM2P256V1 */
#ifdef WITH_CURVE_WEI25519
{.type = WEI25519,.params = &wei25519_str_params},
#endif /* WITH_CURVE_WEI25519 */
#ifdef WITH_CURVE_WEI448
{.type = WEI448,.params = &wei448_str_params},
#endif /* WITH_CURVE_WEI448 */
#ifdef WITH_CURVE_GOST_R3410_2012_256_PARAMSETA
{ .type = GOST_R3410_2012_256_PARAMSETA, .params = &gost_R3410_2012_256_paramSetA_str_params },
#endif /* WITH_CURVE_GOST_R3410_2012_256_PARAMSETA */
#ifdef WITH_CURVE_SECP256K1
{.type = SECP256K1,.params = &secp256k1_str_params},
#endif /* WITH_CURVE_SECP256K1 */
#ifdef WITH_CURVE_GOST_R3410_2001_TESTPARAMSET
{ .type = GOST_R3410_2001_TESTPARAMSET, .params = &gost_R3410_2001_TestParamSet_str_params },
#endif /* WITH_CURVE_GOST_R3410_2001_TESTPARAMSET */
#ifdef WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET
{ .type = GOST_R3410_2001_CRYPTOPRO_A_PARAMSET, .params = &gost_R3410_2001_CryptoPro_A_ParamSet_str_params },
#endif /* WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET */
#ifdef WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET
{ .type = GOST_R3410_2001_CRYPTOPRO_B_PARAMSET, .params = &gost_R3410_2001_CryptoPro_B_ParamSet_str_params },
#endif /* WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET */
#ifdef WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET
{ .type = GOST_R3410_2001_CRYPTOPRO_C_PARAMSET, .params = &gost_R3410_2001_CryptoPro_C_ParamSet_str_params },
#endif /* WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET */
#ifdef WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET
{ .type = GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET, .params = &gost_R3410_2001_CryptoPro_XchA_ParamSet_str_params },
#endif /* WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET */
#ifdef WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET
{ .type = GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET, .params = &gost_R3410_2001_CryptoPro_XchB_ParamSet_str_params },
#endif /* WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET */
#ifdef WITH_CURVE_GOST_R3410_2012_256_PARAMSETA
{ .type = GOST_R3410_2012_256_PARAMSETA, .params = &gost_R3410_2012_256_paramSetA_str_params },
#endif /* WITH_CURVE_GOST_R3410_2012_256_PARAMSETA */
#ifdef WITH_CURVE_GOST_R3410_2012_256_PARAMSETB
{ .type = GOST_R3410_2012_256_PARAMSETB, .params = &gost_R3410_2012_256_paramSetB_str_params },
#endif /* WITH_CURVE_GOST_R3410_2012_256_PARAMSETB */
#ifdef WITH_CURVE_GOST_R3410_2012_256_PARAMSETC
{ .type = GOST_R3410_2012_256_PARAMSETC, .params = &gost_R3410_2012_256_paramSetC_str_params },
#endif /* WITH_CURVE_GOST_R3410_2012_256_PARAMSETC */
#ifdef WITH_CURVE_GOST_R3410_2012_256_PARAMSETD
{ .type = GOST_R3410_2012_256_PARAMSETD, .params = &gost_R3410_2012_256_paramSetD_str_params },
#endif /* WITH_CURVE_GOST_R3410_2012_256_PARAMSETD */
#ifdef WITH_CURVE_GOST_R3410_2012_512_PARAMSETTEST
{ .type = GOST_R3410_2012_512_PARAMSETTEST, .params = &gost_R3410_2012_512_paramSetTest_str_params },
#endif /* WITH_CURVE_GOST_R3410_2012_512_PARAMSETTEST */
#ifdef WITH_CURVE_GOST_R3410_2012_512_PARAMSETA
{ .type = GOST_R3410_2012_512_PARAMSETA, .params = &gost_R3410_2012_512_paramSetA_str_params },
#endif /* WITH_CURVE_GOST_R3410_2012_512_PARAMSETA */
#ifdef WITH_CURVE_GOST_R3410_2012_512_PARAMSETB
{ .type = GOST_R3410_2012_512_PARAMSETB, .params = &gost_R3410_2012_512_paramSetB_str_params },
#endif /* WITH_CURVE_GOST_R3410_2012_512_PARAMSETB */
#ifdef WITH_CURVE_GOST_R3410_2012_512_PARAMSETC
{ .type = GOST_R3410_2012_512_PARAMSETC, .params = &gost_R3410_2012_512_paramSetC_str_params },
#endif /* WITH_CURVE_GOST_R3410_2012_512_PARAMSETC */
#ifdef WITH_CURVE_SECP192K1
{.type = SECP192K1,.params = &secp192k1_str_params},
#endif /* WITH_CURVE_SECP192K1 */
#ifdef WITH_CURVE_SECP224K1
{.type = SECP224K1,.params = &secp224k1_str_params},
#endif /* WITH_CURVE_SECP224K1 */
#ifdef WITH_CURVE_BRAINPOOLP192T1
{.type = BRAINPOOLP192T1,.params = &brainpoolp192t1_str_params},
#endif /* WITH_CURVE_BRAINPOOLP192T1 */
#ifdef WITH_CURVE_BRAINPOOLP224T1
{.type = BRAINPOOLP224T1,.params = &brainpoolp224t1_str_params},
#endif /* WITH_CURVE_BRAINPOOLP224T1 */
#ifdef WITH_CURVE_BRAINPOOLP256T1
{.type = BRAINPOOLP256T1,.params = &brainpoolp256t1_str_params},
#endif /* WITH_CURVE_BRAINPOOLP256T1 */
#ifdef WITH_CURVE_BRAINPOOLP320R1
{.type = BRAINPOOLP320R1,.params = &brainpoolp320r1_str_params},
#endif /* WITH_CURVE_BRAINPOOLP320R1 */
#ifdef WITH_CURVE_BRAINPOOLP320T1
{.type = BRAINPOOLP320T1,.params = &brainpoolp320t1_str_params},
#endif /* WITH_CURVE_BRAINPOOLP320T1 */
#ifdef WITH_CURVE_BRAINPOOLP384T1
{.type = BRAINPOOLP384T1,.params = &brainpoolp384t1_str_params},
#endif /* WITH_CURVE_BRAINPOOLP192T1 */
#ifdef WITH_CURVE_BRAINPOOLP512T1
{.type = BRAINPOOLP512T1,.params = &brainpoolp512t1_str_params},
#endif /* WITH_CURVE_BRAINPOOLP512T1 */
#ifdef WITH_CURVE_BIGN256V1
{.type = BIGN256V1,.params = &bign256v1_str_params},
#endif /* WITH_CURVE_BIGN256V1 */
#ifdef WITH_CURVE_BIGN384V1
{.type = BIGN384V1,.params = &bign384v1_str_params},
#endif /* WITH_CURVE_BIGN384V1 */
#ifdef WITH_CURVE_BIGN512V1
{.type = BIGN512V1,.params = &bign512v1_str_params},
#endif /* WITH_CURVE_BIGN512V1 */
/* ADD curves mapping here */
/* XXX: Do not remove the comment above, as it is
* used by external tools as a placeholder to add or
* remove automatically generated code.
*/
};
/*
* Number of cuvres supported by the lib, i.e. number of elements in
* ec_maps array above.
*/
#define EC_CURVES_NUM (sizeof(ec_maps) / sizeof(ec_mapping))
#endif /* __CURVES_LIST_H__ */

View file

@ -0,0 +1,39 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __EC_EDWARDS_H__
#define __EC_EDWARDS_H__
#include <libecc/nn/nn.h>
#include <libecc/fp/fp.h>
#include <libecc/fp/fp_add.h>
#include <libecc/fp/fp_mul.h>
#include <libecc/fp/fp_mul_redc1.h>
typedef struct {
fp a;
fp d;
nn order;
word_t magic;
} ec_edwards_crv;
typedef ec_edwards_crv *ec_edwards_crv_t;
typedef const ec_edwards_crv *ec_edwards_crv_src_t;
ATTRIBUTE_WARN_UNUSED_RET int ec_edwards_crv_check_initialized(ec_edwards_crv_src_t crv);
ATTRIBUTE_WARN_UNUSED_RET int ec_edwards_crv_init(ec_edwards_crv_t crv, fp_src_t a, fp_src_t b, nn_src_t order);
void ec_edwards_crv_uninit(ec_edwards_crv_t crv);
#endif /* __EC_EDWARDS_H__ */

View file

@ -0,0 +1,34 @@
/*
* Copyright (C) 2021 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __EC_MONTGOMERY_H__
#define __EC_MONTGOMERY_H__
#include <libecc/nn/nn.h>
#include <libecc/fp/fp.h>
#include <libecc/fp/fp_add.h>
#include <libecc/fp/fp_mul.h>
#include <libecc/fp/fp_mul_redc1.h>
typedef struct {
fp A;
fp B;
nn order;
word_t magic;
} ec_montgomery_crv;
typedef ec_montgomery_crv *ec_montgomery_crv_t;
typedef const ec_montgomery_crv *ec_montgomery_crv_src_t;
ATTRIBUTE_WARN_UNUSED_RET int ec_montgomery_crv_check_initialized(ec_montgomery_crv_src_t crv);
ATTRIBUTE_WARN_UNUSED_RET int ec_montgomery_crv_init(ec_montgomery_crv_t crv, fp_src_t a, fp_src_t b, nn_src_t order);
void ec_montgomery_crv_uninit(ec_montgomery_crv_t crv);
#endif /* __EC_MONTGOMERY_H__ */

View file

@ -0,0 +1,91 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __EC_PARAMS_H__
#define __EC_PARAMS_H__
#include <libecc/fp/fp.h>
#include <libecc/curves/prj_pt.h>
#include <libecc/curves/known/ec_params_external.h>
/* Info: this include is here because an update on
* MAX_CURVE_OID_LEN and MAX_CURVE_NAME_LEN can be done
* through preprocessing of the curves at compile time.
*/
#include <libecc/curves/curves_list.h>
/* These default sizes should be enough for the known curves */
#ifdef MAX_CURVE_NAME_LEN
#if (MAX_CURVE_OID_LEN < 32)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 32 /* including trailing 0 */
#endif
#else
#define MAX_CURVE_OID_LEN 32 /* including trailing 0 */
#endif
#ifdef MAX_CURVE_NAME_LEN
#if (MAX_CURVE_NAME_LEN < 32)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 32 /* including trailing 0 */
#endif
#else
#define MAX_CURVE_NAME_LEN 32
#endif
/*
* Elliptic curves parameters. We only support
* curves defined on prime fields (i.e. Fp,
* with p prime).
*/
typedef struct {
/* Fp */
fp_ctx ec_fp;
/* Curve */
ec_shortw_crv ec_curve;
/*
* Generator G defining our group, in projective
* coordinates.
*/
prj_pt ec_gen;
/* Number of points on group generated by G */
nn ec_gen_order;
bitcnt_t ec_gen_order_bitlen;
/* Curve cofactor */
nn ec_gen_cofactor;
#if !defined(USE_SMALL_STACK)
/* Optional transfer coefficients with Montgomery curves */
fp ec_alpha_montgomery;
fp ec_gamma_montgomery;
/* Optional transfer coefficient with Edwards curves */
fp ec_alpha_edwards;
#endif
/* Object Identifier for the curve */
u8 curve_oid[MAX_CURVE_OID_LEN];
/* Short name for the curve */
u8 curve_name[MAX_CURVE_NAME_LEN];
/* Type of the curve */
ec_curve_type curve_type;
} ec_params;
ATTRIBUTE_WARN_UNUSED_RET int import_params(ec_params *out_params, const ec_str_params *in_str_params);
#endif /* __EC_PARAMS_H__ */

View file

@ -0,0 +1,45 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __EC_SHORTW_H__
#define __EC_SHORTW_H__
#include <libecc/nn/nn.h>
#include <libecc/fp/fp.h>
#include <libecc/fp/fp_add.h>
#include <libecc/fp/fp_mul.h>
#include <libecc/fp/fp_mul_redc1.h>
typedef struct {
fp a;
fp b;
fp a_monty;
#ifndef NO_USE_COMPLETE_FORMULAS
fp b3;
fp b_monty;
fp b3_monty;
#endif
nn order; /* curve order */
word_t magic;
} ec_shortw_crv;
typedef ec_shortw_crv *ec_shortw_crv_t;
typedef const ec_shortw_crv *ec_shortw_crv_src_t;
ATTRIBUTE_WARN_UNUSED_RET int ec_shortw_crv_check_initialized(ec_shortw_crv_src_t crv);
ATTRIBUTE_WARN_UNUSED_RET int ec_shortw_crv_init(ec_shortw_crv_t crv, fp_src_t a, fp_src_t b, nn_src_t order);
void ec_shortw_crv_uninit(ec_shortw_crv_t crv);
#endif /* __EC_SHORTW_H__ */

View file

@ -0,0 +1,315 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_BIGN256V1
#ifndef __EC_PARAMS_BIGN256V1_H__
#define __EC_PARAMS_BIGN256V1_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 bign256v1_p[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x43,
};
TO_EC_STR_PARAM(bign256v1_p);
#define CURVE_BIGN256V1_P_BITLEN 256
static const u8 bign256v1_p_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(bign256v1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 bign256v1_r[] = {
0xbd,
};
TO_EC_STR_PARAM(bign256v1_r);
static const u8 bign256v1_r_square[] = {
0x8b, 0x89,
};
TO_EC_STR_PARAM(bign256v1_r_square);
static const u8 bign256v1_mpinv[] = {
0xa5, 0x3f, 0xa9, 0x4f, 0xea, 0x53, 0xfa, 0x95,
};
TO_EC_STR_PARAM(bign256v1_mpinv);
static const u8 bign256v1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(bign256v1_p_shift);
static const u8 bign256v1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x43,
};
TO_EC_STR_PARAM(bign256v1_p_normalized);
static const u8 bign256v1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(bign256v1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 bign256v1_r[] = {
0xbd,
};
TO_EC_STR_PARAM(bign256v1_r);
static const u8 bign256v1_r_square[] = {
0x8b, 0x89,
};
TO_EC_STR_PARAM(bign256v1_r_square);
static const u8 bign256v1_mpinv[] = {
0xea, 0x53, 0xfa, 0x95,
};
TO_EC_STR_PARAM(bign256v1_mpinv);
static const u8 bign256v1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(bign256v1_p_shift);
static const u8 bign256v1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x43,
};
TO_EC_STR_PARAM(bign256v1_p_normalized);
static const u8 bign256v1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(bign256v1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 bign256v1_r[] = {
0xbd,
};
TO_EC_STR_PARAM(bign256v1_r);
static const u8 bign256v1_r_square[] = {
0x8b, 0x89,
};
TO_EC_STR_PARAM(bign256v1_r_square);
static const u8 bign256v1_mpinv[] = {
0xfa, 0x95,
};
TO_EC_STR_PARAM(bign256v1_mpinv);
static const u8 bign256v1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(bign256v1_p_shift);
static const u8 bign256v1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x43,
};
TO_EC_STR_PARAM(bign256v1_p_normalized);
static const u8 bign256v1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(bign256v1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 bign256v1_a[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x40,
};
TO_EC_STR_PARAM(bign256v1_a);
static const u8 bign256v1_b[] = {
0x77, 0xce, 0x6c, 0x15, 0x15, 0xf3, 0xa8, 0xed,
0xd2, 0xc1, 0x3a, 0xab, 0xe4, 0xd8, 0xfb, 0xbe,
0x4c, 0xf5, 0x50, 0x69, 0x97, 0x8b, 0x92, 0x53,
0xb2, 0x2e, 0x7d, 0x6b, 0xd6, 0x9c, 0x03, 0xf1,
};
TO_EC_STR_PARAM(bign256v1_b);
#define CURVE_BIGN256V1_CURVE_ORDER_BITLEN 256
static const u8 bign256v1_curve_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xd9, 0x5c, 0x8e, 0xd6, 0x0d, 0xfb, 0x4d, 0xfc,
0x7e, 0x5a, 0xbf, 0x99, 0x26, 0x3d, 0x66, 0x07,
};
TO_EC_STR_PARAM(bign256v1_curve_order);
static const u8 bign256v1_gx[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
TO_EC_STR_PARAM(bign256v1_gx);
static const u8 bign256v1_gy[] = {
0x6b, 0xf7, 0xfc, 0x3c, 0xfb, 0x16, 0xd6, 0x9f,
0x5c, 0xe4, 0xc9, 0xa3, 0x51, 0xd6, 0x83, 0x5d,
0x78, 0x91, 0x39, 0x66, 0xc4, 0x08, 0xf6, 0x52,
0x1e, 0x29, 0xcf, 0x18, 0x04, 0x51, 0x6a, 0x93,
};
TO_EC_STR_PARAM(bign256v1_gy);
static const u8 bign256v1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(bign256v1_gz);
static const u8 bign256v1_gen_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xd9, 0x5c, 0x8e, 0xd6, 0x0d, 0xfb, 0x4d, 0xfc,
0x7e, 0x5a, 0xbf, 0x99, 0x26, 0x3d, 0x66, 0x07,
};
TO_EC_STR_PARAM(bign256v1_gen_order);
#define CURVE_BIGN256V1_Q_BITLEN 256
static const u8 bign256v1_gen_order_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(bign256v1_gen_order_bitlen);
static const u8 bign256v1_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(bign256v1_cofactor);
static const u8 bign256v1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(bign256v1_alpha_montgomery, 0);
static const u8 bign256v1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(bign256v1_gamma_montgomery, 0);
static const u8 bign256v1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(bign256v1_alpha_edwards, 0);
static const u8 bign256v1_name[] = "BIGN256V1";
TO_EC_STR_PARAM(bign256v1_name);
static const u8 bign256v1_oid[] = "1.2.112.0.2.0.34.101.45.3.1";
TO_EC_STR_PARAM(bign256v1_oid);
static const ec_str_params bign256v1_str_params = {
.p = &bign256v1_p_str_param,
.p_bitlen = &bign256v1_p_bitlen_str_param,
.r = &bign256v1_r_str_param,
.r_square = &bign256v1_r_square_str_param,
.mpinv = &bign256v1_mpinv_str_param,
.p_shift = &bign256v1_p_shift_str_param,
.p_normalized = &bign256v1_p_normalized_str_param,
.p_reciprocal = &bign256v1_p_reciprocal_str_param,
.a = &bign256v1_a_str_param,
.b = &bign256v1_b_str_param,
.curve_order = &bign256v1_curve_order_str_param,
.gx = &bign256v1_gx_str_param,
.gy = &bign256v1_gy_str_param,
.gz = &bign256v1_gz_str_param,
.gen_order = &bign256v1_gen_order_str_param,
.gen_order_bitlen = &bign256v1_gen_order_bitlen_str_param,
.cofactor = &bign256v1_cofactor_str_param,
.alpha_montgomery = &bign256v1_alpha_montgomery_str_param,
.gamma_montgomery = &bign256v1_gamma_montgomery_str_param,
.alpha_edwards = &bign256v1_alpha_edwards_str_param,
.oid = &bign256v1_oid_str_param,
.name = &bign256v1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_BIGN256V1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_BIGN256V1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_BIGN256V1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_BIGN256V1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BIGN256V1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BIGN256V1_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 23)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 23
#endif
#endif /* __EC_PARAMS_BIGN256V1_H__ */
#endif /* WITH_CURVE_BIGN256V1 */

View file

@ -0,0 +1,337 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_BIGN384V1
#ifndef __EC_PARAMS_BIGN384V1_H__
#define __EC_PARAMS_BIGN384V1_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 bign384v1_p[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xc3,
};
TO_EC_STR_PARAM(bign384v1_p);
#define CURVE_BIGN384V1_P_BITLEN 384
static const u8 bign384v1_p_bitlen[] = {
0x01, 0x80,
};
TO_EC_STR_PARAM(bign384v1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 bign384v1_r[] = {
0x01, 0x3d,
};
TO_EC_STR_PARAM(bign384v1_r);
static const u8 bign384v1_r_square[] = {
0x01, 0x88, 0x89,
};
TO_EC_STR_PARAM(bign384v1_r_square);
static const u8 bign384v1_mpinv[] = {
0xec, 0x9e, 0x48, 0xae, 0x6f, 0x71, 0xde, 0x15,
};
TO_EC_STR_PARAM(bign384v1_mpinv);
static const u8 bign384v1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(bign384v1_p_shift);
static const u8 bign384v1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xc3,
};
TO_EC_STR_PARAM(bign384v1_p_normalized);
static const u8 bign384v1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(bign384v1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 bign384v1_r[] = {
0x01, 0x3d,
};
TO_EC_STR_PARAM(bign384v1_r);
static const u8 bign384v1_r_square[] = {
0x01, 0x88, 0x89,
};
TO_EC_STR_PARAM(bign384v1_r_square);
static const u8 bign384v1_mpinv[] = {
0x6f, 0x71, 0xde, 0x15,
};
TO_EC_STR_PARAM(bign384v1_mpinv);
static const u8 bign384v1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(bign384v1_p_shift);
static const u8 bign384v1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xc3,
};
TO_EC_STR_PARAM(bign384v1_p_normalized);
static const u8 bign384v1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(bign384v1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 bign384v1_r[] = {
0x01, 0x3d,
};
TO_EC_STR_PARAM(bign384v1_r);
static const u8 bign384v1_r_square[] = {
0x01, 0x88, 0x89,
};
TO_EC_STR_PARAM(bign384v1_r_square);
static const u8 bign384v1_mpinv[] = {
0xde, 0x15,
};
TO_EC_STR_PARAM(bign384v1_mpinv);
static const u8 bign384v1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(bign384v1_p_shift);
static const u8 bign384v1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xc3,
};
TO_EC_STR_PARAM(bign384v1_p_normalized);
static const u8 bign384v1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(bign384v1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 bign384v1_a[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xc0,
};
TO_EC_STR_PARAM(bign384v1_a);
static const u8 bign384v1_b[] = {
0x3c, 0x75, 0xdf, 0xe1, 0x95, 0x9c, 0xef, 0x20,
0x33, 0x07, 0x5a, 0xab, 0x65, 0x5d, 0x34, 0xd2,
0x71, 0x27, 0x48, 0xbb, 0x0f, 0xfb, 0xb1, 0x96,
0xa6, 0x21, 0x6a, 0xf9, 0xe9, 0x71, 0x2e, 0x3a,
0x14, 0xbd, 0xe2, 0xf0, 0xf3, 0xce, 0xbd, 0x7c,
0xbc, 0xa7, 0xfc, 0x23, 0x68, 0x73, 0xbf, 0x64,
};
TO_EC_STR_PARAM(bign384v1_b);
#define CURVE_BIGN384V1_CURVE_ORDER_BITLEN 384
static const u8 bign384v1_curve_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0x6c, 0xcc, 0xc4, 0x03, 0x73, 0xaf, 0x7b, 0xbb,
0x80, 0x46, 0xda, 0xe7, 0xa6, 0xa4, 0xff, 0x0a,
0x3d, 0xb7, 0xdc, 0x3f, 0xf3, 0x0c, 0xa7, 0xb7,
};
TO_EC_STR_PARAM(bign384v1_curve_order);
static const u8 bign384v1_gx[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
TO_EC_STR_PARAM(bign384v1_gx);
static const u8 bign384v1_gy[] = {
0x5d, 0x43, 0x82, 0x24, 0xa8, 0x2e, 0x9e, 0x9e,
0x63, 0x30, 0x11, 0x7e, 0x43, 0x2d, 0xbf, 0x89,
0x3a, 0x72, 0x9a, 0x11, 0xdc, 0x86, 0xff, 0xa0,
0x05, 0x49, 0xe7, 0x9e, 0x66, 0xb1, 0xd3, 0x55,
0x84, 0x40, 0x3e, 0x27, 0x6b, 0x2a, 0x42, 0xf9,
0xea, 0x5e, 0xcb, 0x31, 0xf7, 0x33, 0xc4, 0x51,
};
TO_EC_STR_PARAM(bign384v1_gy);
static const u8 bign384v1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(bign384v1_gz);
static const u8 bign384v1_gen_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0x6c, 0xcc, 0xc4, 0x03, 0x73, 0xaf, 0x7b, 0xbb,
0x80, 0x46, 0xda, 0xe7, 0xa6, 0xa4, 0xff, 0x0a,
0x3d, 0xb7, 0xdc, 0x3f, 0xf3, 0x0c, 0xa7, 0xb7,
};
TO_EC_STR_PARAM(bign384v1_gen_order);
#define CURVE_BIGN384V1_Q_BITLEN 384
static const u8 bign384v1_gen_order_bitlen[] = {
0x01, 0x80,
};
TO_EC_STR_PARAM(bign384v1_gen_order_bitlen);
static const u8 bign384v1_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(bign384v1_cofactor);
static const u8 bign384v1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(bign384v1_alpha_montgomery, 0);
static const u8 bign384v1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(bign384v1_gamma_montgomery, 0);
static const u8 bign384v1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(bign384v1_alpha_edwards, 0);
static const u8 bign384v1_name[] = "BIGN384V1";
TO_EC_STR_PARAM(bign384v1_name);
static const u8 bign384v1_oid[] = "1.2.112.0.2.0.34.101.45.3.2";
TO_EC_STR_PARAM(bign384v1_oid);
static const ec_str_params bign384v1_str_params = {
.p = &bign384v1_p_str_param,
.p_bitlen = &bign384v1_p_bitlen_str_param,
.r = &bign384v1_r_str_param,
.r_square = &bign384v1_r_square_str_param,
.mpinv = &bign384v1_mpinv_str_param,
.p_shift = &bign384v1_p_shift_str_param,
.p_normalized = &bign384v1_p_normalized_str_param,
.p_reciprocal = &bign384v1_p_reciprocal_str_param,
.a = &bign384v1_a_str_param,
.b = &bign384v1_b_str_param,
.curve_order = &bign384v1_curve_order_str_param,
.gx = &bign384v1_gx_str_param,
.gy = &bign384v1_gy_str_param,
.gz = &bign384v1_gz_str_param,
.gen_order = &bign384v1_gen_order_str_param,
.gen_order_bitlen = &bign384v1_gen_order_bitlen_str_param,
.cofactor = &bign384v1_cofactor_str_param,
.alpha_montgomery = &bign384v1_alpha_montgomery_str_param,
.gamma_montgomery = &bign384v1_gamma_montgomery_str_param,
.alpha_edwards = &bign384v1_alpha_edwards_str_param,
.oid = &bign384v1_oid_str_param,
.name = &bign384v1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_BIGN384V1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_BIGN384V1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_BIGN384V1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_BIGN384V1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BIGN384V1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BIGN384V1_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 23)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 23
#endif
#endif /* __EC_PARAMS_BIGN384V1_H__ */
#endif /* WITH_CURVE_BIGN384V1 */

View file

@ -0,0 +1,359 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_BIGN512V1
#ifndef __EC_PARAMS_BIGN512V1_H__
#define __EC_PARAMS_BIGN512V1_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 bign512v1_p[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc7,
};
TO_EC_STR_PARAM(bign512v1_p);
#define CURVE_BIGN512V1_P_BITLEN 512
static const u8 bign512v1_p_bitlen[] = {
0x02, 0x00,
};
TO_EC_STR_PARAM(bign512v1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 bign512v1_r[] = {
0x02, 0x39,
};
TO_EC_STR_PARAM(bign512v1_r);
static const u8 bign512v1_r_square[] = {
0x04, 0xf0, 0xb1,
};
TO_EC_STR_PARAM(bign512v1_r_square);
static const u8 bign512v1_mpinv[] = {
0x58, 0xa1, 0xf7, 0xe6, 0xce, 0x0f, 0x4c, 0x09,
};
TO_EC_STR_PARAM(bign512v1_mpinv);
static const u8 bign512v1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(bign512v1_p_shift);
static const u8 bign512v1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc7,
};
TO_EC_STR_PARAM(bign512v1_p_normalized);
static const u8 bign512v1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(bign512v1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 bign512v1_r[] = {
0x02, 0x39,
};
TO_EC_STR_PARAM(bign512v1_r);
static const u8 bign512v1_r_square[] = {
0x04, 0xf0, 0xb1,
};
TO_EC_STR_PARAM(bign512v1_r_square);
static const u8 bign512v1_mpinv[] = {
0xce, 0x0f, 0x4c, 0x09,
};
TO_EC_STR_PARAM(bign512v1_mpinv);
static const u8 bign512v1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(bign512v1_p_shift);
static const u8 bign512v1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc7,
};
TO_EC_STR_PARAM(bign512v1_p_normalized);
static const u8 bign512v1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(bign512v1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 bign512v1_r[] = {
0x02, 0x39,
};
TO_EC_STR_PARAM(bign512v1_r);
static const u8 bign512v1_r_square[] = {
0x04, 0xf0, 0xb1,
};
TO_EC_STR_PARAM(bign512v1_r_square);
static const u8 bign512v1_mpinv[] = {
0x4c, 0x09,
};
TO_EC_STR_PARAM(bign512v1_mpinv);
static const u8 bign512v1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(bign512v1_p_shift);
static const u8 bign512v1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc7,
};
TO_EC_STR_PARAM(bign512v1_p_normalized);
static const u8 bign512v1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(bign512v1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 bign512v1_a[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc4,
};
TO_EC_STR_PARAM(bign512v1_a);
static const u8 bign512v1_b[] = {
0x6c, 0xb4, 0x59, 0x44, 0x93, 0x3b, 0x8c, 0x43,
0xd8, 0x8c, 0x5d, 0x6a, 0x60, 0xfd, 0x58, 0x89,
0x5b, 0xc6, 0xa9, 0xee, 0xdd, 0x5d, 0x25, 0x51,
0x17, 0xce, 0x13, 0xe3, 0xda, 0xad, 0xb0, 0x88,
0x27, 0x11, 0xdc, 0xb5, 0xc4, 0x24, 0x5e, 0x95,
0x29, 0x33, 0x00, 0x8c, 0x87, 0xac, 0xa2, 0x43,
0xea, 0x86, 0x22, 0x27, 0x3a, 0x49, 0xa2, 0x7a,
0x09, 0x34, 0x69, 0x98, 0xd6, 0x13, 0x9c, 0x90,
};
TO_EC_STR_PARAM(bign512v1_b);
#define CURVE_BIGN512V1_CURVE_ORDER_BITLEN 512
static const u8 bign512v1_curve_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xb2, 0xc0, 0x09, 0x2c, 0x01, 0x98, 0x00, 0x4e,
0xf2, 0x6b, 0xeb, 0xb0, 0x2e, 0x21, 0x13, 0xf4,
0x36, 0x1b, 0xca, 0xe5, 0x95, 0x56, 0xdf, 0x32,
0xdc, 0xff, 0xad, 0x49, 0x0d, 0x06, 0x8e, 0xf1,
};
TO_EC_STR_PARAM(bign512v1_curve_order);
static const u8 bign512v1_gx[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
TO_EC_STR_PARAM(bign512v1_gx);
static const u8 bign512v1_gy[] = {
0xa8, 0x26, 0xff, 0x7a, 0xe4, 0x03, 0x76, 0x81,
0xb1, 0x82, 0xe6, 0xf7, 0xa0, 0xd1, 0x8f, 0xab,
0xb0, 0xab, 0x41, 0xb3, 0xb3, 0x61, 0xbc, 0xe2,
0xd2, 0xed, 0xf8, 0x1b, 0x00, 0xcc, 0xca, 0xda,
0x69, 0x73, 0xdd, 0xe2, 0x0e, 0xfa, 0x6f, 0xd2,
0xff, 0x77, 0x73, 0x95, 0xee, 0xe8, 0x22, 0x61,
0x67, 0xaa, 0x83, 0xb9, 0xc9, 0x4c, 0x0d, 0x04,
0xb7, 0x92, 0xae, 0x6f, 0xce, 0xef, 0xed, 0xbd,
};
TO_EC_STR_PARAM(bign512v1_gy);
static const u8 bign512v1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(bign512v1_gz);
static const u8 bign512v1_gen_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xb2, 0xc0, 0x09, 0x2c, 0x01, 0x98, 0x00, 0x4e,
0xf2, 0x6b, 0xeb, 0xb0, 0x2e, 0x21, 0x13, 0xf4,
0x36, 0x1b, 0xca, 0xe5, 0x95, 0x56, 0xdf, 0x32,
0xdc, 0xff, 0xad, 0x49, 0x0d, 0x06, 0x8e, 0xf1,
};
TO_EC_STR_PARAM(bign512v1_gen_order);
#define CURVE_BIGN512V1_Q_BITLEN 512
static const u8 bign512v1_gen_order_bitlen[] = {
0x02, 0x00,
};
TO_EC_STR_PARAM(bign512v1_gen_order_bitlen);
static const u8 bign512v1_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(bign512v1_cofactor);
static const u8 bign512v1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(bign512v1_alpha_montgomery, 0);
static const u8 bign512v1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(bign512v1_gamma_montgomery, 0);
static const u8 bign512v1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(bign512v1_alpha_edwards, 0);
static const u8 bign512v1_name[] = "BIGN512V1";
TO_EC_STR_PARAM(bign512v1_name);
static const u8 bign512v1_oid[] = "1.2.112.0.2.0.34.101.45.3.3";
TO_EC_STR_PARAM(bign512v1_oid);
static const ec_str_params bign512v1_str_params = {
.p = &bign512v1_p_str_param,
.p_bitlen = &bign512v1_p_bitlen_str_param,
.r = &bign512v1_r_str_param,
.r_square = &bign512v1_r_square_str_param,
.mpinv = &bign512v1_mpinv_str_param,
.p_shift = &bign512v1_p_shift_str_param,
.p_normalized = &bign512v1_p_normalized_str_param,
.p_reciprocal = &bign512v1_p_reciprocal_str_param,
.a = &bign512v1_a_str_param,
.b = &bign512v1_b_str_param,
.curve_order = &bign512v1_curve_order_str_param,
.gx = &bign512v1_gx_str_param,
.gy = &bign512v1_gy_str_param,
.gz = &bign512v1_gz_str_param,
.gen_order = &bign512v1_gen_order_str_param,
.gen_order_bitlen = &bign512v1_gen_order_bitlen_str_param,
.cofactor = &bign512v1_cofactor_str_param,
.alpha_montgomery = &bign512v1_alpha_montgomery_str_param,
.gamma_montgomery = &bign512v1_gamma_montgomery_str_param,
.alpha_edwards = &bign512v1_alpha_edwards_str_param,
.oid = &bign512v1_oid_str_param,
.name = &bign512v1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_BIGN512V1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_BIGN512V1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_BIGN512V1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_BIGN512V1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BIGN512V1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BIGN512V1_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 23)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 23
#endif
#endif /* __EC_PARAMS_BIGN512V1_H__ */
#endif /* WITH_CURVE_BIGN512V1 */

View file

@ -0,0 +1,334 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_BRAINPOOLP192R1
#ifndef __EC_PARAMS_BRAINPOOLP192R1_H__
#define __EC_PARAMS_BRAINPOOLP192R1_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 brainpoolp192r1_p[] = {
0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd,
0xa7, 0xa3, 0x46, 0x30, 0x93, 0xd1, 0x8d, 0xb7,
0x8f, 0xce, 0x47, 0x6d, 0xe1, 0xa8, 0x62, 0x97,
};
TO_EC_STR_PARAM(brainpoolp192r1_p);
#define CURVE_BRAINPOOLP192R1_P_BITLEN 192
static const u8 brainpoolp192r1_p_bitlen[] = {
0xc0,
};
TO_EC_STR_PARAM(brainpoolp192r1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 brainpoolp192r1_r[] = {
0x3c, 0xfd, 0x0b, 0xe2, 0x6c, 0xd5, 0xc9, 0x32,
0x58, 0x5c, 0xb9, 0xcf, 0x6c, 0x2e, 0x72, 0x48,
0x70, 0x31, 0xb8, 0x92, 0x1e, 0x57, 0x9d, 0x69,
};
TO_EC_STR_PARAM(brainpoolp192r1_r);
static const u8 brainpoolp192r1_r_square[] = {
0xb6, 0x22, 0x51, 0x26, 0xee, 0xd3, 0x4f, 0x10,
0x33, 0xbf, 0x48, 0x46, 0x02, 0xc3, 0xfe, 0x69,
0xe2, 0x47, 0x4c, 0x69, 0x72, 0xc7, 0xb2, 0x1a,
};
TO_EC_STR_PARAM(brainpoolp192r1_r_square);
static const u8 brainpoolp192r1_mpinv[] = {
0xe0, 0x84, 0x96, 0xdb, 0x56, 0xa2, 0xc2, 0xd9,
};
TO_EC_STR_PARAM(brainpoolp192r1_mpinv);
static const u8 brainpoolp192r1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp192r1_p_shift);
static const u8 brainpoolp192r1_p_normalized[] = {
0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd,
0xa7, 0xa3, 0x46, 0x30, 0x93, 0xd1, 0x8d, 0xb7,
0x8f, 0xce, 0x47, 0x6d, 0xe1, 0xa8, 0x62, 0x97,
};
TO_EC_STR_PARAM(brainpoolp192r1_p_normalized);
static const u8 brainpoolp192r1_p_reciprocal[] = {
0x50, 0x0f, 0xea, 0x39, 0xff, 0x17, 0x28, 0xc8,
};
TO_EC_STR_PARAM(brainpoolp192r1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 brainpoolp192r1_r[] = {
0x3c, 0xfd, 0x0b, 0xe2, 0x6c, 0xd5, 0xc9, 0x32,
0x58, 0x5c, 0xb9, 0xcf, 0x6c, 0x2e, 0x72, 0x48,
0x70, 0x31, 0xb8, 0x92, 0x1e, 0x57, 0x9d, 0x69,
};
TO_EC_STR_PARAM(brainpoolp192r1_r);
static const u8 brainpoolp192r1_r_square[] = {
0xb6, 0x22, 0x51, 0x26, 0xee, 0xd3, 0x4f, 0x10,
0x33, 0xbf, 0x48, 0x46, 0x02, 0xc3, 0xfe, 0x69,
0xe2, 0x47, 0x4c, 0x69, 0x72, 0xc7, 0xb2, 0x1a,
};
TO_EC_STR_PARAM(brainpoolp192r1_r_square);
static const u8 brainpoolp192r1_mpinv[] = {
0x56, 0xa2, 0xc2, 0xd9,
};
TO_EC_STR_PARAM(brainpoolp192r1_mpinv);
static const u8 brainpoolp192r1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp192r1_p_shift);
static const u8 brainpoolp192r1_p_normalized[] = {
0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd,
0xa7, 0xa3, 0x46, 0x30, 0x93, 0xd1, 0x8d, 0xb7,
0x8f, 0xce, 0x47, 0x6d, 0xe1, 0xa8, 0x62, 0x97,
};
TO_EC_STR_PARAM(brainpoolp192r1_p_normalized);
static const u8 brainpoolp192r1_p_reciprocal[] = {
0x50, 0x0f, 0xea, 0x39,
};
TO_EC_STR_PARAM(brainpoolp192r1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 brainpoolp192r1_r[] = {
0x3c, 0xfd, 0x0b, 0xe2, 0x6c, 0xd5, 0xc9, 0x32,
0x58, 0x5c, 0xb9, 0xcf, 0x6c, 0x2e, 0x72, 0x48,
0x70, 0x31, 0xb8, 0x92, 0x1e, 0x57, 0x9d, 0x69,
};
TO_EC_STR_PARAM(brainpoolp192r1_r);
static const u8 brainpoolp192r1_r_square[] = {
0xb6, 0x22, 0x51, 0x26, 0xee, 0xd3, 0x4f, 0x10,
0x33, 0xbf, 0x48, 0x46, 0x02, 0xc3, 0xfe, 0x69,
0xe2, 0x47, 0x4c, 0x69, 0x72, 0xc7, 0xb2, 0x1a,
};
TO_EC_STR_PARAM(brainpoolp192r1_r_square);
static const u8 brainpoolp192r1_mpinv[] = {
0xc2, 0xd9,
};
TO_EC_STR_PARAM(brainpoolp192r1_mpinv);
static const u8 brainpoolp192r1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp192r1_p_shift);
static const u8 brainpoolp192r1_p_normalized[] = {
0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd,
0xa7, 0xa3, 0x46, 0x30, 0x93, 0xd1, 0x8d, 0xb7,
0x8f, 0xce, 0x47, 0x6d, 0xe1, 0xa8, 0x62, 0x97,
};
TO_EC_STR_PARAM(brainpoolp192r1_p_normalized);
static const u8 brainpoolp192r1_p_reciprocal[] = {
0x50, 0x0f,
};
TO_EC_STR_PARAM(brainpoolp192r1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 brainpoolp192r1_a[] = {
0x6a, 0x91, 0x17, 0x40, 0x76, 0xb1, 0xe0, 0xe1,
0x9c, 0x39, 0xc0, 0x31, 0xfe, 0x86, 0x85, 0xc1,
0xca, 0xe0, 0x40, 0xe5, 0xc6, 0x9a, 0x28, 0xef,
};
TO_EC_STR_PARAM(brainpoolp192r1_a);
static const u8 brainpoolp192r1_b[] = {
0x46, 0x9a, 0x28, 0xef, 0x7c, 0x28, 0xcc, 0xa3,
0xdc, 0x72, 0x1d, 0x04, 0x4f, 0x44, 0x96, 0xbc,
0xca, 0x7e, 0xf4, 0x14, 0x6f, 0xbf, 0x25, 0xc9,
};
TO_EC_STR_PARAM(brainpoolp192r1_b);
#define CURVE_BRAINPOOLP192R1_CURVE_ORDER_BITLEN 192
static const u8 brainpoolp192r1_curve_order[] = {
0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd,
0xa7, 0xa3, 0x46, 0x2f, 0x9e, 0x9e, 0x91, 0x6b,
0x5b, 0xe8, 0xf1, 0x02, 0x9a, 0xc4, 0xac, 0xc1,
};
TO_EC_STR_PARAM(brainpoolp192r1_curve_order);
static const u8 brainpoolp192r1_gx[] = {
0xc0, 0xa0, 0x64, 0x7e, 0xaa, 0xb6, 0xa4, 0x87,
0x53, 0xb0, 0x33, 0xc5, 0x6c, 0xb0, 0xf0, 0x90,
0x0a, 0x2f, 0x5c, 0x48, 0x53, 0x37, 0x5f, 0xd6,
};
TO_EC_STR_PARAM(brainpoolp192r1_gx);
static const u8 brainpoolp192r1_gy[] = {
0x14, 0xb6, 0x90, 0x86, 0x6a, 0xbd, 0x5b, 0xb8,
0x8b, 0x5f, 0x48, 0x28, 0xc1, 0x49, 0x00, 0x02,
0xe6, 0x77, 0x3f, 0xa2, 0xfa, 0x29, 0x9b, 0x8f,
};
TO_EC_STR_PARAM(brainpoolp192r1_gy);
static const u8 brainpoolp192r1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(brainpoolp192r1_gz);
static const u8 brainpoolp192r1_gen_order[] = {
0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd,
0xa7, 0xa3, 0x46, 0x2f, 0x9e, 0x9e, 0x91, 0x6b,
0x5b, 0xe8, 0xf1, 0x02, 0x9a, 0xc4, 0xac, 0xc1,
};
TO_EC_STR_PARAM(brainpoolp192r1_gen_order);
#define CURVE_BRAINPOOLP192R1_Q_BITLEN 192
static const u8 brainpoolp192r1_gen_order_bitlen[] = {
0xc0,
};
TO_EC_STR_PARAM(brainpoolp192r1_gen_order_bitlen);
static const u8 brainpoolp192r1_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(brainpoolp192r1_cofactor);
static const u8 brainpoolp192r1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp192r1_alpha_montgomery, 0);
static const u8 brainpoolp192r1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp192r1_gamma_montgomery, 0);
static const u8 brainpoolp192r1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp192r1_alpha_edwards, 0);
static const u8 brainpoolp192r1_name[] = "BRAINPOOLP192R1";
TO_EC_STR_PARAM(brainpoolp192r1_name);
static const u8 brainpoolp192r1_oid[] = "1.3.36.3.3.2.8.1.1.3";
TO_EC_STR_PARAM(brainpoolp192r1_oid);
static const ec_str_params brainpoolp192r1_str_params = {
.p = &brainpoolp192r1_p_str_param,
.p_bitlen = &brainpoolp192r1_p_bitlen_str_param,
.r = &brainpoolp192r1_r_str_param,
.r_square = &brainpoolp192r1_r_square_str_param,
.mpinv = &brainpoolp192r1_mpinv_str_param,
.p_shift = &brainpoolp192r1_p_shift_str_param,
.p_normalized = &brainpoolp192r1_p_normalized_str_param,
.p_reciprocal = &brainpoolp192r1_p_reciprocal_str_param,
.a = &brainpoolp192r1_a_str_param,
.b = &brainpoolp192r1_b_str_param,
.curve_order = &brainpoolp192r1_curve_order_str_param,
.gx = &brainpoolp192r1_gx_str_param,
.gy = &brainpoolp192r1_gy_str_param,
.gz = &brainpoolp192r1_gz_str_param,
.gen_order = &brainpoolp192r1_gen_order_str_param,
.gen_order_bitlen = &brainpoolp192r1_gen_order_bitlen_str_param,
.cofactor = &brainpoolp192r1_cofactor_str_param,
.alpha_montgomery = &brainpoolp192r1_alpha_montgomery_str_param,
.gamma_montgomery = &brainpoolp192r1_gamma_montgomery_str_param,
.alpha_edwards = &brainpoolp192r1_alpha_edwards_str_param,
.oid = &brainpoolp192r1_oid_str_param,
.name = &brainpoolp192r1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_BRAINPOOLP192R1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_BRAINPOOLP192R1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_BRAINPOOLP192R1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_BRAINPOOLP192R1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BRAINPOOLP192R1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BRAINPOOLP192R1_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 28)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 28
#endif
#endif /* __EC_PARAMS_BRAINPOOLP192R1_H__ */
#endif /* WITH_CURVE_BRAINPOOLP192R1 */

View file

@ -0,0 +1,316 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_BRAINPOOLP192T1
#ifndef __EC_PARAMS_BRAINPOOLP192T1_H__
#define __EC_PARAMS_BRAINPOOLP192T1_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 brainpoolp192t1_p[] = {
0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd,
0xa7, 0xa3, 0x46, 0x30, 0x93, 0xd1, 0x8d, 0xb7,
0x8f, 0xce, 0x47, 0x6d, 0xe1, 0xa8, 0x62, 0x97,
};
TO_EC_STR_PARAM(brainpoolp192t1_p);
#define CURVE_BRAINPOOLP192T1_P_BITLEN 192
static const u8 brainpoolp192t1_p_bitlen[] = {
0xc0,
};
TO_EC_STR_PARAM(brainpoolp192t1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 brainpoolp192t1_r[] = {
0x3c, 0xfd, 0x0b, 0xe2, 0x6c, 0xd5, 0xc9, 0x32,
0x58, 0x5c, 0xb9, 0xcf, 0x6c, 0x2e, 0x72, 0x48,
0x70, 0x31, 0xb8, 0x92, 0x1e, 0x57, 0x9d, 0x69,
};
TO_EC_STR_PARAM(brainpoolp192t1_r);
static const u8 brainpoolp192t1_r_square[] = {
0xb6, 0x22, 0x51, 0x26, 0xee, 0xd3, 0x4f, 0x10,
0x33, 0xbf, 0x48, 0x46, 0x02, 0xc3, 0xfe, 0x69,
0xe2, 0x47, 0x4c, 0x69, 0x72, 0xc7, 0xb2, 0x1a,
};
TO_EC_STR_PARAM(brainpoolp192t1_r_square);
static const u8 brainpoolp192t1_mpinv[] = {
0xe0, 0x84, 0x96, 0xdb, 0x56, 0xa2, 0xc2, 0xd9,
};
TO_EC_STR_PARAM(brainpoolp192t1_mpinv);
static const u8 brainpoolp192t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp192t1_p_shift);
static const u8 brainpoolp192t1_p_normalized[] = {
0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd,
0xa7, 0xa3, 0x46, 0x30, 0x93, 0xd1, 0x8d, 0xb7,
0x8f, 0xce, 0x47, 0x6d, 0xe1, 0xa8, 0x62, 0x97,
};
TO_EC_STR_PARAM(brainpoolp192t1_p_normalized);
static const u8 brainpoolp192t1_p_reciprocal[] = {
0x50, 0x0f, 0xea, 0x39, 0xff, 0x17, 0x28, 0xc8,
};
TO_EC_STR_PARAM(brainpoolp192t1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 brainpoolp192t1_r[] = {
0x3c, 0xfd, 0x0b, 0xe2, 0x6c, 0xd5, 0xc9, 0x32,
0x58, 0x5c, 0xb9, 0xcf, 0x6c, 0x2e, 0x72, 0x48,
0x70, 0x31, 0xb8, 0x92, 0x1e, 0x57, 0x9d, 0x69,
};
TO_EC_STR_PARAM(brainpoolp192t1_r);
static const u8 brainpoolp192t1_r_square[] = {
0xb6, 0x22, 0x51, 0x26, 0xee, 0xd3, 0x4f, 0x10,
0x33, 0xbf, 0x48, 0x46, 0x02, 0xc3, 0xfe, 0x69,
0xe2, 0x47, 0x4c, 0x69, 0x72, 0xc7, 0xb2, 0x1a,
};
TO_EC_STR_PARAM(brainpoolp192t1_r_square);
static const u8 brainpoolp192t1_mpinv[] = {
0x56, 0xa2, 0xc2, 0xd9,
};
TO_EC_STR_PARAM(brainpoolp192t1_mpinv);
static const u8 brainpoolp192t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp192t1_p_shift);
static const u8 brainpoolp192t1_p_normalized[] = {
0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd,
0xa7, 0xa3, 0x46, 0x30, 0x93, 0xd1, 0x8d, 0xb7,
0x8f, 0xce, 0x47, 0x6d, 0xe1, 0xa8, 0x62, 0x97,
};
TO_EC_STR_PARAM(brainpoolp192t1_p_normalized);
static const u8 brainpoolp192t1_p_reciprocal[] = {
0x50, 0x0f, 0xea, 0x39,
};
TO_EC_STR_PARAM(brainpoolp192t1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 brainpoolp192t1_r[] = {
0x3c, 0xfd, 0x0b, 0xe2, 0x6c, 0xd5, 0xc9, 0x32,
0x58, 0x5c, 0xb9, 0xcf, 0x6c, 0x2e, 0x72, 0x48,
0x70, 0x31, 0xb8, 0x92, 0x1e, 0x57, 0x9d, 0x69,
};
TO_EC_STR_PARAM(brainpoolp192t1_r);
static const u8 brainpoolp192t1_r_square[] = {
0xb6, 0x22, 0x51, 0x26, 0xee, 0xd3, 0x4f, 0x10,
0x33, 0xbf, 0x48, 0x46, 0x02, 0xc3, 0xfe, 0x69,
0xe2, 0x47, 0x4c, 0x69, 0x72, 0xc7, 0xb2, 0x1a,
};
TO_EC_STR_PARAM(brainpoolp192t1_r_square);
static const u8 brainpoolp192t1_mpinv[] = {
0xc2, 0xd9,
};
TO_EC_STR_PARAM(brainpoolp192t1_mpinv);
static const u8 brainpoolp192t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp192t1_p_shift);
static const u8 brainpoolp192t1_p_normalized[] = {
0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd,
0xa7, 0xa3, 0x46, 0x30, 0x93, 0xd1, 0x8d, 0xb7,
0x8f, 0xce, 0x47, 0x6d, 0xe1, 0xa8, 0x62, 0x97,
};
TO_EC_STR_PARAM(brainpoolp192t1_p_normalized);
static const u8 brainpoolp192t1_p_reciprocal[] = {
0x50, 0x0f,
};
TO_EC_STR_PARAM(brainpoolp192t1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 brainpoolp192t1_a[] = {
0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd,
0xa7, 0xa3, 0x46, 0x30, 0x93, 0xd1, 0x8d, 0xb7,
0x8f, 0xce, 0x47, 0x6d, 0xe1, 0xa8, 0x62, 0x94,
};
TO_EC_STR_PARAM(brainpoolp192t1_a);
static const u8 brainpoolp192t1_b[] = {
0x13, 0xd5, 0x6f, 0xfa, 0xec, 0x78, 0x68, 0x1e,
0x68, 0xf9, 0xde, 0xb4, 0x3b, 0x35, 0xbe, 0xc2,
0xfb, 0x68, 0x54, 0x2e, 0x27, 0x89, 0x7b, 0x79,
};
TO_EC_STR_PARAM(brainpoolp192t1_b);
#define CURVE_BRAINPOOLP192T1_CURVE_ORDER_BITLEN 192
static const u8 brainpoolp192t1_curve_order[] = {
0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd,
0xa7, 0xa3, 0x46, 0x2f, 0x9e, 0x9e, 0x91, 0x6b,
0x5b, 0xe8, 0xf1, 0x02, 0x9a, 0xc4, 0xac, 0xc1,
};
TO_EC_STR_PARAM(brainpoolp192t1_curve_order);
static const u8 brainpoolp192t1_gx[] = {
0x3a, 0xe9, 0xe5, 0x8c, 0x82, 0xf6, 0x3c, 0x30,
0x28, 0x2e, 0x1f, 0xe7, 0xbb, 0xf4, 0x3f, 0xa7,
0x2c, 0x44, 0x6a, 0xf6, 0xf4, 0x61, 0x81, 0x29,
};
TO_EC_STR_PARAM(brainpoolp192t1_gx);
static const u8 brainpoolp192t1_gy[] = {
0x09, 0x7e, 0x2c, 0x56, 0x67, 0xc2, 0x22, 0x3a,
0x90, 0x2a, 0xb5, 0xca, 0x44, 0x9d, 0x00, 0x84,
0xb7, 0xe5, 0xb3, 0xde, 0x7c, 0xcc, 0x01, 0xc9,
};
TO_EC_STR_PARAM(brainpoolp192t1_gy);
static const u8 brainpoolp192t1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(brainpoolp192t1_gz);
static const u8 brainpoolp192t1_gen_order[] = {
0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd,
0xa7, 0xa3, 0x46, 0x2f, 0x9e, 0x9e, 0x91, 0x6b,
0x5b, 0xe8, 0xf1, 0x02, 0x9a, 0xc4, 0xac, 0xc1,
};
TO_EC_STR_PARAM(brainpoolp192t1_gen_order);
#define CURVE_BRAINPOOLP192T1_Q_BITLEN 192
static const u8 brainpoolp192t1_gen_order_bitlen[] = {
0xc0,
};
TO_EC_STR_PARAM(brainpoolp192t1_gen_order_bitlen);
static const u8 brainpoolp192t1_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(brainpoolp192t1_cofactor);
static const u8 brainpoolp192t1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp192t1_alpha_montgomery, 0);
static const u8 brainpoolp192t1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp192t1_gamma_montgomery, 0);
static const u8 brainpoolp192t1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp192t1_alpha_edwards, 0);
static const u8 brainpoolp192t1_name[] = "BRAINPOOLP192T1";
TO_EC_STR_PARAM(brainpoolp192t1_name);
static const u8 brainpoolp192t1_oid[] = "1.3.36.3.3.2.8.1.1.4";
TO_EC_STR_PARAM(brainpoolp192t1_oid);
static const ec_str_params brainpoolp192t1_str_params = {
.p = &brainpoolp192t1_p_str_param,
.p_bitlen = &brainpoolp192t1_p_bitlen_str_param,
.r = &brainpoolp192t1_r_str_param,
.r_square = &brainpoolp192t1_r_square_str_param,
.mpinv = &brainpoolp192t1_mpinv_str_param,
.p_shift = &brainpoolp192t1_p_shift_str_param,
.p_normalized = &brainpoolp192t1_p_normalized_str_param,
.p_reciprocal = &brainpoolp192t1_p_reciprocal_str_param,
.a = &brainpoolp192t1_a_str_param,
.b = &brainpoolp192t1_b_str_param,
.curve_order = &brainpoolp192t1_curve_order_str_param,
.gx = &brainpoolp192t1_gx_str_param,
.gy = &brainpoolp192t1_gy_str_param,
.gz = &brainpoolp192t1_gz_str_param,
.gen_order = &brainpoolp192t1_gen_order_str_param,
.gen_order_bitlen = &brainpoolp192t1_gen_order_bitlen_str_param,
.cofactor = &brainpoolp192t1_cofactor_str_param,
.alpha_montgomery = &brainpoolp192t1_alpha_montgomery_str_param,
.gamma_montgomery = &brainpoolp192t1_gamma_montgomery_str_param,
.alpha_edwards = &brainpoolp192t1_alpha_edwards_str_param,
.oid = &brainpoolp192t1_oid_str_param,
.name = &brainpoolp192t1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_BRAINPOOLP192T1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_BRAINPOOLP192T1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_BRAINPOOLP192T1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_BRAINPOOLP192T1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BRAINPOOLP192T1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BRAINPOOLP192T1_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 29)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 29
#endif
#endif /* __EC_PARAMS_BRAINPOOLP192T1_H__ */
#endif /* WITH_CURVE_BRAINPOOLP192T1 */

View file

@ -0,0 +1,295 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_BRAINPOOLP224R1
#ifndef __EC_PARAMS_BRAINPOOLP224R1_H__
#define __EC_PARAMS_BRAINPOOLP224R1_H__
#include "ec_params_external.h"
static const u8 brainpoolp224r1_p[] = {
0xD7, 0xC1, 0x34, 0xAA, 0x26, 0x43, 0x66, 0x86,
0x2A, 0x18, 0x30, 0x25, 0x75, 0xD1, 0xD7, 0x87,
0xB0, 0x9F, 0x07, 0x57, 0x97, 0xDA, 0x89, 0xF5,
0x7E, 0xC8, 0xC0, 0xFF
};
TO_EC_STR_PARAM(brainpoolp224r1_p);
#define CURVE_BRAINPOOLP224R1_P_BITLEN 224
static const u8 brainpoolp224r1_p_bitlen[] = { 0xE0 };
TO_EC_STR_PARAM(brainpoolp224r1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 brainpoolp224r1_p_normalized[] = {
0xD7, 0xC1, 0x34, 0xAA, 0x26, 0x43, 0x66, 0x86,
0x2A, 0x18, 0x30, 0x25, 0x75, 0xD1, 0xD7, 0x87,
0xB0, 0x9F, 0x07, 0x57, 0x97, 0xDA, 0x89, 0xF5,
0x7E, 0xC8, 0xC0, 0xFF, 0x00, 0x00, 0x00, 0x00
};
static const u8 brainpoolp224r1_r[] = {
0x00, 0x00, 0x00, 0x00, 0x79, 0x36, 0x06, 0x11,
0x1c, 0x3f, 0xb2, 0x44, 0x7b, 0x57, 0x6c, 0xf5,
0xa8, 0xe8, 0x42, 0x8f, 0x5c, 0xbf, 0x03, 0x89,
0xd6, 0x82, 0x78, 0x5e, 0x20, 0xb5, 0x62, 0xf7
};
static const u8 brainpoolp224r1_r_square[] = {
0x00, 0x00, 0x00, 0x00, 0x2b, 0x3d, 0x40, 0xdd,
0x7e, 0xa5, 0x57, 0x7c, 0x77, 0xe3, 0xd7, 0xe4,
0x76, 0xf9, 0xee, 0x46, 0xf6, 0x91, 0xd1, 0x05,
0x3b, 0xfb, 0xc9, 0xbf, 0x6b, 0x3d, 0x58, 0xff
};
static const u8 brainpoolp224r1_p_shift[] = {
0x20
};
static const u8 brainpoolp224r1_mpinv[] = {
0xE2, 0x4D, 0x21, 0x6A, 0xE1, 0x49, 0xC1, 0x01
};
static const u8 brainpoolp224r1_p_reciprocal[] = {
0x2F, 0xC0, 0x99, 0xF7, 0x8F, 0xD2, 0x22, 0x99
};
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 brainpoolp224r1_p_normalized[] = {
0xd7, 0xc1, 0x34, 0xaa, 0x26, 0x43, 0x66, 0x86,
0x2a, 0x18, 0x30, 0x25, 0x75, 0xd1, 0xd7, 0x87,
0xb0, 0x9f, 0x07, 0x57, 0x97, 0xda, 0x89, 0xf5,
0x7e, 0xc8, 0xc0, 0xff
};
static const u8 brainpoolp224r1_r[] = {
0x28, 0x3e, 0xcb, 0x55, 0xd9, 0xbc, 0x99, 0x79,
0xd5, 0xe7, 0xcf, 0xda, 0x8a, 0x2e, 0x28, 0x78,
0x4f, 0x60, 0xf8, 0xa8, 0x68, 0x25, 0x76, 0x0a,
0x81, 0x37, 0x3f, 0x01
};
static const u8 brainpoolp224r1_r_square[] = {
0x05, 0x78, 0xfd, 0x59, 0x2e, 0x6a, 0x6c, 0xe4,
0x3f, 0xe8, 0xa2, 0xaa, 0x96, 0xaf, 0x77, 0x4c,
0x43, 0xc2, 0x0e, 0x72, 0x78, 0x67, 0xca, 0x80,
0x64, 0xdc, 0xd0, 0x4f
};
static const u8 brainpoolp224r1_p_shift[] = {
0x00
};
static const u8 brainpoolp224r1_mpinv[] = {
0xE1, 0x49, 0xC1, 0x01
};
static const u8 brainpoolp224r1_p_reciprocal[] = {
0x2F, 0xC0, 0x99, 0xF7
};
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 brainpoolp224r1_p_normalized[] = {
0xd7, 0xc1, 0x34, 0xaa, 0x26, 0x43, 0x66, 0x86,
0x2a, 0x18, 0x30, 0x25, 0x75, 0xd1, 0xd7, 0x87,
0xb0, 0x9f, 0x07, 0x57, 0x97, 0xda, 0x89, 0xf5,
0x7e, 0xc8, 0xc0, 0xff
};
static const u8 brainpoolp224r1_r[] = {
0x28, 0x3e, 0xcb, 0x55, 0xd9, 0xbc, 0x99, 0x79,
0xd5, 0xe7, 0xcf, 0xda, 0x8a, 0x2e, 0x28, 0x78,
0x4f, 0x60, 0xf8, 0xa8, 0x68, 0x25, 0x76, 0x0a,
0x81, 0x37, 0x3f, 0x01
};
static const u8 brainpoolp224r1_r_square[] = {
0x05, 0x78, 0xfd, 0x59, 0x2e, 0x6a, 0x6c, 0xe4,
0x3f, 0xe8, 0xa2, 0xaa, 0x96, 0xaf, 0x77, 0x4c,
0x43, 0xc2, 0x0e, 0x72, 0x78, 0x67, 0xca, 0x80,
0x64, 0xdc, 0xd0, 0x4f
};
static const u8 brainpoolp224r1_p_shift[] = {
0x00
};
static const u8 brainpoolp224r1_mpinv[] = {
0xC1, 0x01
};
static const u8 brainpoolp224r1_p_reciprocal[] = {
0x2F, 0xC0
};
#else /* unknown word size */
#error "Unsupported word size"
#endif
TO_EC_STR_PARAM(brainpoolp224r1_p_normalized);
TO_EC_STR_PARAM(brainpoolp224r1_p_shift);
TO_EC_STR_PARAM(brainpoolp224r1_r);
TO_EC_STR_PARAM(brainpoolp224r1_r_square);
TO_EC_STR_PARAM(brainpoolp224r1_mpinv);
TO_EC_STR_PARAM(brainpoolp224r1_p_reciprocal);
static const u8 brainpoolp224r1_a[] = {
0x68, 0xA5, 0xE6, 0x2C, 0xA9, 0xCE, 0x6C, 0x1C,
0x29, 0x98, 0x03, 0xA6, 0xC1, 0x53, 0x0B, 0x51,
0x4E, 0x18, 0x2A, 0xD8, 0xB0, 0x04, 0x2A, 0x59,
0xCA, 0xD2, 0x9F, 0x43
};
TO_EC_STR_PARAM(brainpoolp224r1_a);
static const u8 brainpoolp224r1_b[] = {
0x25, 0x80, 0xF6, 0x3C, 0xCF, 0xE4, 0x41, 0x38,
0x87, 0x07, 0x13, 0xB1, 0xA9, 0x23, 0x69, 0xE3,
0x3E, 0x21, 0x35, 0xD2, 0x66, 0xDB, 0xB3, 0x72,
0x38, 0x6C, 0x40, 0x0B
};
TO_EC_STR_PARAM(brainpoolp224r1_b);
static const u8 brainpoolp224r1_curve_order[] = {
0xD7, 0xC1, 0x34, 0xAA, 0x26, 0x43, 0x66, 0x86,
0x2A, 0x18, 0x30, 0x25, 0x75, 0xD0, 0xFB, 0x98,
0xD1, 0x16, 0xBC, 0x4B, 0x6D, 0xDE, 0xBC, 0xA3,
0xA5, 0xA7, 0x93, 0x9F
};
TO_EC_STR_PARAM(brainpoolp224r1_curve_order);
static const u8 brainpoolp224r1_gx[] = {
0x0D, 0x90, 0x29, 0xAD, 0x2C, 0x7E, 0x5C, 0xF4,
0x34, 0x08, 0x23, 0xB2, 0xA8, 0x7D, 0xC6, 0x8C,
0x9E, 0x4C, 0xE3, 0x17, 0x4C, 0x1E, 0x6E, 0xFD,
0xEE, 0x12, 0xC0, 0x7D
};
TO_EC_STR_PARAM(brainpoolp224r1_gx);
static const u8 brainpoolp224r1_gy[] = {
0x58, 0xAA, 0x56, 0xF7, 0x72, 0xC0, 0x72, 0x6F,
0x24, 0xC6, 0xB8, 0x9E, 0x4E, 0xCD, 0xAC, 0x24,
0x35, 0x4B, 0x9E, 0x99, 0xCA, 0xA3, 0xF6, 0xD3,
0x76, 0x14, 0x02, 0xCD
};
TO_EC_STR_PARAM(brainpoolp224r1_gy);
static const u8 brainpoolp224r1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01
};
TO_EC_STR_PARAM(brainpoolp224r1_gz);
#define CURVE_BRAINPOOLP224R1_CURVE_ORDER_BITLEN 224
static const u8 brainpoolp224r1_gen_order[] = {
0xD7, 0xC1, 0x34, 0xAA, 0x26, 0x43, 0x66, 0x86,
0x2A, 0x18, 0x30, 0x25, 0x75, 0xD0, 0xFB, 0x98,
0xD1, 0x16, 0xBC, 0x4B, 0x6D, 0xDE, 0xBC, 0xA3,
0xA5, 0xA7, 0x93, 0x9F
};
TO_EC_STR_PARAM(brainpoolp224r1_gen_order);
#define CURVE_BRAINPOOLP224R1_Q_BITLEN 224
static const u8 brainpoolp224r1_gen_order_bitlen[] = { 0xE0 };
TO_EC_STR_PARAM(brainpoolp224r1_gen_order_bitlen);
static const u8 brainpoolp224r1_cofactor[] = { 0x01 };
TO_EC_STR_PARAM(brainpoolp224r1_cofactor);
static const u8 brainpoolp224r1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp224r1_alpha_montgomery, 0);
static const u8 brainpoolp224r1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp224r1_gamma_montgomery, 0);
static const u8 brainpoolp224r1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp224r1_alpha_edwards, 0);
static const u8 brainpoolp224r1_oid[] = "1.3.36.3.3.2.8.1.1.5";
TO_EC_STR_PARAM(brainpoolp224r1_oid);
static const u8 brainpoolp224r1_name[] = "BRAINPOOLP224R1";
TO_EC_STR_PARAM(brainpoolp224r1_name);
static const ec_str_params brainpoolp224r1_str_params = {
.p = &brainpoolp224r1_p_str_param,
.p_bitlen = &brainpoolp224r1_p_bitlen_str_param,
.r = &brainpoolp224r1_r_str_param,
.r_square = &brainpoolp224r1_r_square_str_param,
.mpinv = &brainpoolp224r1_mpinv_str_param,
.p_shift = &brainpoolp224r1_p_shift_str_param,
.p_normalized = &brainpoolp224r1_p_normalized_str_param,
.p_reciprocal = &brainpoolp224r1_p_reciprocal_str_param,
.a = &brainpoolp224r1_a_str_param,
.b = &brainpoolp224r1_b_str_param,
.curve_order = &brainpoolp224r1_curve_order_str_param,
.gx = &brainpoolp224r1_gx_str_param,
.gy = &brainpoolp224r1_gy_str_param,
.gz = &brainpoolp224r1_gz_str_param,
.gen_order = &brainpoolp224r1_gen_order_str_param,
.gen_order_bitlen = &brainpoolp224r1_gen_order_bitlen_str_param,
.cofactor = &brainpoolp224r1_cofactor_str_param,
.alpha_montgomery = &brainpoolp224r1_alpha_montgomery_str_param,
.gamma_montgomery = &brainpoolp224r1_gamma_montgomery_str_param,
.alpha_edwards = &brainpoolp224r1_alpha_edwards_str_param,
.oid = &brainpoolp224r1_oid_str_param,
.name = &brainpoolp224r1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_BRAINPOOLP224R1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_BRAINPOOLP224R1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_BRAINPOOLP224R1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_BRAINPOOLP224R1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BRAINPOOLP224R1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BRAINPOOLP224R1_CURVE_ORDER_BITLEN
#endif
#endif /* __EC_PARAMS_BRAINPOOLP224R1_H__ */
#endif /* WITH_CURVE_BRAINPOOLP224R1 */

View file

@ -0,0 +1,333 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_BRAINPOOLP224T1
#ifndef __EC_PARAMS_BRAINPOOLP224T1_H__
#define __EC_PARAMS_BRAINPOOLP224T1_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 brainpoolp224t1_p[] = {
0xd7, 0xc1, 0x34, 0xaa, 0x26, 0x43, 0x66, 0x86,
0x2a, 0x18, 0x30, 0x25, 0x75, 0xd1, 0xd7, 0x87,
0xb0, 0x9f, 0x07, 0x57, 0x97, 0xda, 0x89, 0xf5,
0x7e, 0xc8, 0xc0, 0xff,
};
TO_EC_STR_PARAM(brainpoolp224t1_p);
#define CURVE_BRAINPOOLP224T1_P_BITLEN 224
static const u8 brainpoolp224t1_p_bitlen[] = {
0xe0,
};
TO_EC_STR_PARAM(brainpoolp224t1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 brainpoolp224t1_r[] = {
0x79, 0x36, 0x06, 0x11, 0x1c, 0x3f, 0xb2, 0x44,
0x7b, 0x57, 0x6c, 0xf5, 0xa8, 0xe8, 0x42, 0x8f,
0x5c, 0xbf, 0x03, 0x89, 0xd6, 0x82, 0x78, 0x5e,
0x20, 0xb5, 0x62, 0xf7,
};
TO_EC_STR_PARAM(brainpoolp224t1_r);
static const u8 brainpoolp224t1_r_square[] = {
0x2b, 0x3d, 0x40, 0xdd, 0x7e, 0xa5, 0x57, 0x7c,
0x77, 0xe3, 0xd7, 0xe4, 0x76, 0xf9, 0xee, 0x46,
0xf6, 0x91, 0xd1, 0x05, 0x3b, 0xfb, 0xc9, 0xbf,
0x6b, 0x3d, 0x58, 0xff,
};
TO_EC_STR_PARAM(brainpoolp224t1_r_square);
static const u8 brainpoolp224t1_mpinv[] = {
0xe2, 0x4d, 0x21, 0x6a, 0xe1, 0x49, 0xc1, 0x01,
};
TO_EC_STR_PARAM(brainpoolp224t1_mpinv);
static const u8 brainpoolp224t1_p_shift[] = {
0x20,
};
TO_EC_STR_PARAM(brainpoolp224t1_p_shift);
static const u8 brainpoolp224t1_p_normalized[] = {
0xd7, 0xc1, 0x34, 0xaa, 0x26, 0x43, 0x66, 0x86,
0x2a, 0x18, 0x30, 0x25, 0x75, 0xd1, 0xd7, 0x87,
0xb0, 0x9f, 0x07, 0x57, 0x97, 0xda, 0x89, 0xf5,
0x7e, 0xc8, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x00,
};
TO_EC_STR_PARAM(brainpoolp224t1_p_normalized);
static const u8 brainpoolp224t1_p_reciprocal[] = {
0x2f, 0xc0, 0x99, 0xf7, 0x8f, 0xd2, 0x22, 0x99,
};
TO_EC_STR_PARAM(brainpoolp224t1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 brainpoolp224t1_r[] = {
0x28, 0x3e, 0xcb, 0x55, 0xd9, 0xbc, 0x99, 0x79,
0xd5, 0xe7, 0xcf, 0xda, 0x8a, 0x2e, 0x28, 0x78,
0x4f, 0x60, 0xf8, 0xa8, 0x68, 0x25, 0x76, 0x0a,
0x81, 0x37, 0x3f, 0x01,
};
TO_EC_STR_PARAM(brainpoolp224t1_r);
static const u8 brainpoolp224t1_r_square[] = {
0x05, 0x78, 0xfd, 0x59, 0x2e, 0x6a, 0x6c, 0xe4,
0x3f, 0xe8, 0xa2, 0xaa, 0x96, 0xaf, 0x77, 0x4c,
0x43, 0xc2, 0x0e, 0x72, 0x78, 0x67, 0xca, 0x80,
0x64, 0xdc, 0xd0, 0x4f,
};
TO_EC_STR_PARAM(brainpoolp224t1_r_square);
static const u8 brainpoolp224t1_mpinv[] = {
0xe1, 0x49, 0xc1, 0x01,
};
TO_EC_STR_PARAM(brainpoolp224t1_mpinv);
static const u8 brainpoolp224t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp224t1_p_shift);
static const u8 brainpoolp224t1_p_normalized[] = {
0xd7, 0xc1, 0x34, 0xaa, 0x26, 0x43, 0x66, 0x86,
0x2a, 0x18, 0x30, 0x25, 0x75, 0xd1, 0xd7, 0x87,
0xb0, 0x9f, 0x07, 0x57, 0x97, 0xda, 0x89, 0xf5,
0x7e, 0xc8, 0xc0, 0xff,
};
TO_EC_STR_PARAM(brainpoolp224t1_p_normalized);
static const u8 brainpoolp224t1_p_reciprocal[] = {
0x2f, 0xc0, 0x99, 0xf7,
};
TO_EC_STR_PARAM(brainpoolp224t1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 brainpoolp224t1_r[] = {
0x28, 0x3e, 0xcb, 0x55, 0xd9, 0xbc, 0x99, 0x79,
0xd5, 0xe7, 0xcf, 0xda, 0x8a, 0x2e, 0x28, 0x78,
0x4f, 0x60, 0xf8, 0xa8, 0x68, 0x25, 0x76, 0x0a,
0x81, 0x37, 0x3f, 0x01,
};
TO_EC_STR_PARAM(brainpoolp224t1_r);
static const u8 brainpoolp224t1_r_square[] = {
0x05, 0x78, 0xfd, 0x59, 0x2e, 0x6a, 0x6c, 0xe4,
0x3f, 0xe8, 0xa2, 0xaa, 0x96, 0xaf, 0x77, 0x4c,
0x43, 0xc2, 0x0e, 0x72, 0x78, 0x67, 0xca, 0x80,
0x64, 0xdc, 0xd0, 0x4f,
};
TO_EC_STR_PARAM(brainpoolp224t1_r_square);
static const u8 brainpoolp224t1_mpinv[] = {
0xc1, 0x01,
};
TO_EC_STR_PARAM(brainpoolp224t1_mpinv);
static const u8 brainpoolp224t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp224t1_p_shift);
static const u8 brainpoolp224t1_p_normalized[] = {
0xd7, 0xc1, 0x34, 0xaa, 0x26, 0x43, 0x66, 0x86,
0x2a, 0x18, 0x30, 0x25, 0x75, 0xd1, 0xd7, 0x87,
0xb0, 0x9f, 0x07, 0x57, 0x97, 0xda, 0x89, 0xf5,
0x7e, 0xc8, 0xc0, 0xff,
};
TO_EC_STR_PARAM(brainpoolp224t1_p_normalized);
static const u8 brainpoolp224t1_p_reciprocal[] = {
0x2f, 0xc0,
};
TO_EC_STR_PARAM(brainpoolp224t1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 brainpoolp224t1_a[] = {
0xd7, 0xc1, 0x34, 0xaa, 0x26, 0x43, 0x66, 0x86,
0x2a, 0x18, 0x30, 0x25, 0x75, 0xd1, 0xd7, 0x87,
0xb0, 0x9f, 0x07, 0x57, 0x97, 0xda, 0x89, 0xf5,
0x7e, 0xc8, 0xc0, 0xfc,
};
TO_EC_STR_PARAM(brainpoolp224t1_a);
static const u8 brainpoolp224t1_b[] = {
0x4b, 0x33, 0x7d, 0x93, 0x41, 0x04, 0xcd, 0x7b,
0xef, 0x27, 0x1b, 0xf6, 0x0c, 0xed, 0x1e, 0xd2,
0x0d, 0xa1, 0x4c, 0x08, 0xb3, 0xbb, 0x64, 0xf1,
0x8a, 0x60, 0x88, 0x8d,
};
TO_EC_STR_PARAM(brainpoolp224t1_b);
#define CURVE_BRAINPOOLP224T1_CURVE_ORDER_BITLEN 224
static const u8 brainpoolp224t1_curve_order[] = {
0xd7, 0xc1, 0x34, 0xaa, 0x26, 0x43, 0x66, 0x86,
0x2a, 0x18, 0x30, 0x25, 0x75, 0xd0, 0xfb, 0x98,
0xd1, 0x16, 0xbc, 0x4b, 0x6d, 0xde, 0xbc, 0xa3,
0xa5, 0xa7, 0x93, 0x9f,
};
TO_EC_STR_PARAM(brainpoolp224t1_curve_order);
static const u8 brainpoolp224t1_gx[] = {
0x6a, 0xb1, 0xe3, 0x44, 0xce, 0x25, 0xff, 0x38,
0x96, 0x42, 0x4e, 0x7f, 0xfe, 0x14, 0x76, 0x2e,
0xcb, 0x49, 0xf8, 0x92, 0x8a, 0xc0, 0xc7, 0x60,
0x29, 0xb4, 0xd5, 0x80,
};
TO_EC_STR_PARAM(brainpoolp224t1_gx);
static const u8 brainpoolp224t1_gy[] = {
0x03, 0x74, 0xe9, 0xf5, 0x14, 0x3e, 0x56, 0x8c,
0xd2, 0x3f, 0x3f, 0x4d, 0x7c, 0x0d, 0x4b, 0x1e,
0x41, 0xc8, 0xcc, 0x0d, 0x1c, 0x6a, 0xbd, 0x5f,
0x1a, 0x46, 0xdb, 0x4c,
};
TO_EC_STR_PARAM(brainpoolp224t1_gy);
static const u8 brainpoolp224t1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(brainpoolp224t1_gz);
static const u8 brainpoolp224t1_gen_order[] = {
0xd7, 0xc1, 0x34, 0xaa, 0x26, 0x43, 0x66, 0x86,
0x2a, 0x18, 0x30, 0x25, 0x75, 0xd0, 0xfb, 0x98,
0xd1, 0x16, 0xbc, 0x4b, 0x6d, 0xde, 0xbc, 0xa3,
0xa5, 0xa7, 0x93, 0x9f,
};
TO_EC_STR_PARAM(brainpoolp224t1_gen_order);
#define CURVE_BRAINPOOLP224T1_Q_BITLEN 224
static const u8 brainpoolp224t1_gen_order_bitlen[] = {
0xe0,
};
TO_EC_STR_PARAM(brainpoolp224t1_gen_order_bitlen);
static const u8 brainpoolp224t1_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(brainpoolp224t1_cofactor);
static const u8 brainpoolp224t1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp224t1_alpha_montgomery, 0);
static const u8 brainpoolp224t1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp224t1_gamma_montgomery, 0);
static const u8 brainpoolp224t1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp224t1_alpha_edwards, 0);
static const u8 brainpoolp224t1_name[] = "BRAINPOOLP224T1";
TO_EC_STR_PARAM(brainpoolp224t1_name);
static const u8 brainpoolp224t1_oid[] = "1.3.36.3.3.2.8.1.1.6";
TO_EC_STR_PARAM(brainpoolp224t1_oid);
static const ec_str_params brainpoolp224t1_str_params = {
.p = &brainpoolp224t1_p_str_param,
.p_bitlen = &brainpoolp224t1_p_bitlen_str_param,
.r = &brainpoolp224t1_r_str_param,
.r_square = &brainpoolp224t1_r_square_str_param,
.mpinv = &brainpoolp224t1_mpinv_str_param,
.p_shift = &brainpoolp224t1_p_shift_str_param,
.p_normalized = &brainpoolp224t1_p_normalized_str_param,
.p_reciprocal = &brainpoolp224t1_p_reciprocal_str_param,
.a = &brainpoolp224t1_a_str_param,
.b = &brainpoolp224t1_b_str_param,
.curve_order = &brainpoolp224t1_curve_order_str_param,
.gx = &brainpoolp224t1_gx_str_param,
.gy = &brainpoolp224t1_gy_str_param,
.gz = &brainpoolp224t1_gz_str_param,
.gen_order = &brainpoolp224t1_gen_order_str_param,
.gen_order_bitlen = &brainpoolp224t1_gen_order_bitlen_str_param,
.cofactor = &brainpoolp224t1_cofactor_str_param,
.alpha_montgomery = &brainpoolp224t1_alpha_montgomery_str_param,
.gamma_montgomery = &brainpoolp224t1_gamma_montgomery_str_param,
.alpha_edwards = &brainpoolp224t1_alpha_edwards_str_param,
.oid = &brainpoolp224t1_oid_str_param,
.name = &brainpoolp224t1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_BRAINPOOLP224T1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_BRAINPOOLP224T1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_BRAINPOOLP224T1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_BRAINPOOLP224T1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BRAINPOOLP224T1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BRAINPOOLP224T1_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 29)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 29
#endif
#endif /* __EC_PARAMS_BRAINPOOLP224T1_H__ */
#endif /* WITH_CURVE_BRAINPOOLP224T1 */

View file

@ -0,0 +1,227 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_BRAINPOOLP256R1
#ifndef __EC_PARAMS_BRAINPOOLP256R1_H__
#define __EC_PARAMS_BRAINPOOLP256R1_H__
#include "ec_params_external.h"
static const u8 brainpoolp256r1_p[] = {
0xA9, 0xFB, 0x57, 0xDB, 0xA1, 0xEE, 0xA9, 0xBC,
0x3E, 0x66, 0x0A, 0x90, 0x9D, 0x83, 0x8D, 0x72,
0x6E, 0x3B, 0xF6, 0x23, 0xD5, 0x26, 0x20, 0x28,
0x20, 0x13, 0x48, 0x1D, 0x1F, 0x6E, 0x53, 0x77
};
TO_EC_STR_PARAM(brainpoolp256r1_p);
#define CURVE_BRAINPOOLP256R1_P_BITLEN 256
static const u8 brainpoolp256r1_p_bitlen[] = { 0x01, 0x00 };
TO_EC_STR_PARAM(brainpoolp256r1_p_bitlen);
static const u8 brainpoolp256r1_r[] = {
0x56, 0x04, 0xa8, 0x24, 0x5e, 0x11, 0x56, 0x43,
0xc1, 0x99, 0xf5, 0x6f, 0x62, 0x7c, 0x72, 0x8d,
0x91, 0xc4, 0x09, 0xdc, 0x2a, 0xd9, 0xdf, 0xd7,
0xdf, 0xec, 0xb7, 0xe2, 0xe0, 0x91, 0xac, 0x89
};
TO_EC_STR_PARAM(brainpoolp256r1_r);
static const u8 brainpoolp256r1_r_square[] = {
0x47, 0x17, 0xaa, 0x21, 0xe5, 0x95, 0x7f, 0xa8,
0xa1, 0xec, 0xda, 0xcd, 0x6b, 0x1a, 0xc8, 0x07,
0x5c, 0xce, 0x4c, 0x26, 0x61, 0x4d, 0x4f, 0x4d,
0x8c, 0xfe, 0xdf, 0x7b, 0xa6, 0x46, 0x5b, 0x6c
};
TO_EC_STR_PARAM(brainpoolp256r1_r_square);
static const u8 brainpoolp256r1_mpinv[] = {
0xc6, 0xa7, 0x55, 0x90, 0xce, 0xfd, 0x89, 0xb9
};
TO_EC_STR_PARAM(brainpoolp256r1_mpinv);
static const u8 brainpoolp256r1_p_shift[] = {
0x00
};
TO_EC_STR_PARAM(brainpoolp256r1_p_shift);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 brainpoolp256r1_p_reciprocal[] = {
0x81, 0x8c, 0x11, 0x31, 0xa1, 0xc5, 0x5b, 0x7e
};
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 brainpoolp256r1_p_reciprocal[] = {
0x81, 0x8c, 0x11, 0x31
};
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 brainpoolp256r1_p_reciprocal[] = {
0x81, 0x8c
};
#else /* unknown word size */
#error "Unsupported word size"
#endif
TO_EC_STR_PARAM(brainpoolp256r1_p_reciprocal);
static const u8 brainpoolp256r1_a[] = {
0x7D, 0x5A, 0x09, 0x75, 0xFC, 0x2C, 0x30, 0x57, 0xEE, 0xF6, 0x75, 0x30,
0x41, 0x7A, 0xFF, 0xE7, 0xFB, 0x80, 0x55, 0xC1, 0x26, 0xDC, 0x5C, 0x6C,
0xE9, 0x4A, 0x4B, 0x44, 0xF3, 0x30, 0xB5, 0xD9
};
TO_EC_STR_PARAM(brainpoolp256r1_a);
static const u8 brainpoolp256r1_b[] = {
0x26, 0xDC, 0x5C, 0x6C, 0xE9, 0x4A, 0x4B, 0x44, 0xF3, 0x30, 0xB5, 0xD9,
0xBB, 0xD7, 0x7C, 0xBF, 0x95, 0x84, 0x16, 0x29, 0x5C, 0xF7, 0xE1, 0xCE,
0x6B, 0xCC, 0xDC, 0x18, 0xFF, 0x8C, 0x07, 0xB6
};
TO_EC_STR_PARAM(brainpoolp256r1_b);
#define CURVE_BRAINPOOLP256R1_CURVE_ORDER_BITLEN 256
static const u8 brainpoolp256r1_curve_order[] = {
0xA9, 0xFB, 0x57, 0xDB, 0xA1, 0xEE, 0xA9, 0xBC, 0x3E, 0x66, 0x0A, 0x90,
0x9D, 0x83, 0x8D, 0x71, 0x8C, 0x39, 0x7A, 0xA3, 0xB5, 0x61, 0xA6, 0xF7,
0x90, 0x1E, 0x0E, 0x82, 0x97, 0x48, 0x56, 0xA7
};
TO_EC_STR_PARAM(brainpoolp256r1_curve_order);
static const u8 brainpoolp256r1_gx[] = {
0x8B, 0xD2, 0xAE, 0xB9, 0xCB, 0x7E, 0x57, 0xCB, 0x2C, 0x4B, 0x48, 0x2F,
0xFC, 0x81, 0xB7, 0xAF, 0xB9, 0xDE, 0x27, 0xE1, 0xE3, 0xBD, 0x23, 0xC2,
0x3A, 0x44, 0x53, 0xBD, 0x9A, 0xCE, 0x32, 0x62
};
TO_EC_STR_PARAM(brainpoolp256r1_gx);
static const u8 brainpoolp256r1_gy[] = {
0x54, 0x7E, 0xF8, 0x35, 0xC3, 0xDA, 0xC4, 0xFD, 0x97, 0xF8, 0x46, 0x1A,
0x14, 0x61, 0x1D, 0xC9, 0xC2, 0x77, 0x45, 0x13, 0x2D, 0xED, 0x8E, 0x54,
0x5C, 0x1D, 0x54, 0xC7, 0x2F, 0x04, 0x69, 0x97
};
TO_EC_STR_PARAM(brainpoolp256r1_gy);
static const u8 brainpoolp256r1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
};
TO_EC_STR_PARAM(brainpoolp256r1_gz);
static const u8 brainpoolp256r1_gen_order[] = {
0xA9, 0xFB, 0x57, 0xDB, 0xA1, 0xEE, 0xA9, 0xBC, 0x3E, 0x66, 0x0A, 0x90,
0x9D, 0x83, 0x8D, 0x71, 0x8C, 0x39, 0x7A, 0xA3, 0xB5, 0x61, 0xA6, 0xF7,
0x90, 0x1E, 0x0E, 0x82, 0x97, 0x48, 0x56, 0xA7
};
TO_EC_STR_PARAM(brainpoolp256r1_gen_order);
#define CURVE_BRAINPOOLP256R1_Q_BITLEN 256
static const u8 brainpoolp256r1_gen_order_bitlen[] = { 0x01, 0x00 };
TO_EC_STR_PARAM(brainpoolp256r1_gen_order_bitlen);
static const u8 brainpoolp256r1_cofactor[] = { 0x01 };
TO_EC_STR_PARAM(brainpoolp256r1_cofactor);
static const u8 brainpoolp256r1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp256r1_alpha_montgomery, 0);
static const u8 brainpoolp256r1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp256r1_gamma_montgomery, 0);
static const u8 brainpoolp256r1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp256r1_alpha_edwards, 0);
static const u8 brainpoolp256r1_oid[] = "1.3.36.3.3.2.8.1.1.7";
TO_EC_STR_PARAM(brainpoolp256r1_oid);
static const u8 brainpoolp256r1_name[] = "BRAINPOOLP256R1";
TO_EC_STR_PARAM(brainpoolp256r1_name);
static const ec_str_params brainpoolp256r1_str_params = {
.p = &brainpoolp256r1_p_str_param,
.p_bitlen = &brainpoolp256r1_p_bitlen_str_param,
.r = &brainpoolp256r1_r_str_param,
.r_square = &brainpoolp256r1_r_square_str_param,
.mpinv = &brainpoolp256r1_mpinv_str_param,
.p_shift = &brainpoolp256r1_p_shift_str_param,
.p_normalized = &brainpoolp256r1_p_str_param,
.p_reciprocal = &brainpoolp256r1_p_reciprocal_str_param,
.a = &brainpoolp256r1_a_str_param,
.b = &brainpoolp256r1_b_str_param,
.curve_order = &brainpoolp256r1_curve_order_str_param,
.gx = &brainpoolp256r1_gx_str_param,
.gy = &brainpoolp256r1_gy_str_param,
.gz = &brainpoolp256r1_gz_str_param,
.gen_order = &brainpoolp256r1_gen_order_str_param,
.gen_order_bitlen = &brainpoolp256r1_gen_order_bitlen_str_param,
.cofactor = &brainpoolp256r1_cofactor_str_param,
.alpha_montgomery = &brainpoolp256r1_alpha_montgomery_str_param,
.gamma_montgomery = &brainpoolp256r1_gamma_montgomery_str_param,
.alpha_edwards = &brainpoolp256r1_alpha_edwards_str_param,
.oid = &brainpoolp256r1_oid_str_param,
.name = &brainpoolp256r1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_BRAINPOOLP256R1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_BRAINPOOLP256R1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_BRAINPOOLP256R1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_BRAINPOOLP256R1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BRAINPOOLP256R1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BRAINPOOLP256R1_CURVE_ORDER_BITLEN
#endif
#endif /* __EC_PARAMS_BRAINPOOLP256R1_H__ */
#endif /* WITH_CURVE_BRAINPOOLP256R1 */

View file

@ -0,0 +1,333 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_BRAINPOOLP256T1
#ifndef __EC_PARAMS_BRAINPOOLP256T1_H__
#define __EC_PARAMS_BRAINPOOLP256T1_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 brainpoolp256t1_p[] = {
0xa9, 0xfb, 0x57, 0xdb, 0xa1, 0xee, 0xa9, 0xbc,
0x3e, 0x66, 0x0a, 0x90, 0x9d, 0x83, 0x8d, 0x72,
0x6e, 0x3b, 0xf6, 0x23, 0xd5, 0x26, 0x20, 0x28,
0x20, 0x13, 0x48, 0x1d, 0x1f, 0x6e, 0x53, 0x77,
};
TO_EC_STR_PARAM(brainpoolp256t1_p);
#define CURVE_BRAINPOOLP256T1_P_BITLEN 256
static const u8 brainpoolp256t1_p_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(brainpoolp256t1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 brainpoolp256t1_r[] = {
0x56, 0x04, 0xa8, 0x24, 0x5e, 0x11, 0x56, 0x43,
0xc1, 0x99, 0xf5, 0x6f, 0x62, 0x7c, 0x72, 0x8d,
0x91, 0xc4, 0x09, 0xdc, 0x2a, 0xd9, 0xdf, 0xd7,
0xdf, 0xec, 0xb7, 0xe2, 0xe0, 0x91, 0xac, 0x89,
};
TO_EC_STR_PARAM(brainpoolp256t1_r);
static const u8 brainpoolp256t1_r_square[] = {
0x47, 0x17, 0xaa, 0x21, 0xe5, 0x95, 0x7f, 0xa8,
0xa1, 0xec, 0xda, 0xcd, 0x6b, 0x1a, 0xc8, 0x07,
0x5c, 0xce, 0x4c, 0x26, 0x61, 0x4d, 0x4f, 0x4d,
0x8c, 0xfe, 0xdf, 0x7b, 0xa6, 0x46, 0x5b, 0x6c,
};
TO_EC_STR_PARAM(brainpoolp256t1_r_square);
static const u8 brainpoolp256t1_mpinv[] = {
0xc6, 0xa7, 0x55, 0x90, 0xce, 0xfd, 0x89, 0xb9,
};
TO_EC_STR_PARAM(brainpoolp256t1_mpinv);
static const u8 brainpoolp256t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp256t1_p_shift);
static const u8 brainpoolp256t1_p_normalized[] = {
0xa9, 0xfb, 0x57, 0xdb, 0xa1, 0xee, 0xa9, 0xbc,
0x3e, 0x66, 0x0a, 0x90, 0x9d, 0x83, 0x8d, 0x72,
0x6e, 0x3b, 0xf6, 0x23, 0xd5, 0x26, 0x20, 0x28,
0x20, 0x13, 0x48, 0x1d, 0x1f, 0x6e, 0x53, 0x77,
};
TO_EC_STR_PARAM(brainpoolp256t1_p_normalized);
static const u8 brainpoolp256t1_p_reciprocal[] = {
0x81, 0x8c, 0x11, 0x31, 0xa1, 0xc5, 0x5b, 0x7e,
};
TO_EC_STR_PARAM(brainpoolp256t1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 brainpoolp256t1_r[] = {
0x56, 0x04, 0xa8, 0x24, 0x5e, 0x11, 0x56, 0x43,
0xc1, 0x99, 0xf5, 0x6f, 0x62, 0x7c, 0x72, 0x8d,
0x91, 0xc4, 0x09, 0xdc, 0x2a, 0xd9, 0xdf, 0xd7,
0xdf, 0xec, 0xb7, 0xe2, 0xe0, 0x91, 0xac, 0x89,
};
TO_EC_STR_PARAM(brainpoolp256t1_r);
static const u8 brainpoolp256t1_r_square[] = {
0x47, 0x17, 0xaa, 0x21, 0xe5, 0x95, 0x7f, 0xa8,
0xa1, 0xec, 0xda, 0xcd, 0x6b, 0x1a, 0xc8, 0x07,
0x5c, 0xce, 0x4c, 0x26, 0x61, 0x4d, 0x4f, 0x4d,
0x8c, 0xfe, 0xdf, 0x7b, 0xa6, 0x46, 0x5b, 0x6c,
};
TO_EC_STR_PARAM(brainpoolp256t1_r_square);
static const u8 brainpoolp256t1_mpinv[] = {
0xce, 0xfd, 0x89, 0xb9,
};
TO_EC_STR_PARAM(brainpoolp256t1_mpinv);
static const u8 brainpoolp256t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp256t1_p_shift);
static const u8 brainpoolp256t1_p_normalized[] = {
0xa9, 0xfb, 0x57, 0xdb, 0xa1, 0xee, 0xa9, 0xbc,
0x3e, 0x66, 0x0a, 0x90, 0x9d, 0x83, 0x8d, 0x72,
0x6e, 0x3b, 0xf6, 0x23, 0xd5, 0x26, 0x20, 0x28,
0x20, 0x13, 0x48, 0x1d, 0x1f, 0x6e, 0x53, 0x77,
};
TO_EC_STR_PARAM(brainpoolp256t1_p_normalized);
static const u8 brainpoolp256t1_p_reciprocal[] = {
0x81, 0x8c, 0x11, 0x31,
};
TO_EC_STR_PARAM(brainpoolp256t1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 brainpoolp256t1_r[] = {
0x56, 0x04, 0xa8, 0x24, 0x5e, 0x11, 0x56, 0x43,
0xc1, 0x99, 0xf5, 0x6f, 0x62, 0x7c, 0x72, 0x8d,
0x91, 0xc4, 0x09, 0xdc, 0x2a, 0xd9, 0xdf, 0xd7,
0xdf, 0xec, 0xb7, 0xe2, 0xe0, 0x91, 0xac, 0x89,
};
TO_EC_STR_PARAM(brainpoolp256t1_r);
static const u8 brainpoolp256t1_r_square[] = {
0x47, 0x17, 0xaa, 0x21, 0xe5, 0x95, 0x7f, 0xa8,
0xa1, 0xec, 0xda, 0xcd, 0x6b, 0x1a, 0xc8, 0x07,
0x5c, 0xce, 0x4c, 0x26, 0x61, 0x4d, 0x4f, 0x4d,
0x8c, 0xfe, 0xdf, 0x7b, 0xa6, 0x46, 0x5b, 0x6c,
};
TO_EC_STR_PARAM(brainpoolp256t1_r_square);
static const u8 brainpoolp256t1_mpinv[] = {
0x89, 0xb9,
};
TO_EC_STR_PARAM(brainpoolp256t1_mpinv);
static const u8 brainpoolp256t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp256t1_p_shift);
static const u8 brainpoolp256t1_p_normalized[] = {
0xa9, 0xfb, 0x57, 0xdb, 0xa1, 0xee, 0xa9, 0xbc,
0x3e, 0x66, 0x0a, 0x90, 0x9d, 0x83, 0x8d, 0x72,
0x6e, 0x3b, 0xf6, 0x23, 0xd5, 0x26, 0x20, 0x28,
0x20, 0x13, 0x48, 0x1d, 0x1f, 0x6e, 0x53, 0x77,
};
TO_EC_STR_PARAM(brainpoolp256t1_p_normalized);
static const u8 brainpoolp256t1_p_reciprocal[] = {
0x81, 0x8c,
};
TO_EC_STR_PARAM(brainpoolp256t1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 brainpoolp256t1_a[] = {
0xa9, 0xfb, 0x57, 0xdb, 0xa1, 0xee, 0xa9, 0xbc,
0x3e, 0x66, 0x0a, 0x90, 0x9d, 0x83, 0x8d, 0x72,
0x6e, 0x3b, 0xf6, 0x23, 0xd5, 0x26, 0x20, 0x28,
0x20, 0x13, 0x48, 0x1d, 0x1f, 0x6e, 0x53, 0x74,
};
TO_EC_STR_PARAM(brainpoolp256t1_a);
static const u8 brainpoolp256t1_b[] = {
0x66, 0x2c, 0x61, 0xc4, 0x30, 0xd8, 0x4e, 0xa4,
0xfe, 0x66, 0xa7, 0x73, 0x3d, 0x0b, 0x76, 0xb7,
0xbf, 0x93, 0xeb, 0xc4, 0xaf, 0x2f, 0x49, 0x25,
0x6a, 0xe5, 0x81, 0x01, 0xfe, 0xe9, 0x2b, 0x04,
};
TO_EC_STR_PARAM(brainpoolp256t1_b);
#define CURVE_BRAINPOOLP256T1_CURVE_ORDER_BITLEN 256
static const u8 brainpoolp256t1_curve_order[] = {
0xa9, 0xfb, 0x57, 0xdb, 0xa1, 0xee, 0xa9, 0xbc,
0x3e, 0x66, 0x0a, 0x90, 0x9d, 0x83, 0x8d, 0x71,
0x8c, 0x39, 0x7a, 0xa3, 0xb5, 0x61, 0xa6, 0xf7,
0x90, 0x1e, 0x0e, 0x82, 0x97, 0x48, 0x56, 0xa7,
};
TO_EC_STR_PARAM(brainpoolp256t1_curve_order);
static const u8 brainpoolp256t1_gx[] = {
0xa3, 0xe8, 0xeb, 0x3c, 0xc1, 0xcf, 0xe7, 0xb7,
0x73, 0x22, 0x13, 0xb2, 0x3a, 0x65, 0x61, 0x49,
0xaf, 0xa1, 0x42, 0xc4, 0x7a, 0xaf, 0xbc, 0x2b,
0x79, 0xa1, 0x91, 0x56, 0x2e, 0x13, 0x05, 0xf4,
};
TO_EC_STR_PARAM(brainpoolp256t1_gx);
static const u8 brainpoolp256t1_gy[] = {
0x2d, 0x99, 0x6c, 0x82, 0x34, 0x39, 0xc5, 0x6d,
0x7f, 0x7b, 0x22, 0xe1, 0x46, 0x44, 0x41, 0x7e,
0x69, 0xbc, 0xb6, 0xde, 0x39, 0xd0, 0x27, 0x00,
0x1d, 0xab, 0xe8, 0xf3, 0x5b, 0x25, 0xc9, 0xbe,
};
TO_EC_STR_PARAM(brainpoolp256t1_gy);
static const u8 brainpoolp256t1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(brainpoolp256t1_gz);
static const u8 brainpoolp256t1_gen_order[] = {
0xa9, 0xfb, 0x57, 0xdb, 0xa1, 0xee, 0xa9, 0xbc,
0x3e, 0x66, 0x0a, 0x90, 0x9d, 0x83, 0x8d, 0x71,
0x8c, 0x39, 0x7a, 0xa3, 0xb5, 0x61, 0xa6, 0xf7,
0x90, 0x1e, 0x0e, 0x82, 0x97, 0x48, 0x56, 0xa7,
};
TO_EC_STR_PARAM(brainpoolp256t1_gen_order);
#define CURVE_BRAINPOOLP256T1_Q_BITLEN 256
static const u8 brainpoolp256t1_gen_order_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(brainpoolp256t1_gen_order_bitlen);
static const u8 brainpoolp256t1_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(brainpoolp256t1_cofactor);
static const u8 brainpoolp256t1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp256t1_alpha_montgomery, 0);
static const u8 brainpoolp256t1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp256t1_gamma_montgomery, 0);
static const u8 brainpoolp256t1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp256t1_alpha_edwards, 0);
static const u8 brainpoolp256t1_name[] = "BRAINPOOLP256T1";
TO_EC_STR_PARAM(brainpoolp256t1_name);
static const u8 brainpoolp256t1_oid[] = "1.3.36.3.3.2.8.1.1.8";
TO_EC_STR_PARAM(brainpoolp256t1_oid);
static const ec_str_params brainpoolp256t1_str_params = {
.p = &brainpoolp256t1_p_str_param,
.p_bitlen = &brainpoolp256t1_p_bitlen_str_param,
.r = &brainpoolp256t1_r_str_param,
.r_square = &brainpoolp256t1_r_square_str_param,
.mpinv = &brainpoolp256t1_mpinv_str_param,
.p_shift = &brainpoolp256t1_p_shift_str_param,
.p_normalized = &brainpoolp256t1_p_normalized_str_param,
.p_reciprocal = &brainpoolp256t1_p_reciprocal_str_param,
.a = &brainpoolp256t1_a_str_param,
.b = &brainpoolp256t1_b_str_param,
.curve_order = &brainpoolp256t1_curve_order_str_param,
.gx = &brainpoolp256t1_gx_str_param,
.gy = &brainpoolp256t1_gy_str_param,
.gz = &brainpoolp256t1_gz_str_param,
.gen_order = &brainpoolp256t1_gen_order_str_param,
.gen_order_bitlen = &brainpoolp256t1_gen_order_bitlen_str_param,
.cofactor = &brainpoolp256t1_cofactor_str_param,
.alpha_montgomery = &brainpoolp256t1_alpha_montgomery_str_param,
.gamma_montgomery = &brainpoolp256t1_gamma_montgomery_str_param,
.alpha_edwards = &brainpoolp256t1_alpha_edwards_str_param,
.oid = &brainpoolp256t1_oid_str_param,
.name = &brainpoolp256t1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_BRAINPOOLP256T1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_BRAINPOOLP256T1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_BRAINPOOLP256T1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_BRAINPOOLP256T1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BRAINPOOLP256T1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BRAINPOOLP256T1_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 29)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 29
#endif
#endif /* __EC_PARAMS_BRAINPOOLP256T1_H__ */
#endif /* WITH_CURVE_BRAINPOOLP256T1 */

View file

@ -0,0 +1,350 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_BRAINPOOLP320R1
#ifndef __EC_PARAMS_BRAINPOOLP320R1_H__
#define __EC_PARAMS_BRAINPOOLP320R1_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 brainpoolp320r1_p[] = {
0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
0xf9, 0x8f, 0xcf, 0xa6, 0xf6, 0xf4, 0x0d, 0xef,
0x4f, 0x92, 0xb9, 0xec, 0x78, 0x93, 0xec, 0x28,
0xfc, 0xd4, 0x12, 0xb1, 0xf1, 0xb3, 0x2e, 0x27,
};
TO_EC_STR_PARAM(brainpoolp320r1_p);
#define CURVE_BRAINPOOLP320R1_P_BITLEN 320
static const u8 brainpoolp320r1_p_bitlen[] = {
0x01, 0x40,
};
TO_EC_STR_PARAM(brainpoolp320r1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 brainpoolp320r1_r[] = {
0x2c, 0xa1, 0xb8, 0xdf, 0xc9, 0x43, 0xb0, 0x48,
0x1e, 0xc3, 0x87, 0xa1, 0x2d, 0xfe, 0x1f, 0x9a,
0x06, 0x70, 0x30, 0x59, 0x09, 0x0b, 0xf2, 0x10,
0xb0, 0x6d, 0x46, 0x13, 0x87, 0x6c, 0x13, 0xd7,
0x03, 0x2b, 0xed, 0x4e, 0x0e, 0x4c, 0xd1, 0xd9,
};
TO_EC_STR_PARAM(brainpoolp320r1_r);
static const u8 brainpoolp320r1_r_square[] = {
0xa2, 0x59, 0xba, 0x4a, 0x6c, 0x2d, 0x92, 0x52,
0x54, 0x55, 0xa9, 0x64, 0xe6, 0x14, 0xd6, 0xd2,
0x1f, 0x4c, 0x88, 0x1f, 0x30, 0xc5, 0xb6, 0x76,
0xc2, 0x47, 0x8a, 0x8d, 0x90, 0x69, 0x78, 0xef,
0x99, 0x4e, 0xe8, 0x8a, 0x74, 0x3b, 0x52, 0xf9,
};
TO_EC_STR_PARAM(brainpoolp320r1_r_square);
static const u8 brainpoolp320r1_mpinv[] = {
0x3d, 0x1e, 0x9b, 0xa2, 0x2a, 0x8a, 0x9e, 0x69,
};
TO_EC_STR_PARAM(brainpoolp320r1_mpinv);
static const u8 brainpoolp320r1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp320r1_p_shift);
static const u8 brainpoolp320r1_p_normalized[] = {
0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
0xf9, 0x8f, 0xcf, 0xa6, 0xf6, 0xf4, 0x0d, 0xef,
0x4f, 0x92, 0xb9, 0xec, 0x78, 0x93, 0xec, 0x28,
0xfc, 0xd4, 0x12, 0xb1, 0xf1, 0xb3, 0x2e, 0x27,
};
TO_EC_STR_PARAM(brainpoolp320r1_p_normalized);
static const u8 brainpoolp320r1_p_reciprocal[] = {
0x36, 0x0e, 0x55, 0xa5, 0xaf, 0x1a, 0xa1, 0x20,
};
TO_EC_STR_PARAM(brainpoolp320r1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 brainpoolp320r1_r[] = {
0x2c, 0xa1, 0xb8, 0xdf, 0xc9, 0x43, 0xb0, 0x48,
0x1e, 0xc3, 0x87, 0xa1, 0x2d, 0xfe, 0x1f, 0x9a,
0x06, 0x70, 0x30, 0x59, 0x09, 0x0b, 0xf2, 0x10,
0xb0, 0x6d, 0x46, 0x13, 0x87, 0x6c, 0x13, 0xd7,
0x03, 0x2b, 0xed, 0x4e, 0x0e, 0x4c, 0xd1, 0xd9,
};
TO_EC_STR_PARAM(brainpoolp320r1_r);
static const u8 brainpoolp320r1_r_square[] = {
0xa2, 0x59, 0xba, 0x4a, 0x6c, 0x2d, 0x92, 0x52,
0x54, 0x55, 0xa9, 0x64, 0xe6, 0x14, 0xd6, 0xd2,
0x1f, 0x4c, 0x88, 0x1f, 0x30, 0xc5, 0xb6, 0x76,
0xc2, 0x47, 0x8a, 0x8d, 0x90, 0x69, 0x78, 0xef,
0x99, 0x4e, 0xe8, 0x8a, 0x74, 0x3b, 0x52, 0xf9,
};
TO_EC_STR_PARAM(brainpoolp320r1_r_square);
static const u8 brainpoolp320r1_mpinv[] = {
0x2a, 0x8a, 0x9e, 0x69,
};
TO_EC_STR_PARAM(brainpoolp320r1_mpinv);
static const u8 brainpoolp320r1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp320r1_p_shift);
static const u8 brainpoolp320r1_p_normalized[] = {
0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
0xf9, 0x8f, 0xcf, 0xa6, 0xf6, 0xf4, 0x0d, 0xef,
0x4f, 0x92, 0xb9, 0xec, 0x78, 0x93, 0xec, 0x28,
0xfc, 0xd4, 0x12, 0xb1, 0xf1, 0xb3, 0x2e, 0x27,
};
TO_EC_STR_PARAM(brainpoolp320r1_p_normalized);
static const u8 brainpoolp320r1_p_reciprocal[] = {
0x36, 0x0e, 0x55, 0xa5,
};
TO_EC_STR_PARAM(brainpoolp320r1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 brainpoolp320r1_r[] = {
0x2c, 0xa1, 0xb8, 0xdf, 0xc9, 0x43, 0xb0, 0x48,
0x1e, 0xc3, 0x87, 0xa1, 0x2d, 0xfe, 0x1f, 0x9a,
0x06, 0x70, 0x30, 0x59, 0x09, 0x0b, 0xf2, 0x10,
0xb0, 0x6d, 0x46, 0x13, 0x87, 0x6c, 0x13, 0xd7,
0x03, 0x2b, 0xed, 0x4e, 0x0e, 0x4c, 0xd1, 0xd9,
};
TO_EC_STR_PARAM(brainpoolp320r1_r);
static const u8 brainpoolp320r1_r_square[] = {
0xa2, 0x59, 0xba, 0x4a, 0x6c, 0x2d, 0x92, 0x52,
0x54, 0x55, 0xa9, 0x64, 0xe6, 0x14, 0xd6, 0xd2,
0x1f, 0x4c, 0x88, 0x1f, 0x30, 0xc5, 0xb6, 0x76,
0xc2, 0x47, 0x8a, 0x8d, 0x90, 0x69, 0x78, 0xef,
0x99, 0x4e, 0xe8, 0x8a, 0x74, 0x3b, 0x52, 0xf9,
};
TO_EC_STR_PARAM(brainpoolp320r1_r_square);
static const u8 brainpoolp320r1_mpinv[] = {
0x9e, 0x69,
};
TO_EC_STR_PARAM(brainpoolp320r1_mpinv);
static const u8 brainpoolp320r1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp320r1_p_shift);
static const u8 brainpoolp320r1_p_normalized[] = {
0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
0xf9, 0x8f, 0xcf, 0xa6, 0xf6, 0xf4, 0x0d, 0xef,
0x4f, 0x92, 0xb9, 0xec, 0x78, 0x93, 0xec, 0x28,
0xfc, 0xd4, 0x12, 0xb1, 0xf1, 0xb3, 0x2e, 0x27,
};
TO_EC_STR_PARAM(brainpoolp320r1_p_normalized);
static const u8 brainpoolp320r1_p_reciprocal[] = {
0x36, 0x0e,
};
TO_EC_STR_PARAM(brainpoolp320r1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 brainpoolp320r1_a[] = {
0x3e, 0xe3, 0x0b, 0x56, 0x8f, 0xba, 0xb0, 0xf8,
0x83, 0xcc, 0xeb, 0xd4, 0x6d, 0x3f, 0x3b, 0xb8,
0xa2, 0xa7, 0x35, 0x13, 0xf5, 0xeb, 0x79, 0xda,
0x66, 0x19, 0x0e, 0xb0, 0x85, 0xff, 0xa9, 0xf4,
0x92, 0xf3, 0x75, 0xa9, 0x7d, 0x86, 0x0e, 0xb4,
};
TO_EC_STR_PARAM(brainpoolp320r1_a);
static const u8 brainpoolp320r1_b[] = {
0x52, 0x08, 0x83, 0x94, 0x9d, 0xfd, 0xbc, 0x42,
0xd3, 0xad, 0x19, 0x86, 0x40, 0x68, 0x8a, 0x6f,
0xe1, 0x3f, 0x41, 0x34, 0x95, 0x54, 0xb4, 0x9a,
0xcc, 0x31, 0xdc, 0xcd, 0x88, 0x45, 0x39, 0x81,
0x6f, 0x5e, 0xb4, 0xac, 0x8f, 0xb1, 0xf1, 0xa6,
};
TO_EC_STR_PARAM(brainpoolp320r1_b);
#define CURVE_BRAINPOOLP320R1_CURVE_ORDER_BITLEN 320
static const u8 brainpoolp320r1_curve_order[] = {
0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
0xf9, 0x8f, 0xcf, 0xa5, 0xb6, 0x8f, 0x12, 0xa3,
0x2d, 0x48, 0x2e, 0xc7, 0xee, 0x86, 0x58, 0xe9,
0x86, 0x91, 0x55, 0x5b, 0x44, 0xc5, 0x93, 0x11,
};
TO_EC_STR_PARAM(brainpoolp320r1_curve_order);
static const u8 brainpoolp320r1_gx[] = {
0x43, 0xbd, 0x7e, 0x9a, 0xfb, 0x53, 0xd8, 0xb8,
0x52, 0x89, 0xbc, 0xc4, 0x8e, 0xe5, 0xbf, 0xe6,
0xf2, 0x01, 0x37, 0xd1, 0x0a, 0x08, 0x7e, 0xb6,
0xe7, 0x87, 0x1e, 0x2a, 0x10, 0xa5, 0x99, 0xc7,
0x10, 0xaf, 0x8d, 0x0d, 0x39, 0xe2, 0x06, 0x11,
};
TO_EC_STR_PARAM(brainpoolp320r1_gx);
static const u8 brainpoolp320r1_gy[] = {
0x14, 0xfd, 0xd0, 0x55, 0x45, 0xec, 0x1c, 0xc8,
0xab, 0x40, 0x93, 0x24, 0x7f, 0x77, 0x27, 0x5e,
0x07, 0x43, 0xff, 0xed, 0x11, 0x71, 0x82, 0xea,
0xa9, 0xc7, 0x78, 0x77, 0xaa, 0xac, 0x6a, 0xc7,
0xd3, 0x52, 0x45, 0xd1, 0x69, 0x2e, 0x8e, 0xe1,
};
TO_EC_STR_PARAM(brainpoolp320r1_gy);
static const u8 brainpoolp320r1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(brainpoolp320r1_gz);
static const u8 brainpoolp320r1_gen_order[] = {
0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
0xf9, 0x8f, 0xcf, 0xa5, 0xb6, 0x8f, 0x12, 0xa3,
0x2d, 0x48, 0x2e, 0xc7, 0xee, 0x86, 0x58, 0xe9,
0x86, 0x91, 0x55, 0x5b, 0x44, 0xc5, 0x93, 0x11,
};
TO_EC_STR_PARAM(brainpoolp320r1_gen_order);
#define CURVE_BRAINPOOLP320R1_Q_BITLEN 320
static const u8 brainpoolp320r1_gen_order_bitlen[] = {
0x01, 0x40,
};
TO_EC_STR_PARAM(brainpoolp320r1_gen_order_bitlen);
static const u8 brainpoolp320r1_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(brainpoolp320r1_cofactor);
static const u8 brainpoolp320r1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp320r1_alpha_montgomery, 0);
static const u8 brainpoolp320r1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp320r1_gamma_montgomery, 0);
static const u8 brainpoolp320r1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp320r1_alpha_edwards, 0);
static const u8 brainpoolp320r1_name[] = "BRAINPOOLP320R1";
TO_EC_STR_PARAM(brainpoolp320r1_name);
static const u8 brainpoolp320r1_oid[] = "1.3.36.3.3.2.8.1.1.9";
TO_EC_STR_PARAM(brainpoolp320r1_oid);
static const ec_str_params brainpoolp320r1_str_params = {
.p = &brainpoolp320r1_p_str_param,
.p_bitlen = &brainpoolp320r1_p_bitlen_str_param,
.r = &brainpoolp320r1_r_str_param,
.r_square = &brainpoolp320r1_r_square_str_param,
.mpinv = &brainpoolp320r1_mpinv_str_param,
.p_shift = &brainpoolp320r1_p_shift_str_param,
.p_normalized = &brainpoolp320r1_p_normalized_str_param,
.p_reciprocal = &brainpoolp320r1_p_reciprocal_str_param,
.a = &brainpoolp320r1_a_str_param,
.b = &brainpoolp320r1_b_str_param,
.curve_order = &brainpoolp320r1_curve_order_str_param,
.gx = &brainpoolp320r1_gx_str_param,
.gy = &brainpoolp320r1_gy_str_param,
.gz = &brainpoolp320r1_gz_str_param,
.gen_order = &brainpoolp320r1_gen_order_str_param,
.gen_order_bitlen = &brainpoolp320r1_gen_order_bitlen_str_param,
.cofactor = &brainpoolp320r1_cofactor_str_param,
.alpha_montgomery = &brainpoolp320r1_alpha_montgomery_str_param,
.gamma_montgomery = &brainpoolp320r1_gamma_montgomery_str_param,
.alpha_edwards = &brainpoolp320r1_alpha_edwards_str_param,
.oid = &brainpoolp320r1_oid_str_param,
.name = &brainpoolp320r1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_BRAINPOOLP320R1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_BRAINPOOLP320R1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_BRAINPOOLP320R1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_BRAINPOOLP320R1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BRAINPOOLP320R1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BRAINPOOLP320R1_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 29)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 29
#endif
#endif /* __EC_PARAMS_BRAINPOOLP320R1_H__ */
#endif /* WITH_CURVE_BRAINPOOLP320R1 */

View file

@ -0,0 +1,350 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_BRAINPOOLP320T1
#ifndef __EC_PARAMS_BRAINPOOLP320T1_H__
#define __EC_PARAMS_BRAINPOOLP320T1_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 brainpoolp320t1_p[] = {
0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
0xf9, 0x8f, 0xcf, 0xa6, 0xf6, 0xf4, 0x0d, 0xef,
0x4f, 0x92, 0xb9, 0xec, 0x78, 0x93, 0xec, 0x28,
0xfc, 0xd4, 0x12, 0xb1, 0xf1, 0xb3, 0x2e, 0x27,
};
TO_EC_STR_PARAM(brainpoolp320t1_p);
#define CURVE_BRAINPOOLP320T1_P_BITLEN 320
static const u8 brainpoolp320t1_p_bitlen[] = {
0x01, 0x40,
};
TO_EC_STR_PARAM(brainpoolp320t1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 brainpoolp320t1_r[] = {
0x2c, 0xa1, 0xb8, 0xdf, 0xc9, 0x43, 0xb0, 0x48,
0x1e, 0xc3, 0x87, 0xa1, 0x2d, 0xfe, 0x1f, 0x9a,
0x06, 0x70, 0x30, 0x59, 0x09, 0x0b, 0xf2, 0x10,
0xb0, 0x6d, 0x46, 0x13, 0x87, 0x6c, 0x13, 0xd7,
0x03, 0x2b, 0xed, 0x4e, 0x0e, 0x4c, 0xd1, 0xd9,
};
TO_EC_STR_PARAM(brainpoolp320t1_r);
static const u8 brainpoolp320t1_r_square[] = {
0xa2, 0x59, 0xba, 0x4a, 0x6c, 0x2d, 0x92, 0x52,
0x54, 0x55, 0xa9, 0x64, 0xe6, 0x14, 0xd6, 0xd2,
0x1f, 0x4c, 0x88, 0x1f, 0x30, 0xc5, 0xb6, 0x76,
0xc2, 0x47, 0x8a, 0x8d, 0x90, 0x69, 0x78, 0xef,
0x99, 0x4e, 0xe8, 0x8a, 0x74, 0x3b, 0x52, 0xf9,
};
TO_EC_STR_PARAM(brainpoolp320t1_r_square);
static const u8 brainpoolp320t1_mpinv[] = {
0x3d, 0x1e, 0x9b, 0xa2, 0x2a, 0x8a, 0x9e, 0x69,
};
TO_EC_STR_PARAM(brainpoolp320t1_mpinv);
static const u8 brainpoolp320t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp320t1_p_shift);
static const u8 brainpoolp320t1_p_normalized[] = {
0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
0xf9, 0x8f, 0xcf, 0xa6, 0xf6, 0xf4, 0x0d, 0xef,
0x4f, 0x92, 0xb9, 0xec, 0x78, 0x93, 0xec, 0x28,
0xfc, 0xd4, 0x12, 0xb1, 0xf1, 0xb3, 0x2e, 0x27,
};
TO_EC_STR_PARAM(brainpoolp320t1_p_normalized);
static const u8 brainpoolp320t1_p_reciprocal[] = {
0x36, 0x0e, 0x55, 0xa5, 0xaf, 0x1a, 0xa1, 0x20,
};
TO_EC_STR_PARAM(brainpoolp320t1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 brainpoolp320t1_r[] = {
0x2c, 0xa1, 0xb8, 0xdf, 0xc9, 0x43, 0xb0, 0x48,
0x1e, 0xc3, 0x87, 0xa1, 0x2d, 0xfe, 0x1f, 0x9a,
0x06, 0x70, 0x30, 0x59, 0x09, 0x0b, 0xf2, 0x10,
0xb0, 0x6d, 0x46, 0x13, 0x87, 0x6c, 0x13, 0xd7,
0x03, 0x2b, 0xed, 0x4e, 0x0e, 0x4c, 0xd1, 0xd9,
};
TO_EC_STR_PARAM(brainpoolp320t1_r);
static const u8 brainpoolp320t1_r_square[] = {
0xa2, 0x59, 0xba, 0x4a, 0x6c, 0x2d, 0x92, 0x52,
0x54, 0x55, 0xa9, 0x64, 0xe6, 0x14, 0xd6, 0xd2,
0x1f, 0x4c, 0x88, 0x1f, 0x30, 0xc5, 0xb6, 0x76,
0xc2, 0x47, 0x8a, 0x8d, 0x90, 0x69, 0x78, 0xef,
0x99, 0x4e, 0xe8, 0x8a, 0x74, 0x3b, 0x52, 0xf9,
};
TO_EC_STR_PARAM(brainpoolp320t1_r_square);
static const u8 brainpoolp320t1_mpinv[] = {
0x2a, 0x8a, 0x9e, 0x69,
};
TO_EC_STR_PARAM(brainpoolp320t1_mpinv);
static const u8 brainpoolp320t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp320t1_p_shift);
static const u8 brainpoolp320t1_p_normalized[] = {
0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
0xf9, 0x8f, 0xcf, 0xa6, 0xf6, 0xf4, 0x0d, 0xef,
0x4f, 0x92, 0xb9, 0xec, 0x78, 0x93, 0xec, 0x28,
0xfc, 0xd4, 0x12, 0xb1, 0xf1, 0xb3, 0x2e, 0x27,
};
TO_EC_STR_PARAM(brainpoolp320t1_p_normalized);
static const u8 brainpoolp320t1_p_reciprocal[] = {
0x36, 0x0e, 0x55, 0xa5,
};
TO_EC_STR_PARAM(brainpoolp320t1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 brainpoolp320t1_r[] = {
0x2c, 0xa1, 0xb8, 0xdf, 0xc9, 0x43, 0xb0, 0x48,
0x1e, 0xc3, 0x87, 0xa1, 0x2d, 0xfe, 0x1f, 0x9a,
0x06, 0x70, 0x30, 0x59, 0x09, 0x0b, 0xf2, 0x10,
0xb0, 0x6d, 0x46, 0x13, 0x87, 0x6c, 0x13, 0xd7,
0x03, 0x2b, 0xed, 0x4e, 0x0e, 0x4c, 0xd1, 0xd9,
};
TO_EC_STR_PARAM(brainpoolp320t1_r);
static const u8 brainpoolp320t1_r_square[] = {
0xa2, 0x59, 0xba, 0x4a, 0x6c, 0x2d, 0x92, 0x52,
0x54, 0x55, 0xa9, 0x64, 0xe6, 0x14, 0xd6, 0xd2,
0x1f, 0x4c, 0x88, 0x1f, 0x30, 0xc5, 0xb6, 0x76,
0xc2, 0x47, 0x8a, 0x8d, 0x90, 0x69, 0x78, 0xef,
0x99, 0x4e, 0xe8, 0x8a, 0x74, 0x3b, 0x52, 0xf9,
};
TO_EC_STR_PARAM(brainpoolp320t1_r_square);
static const u8 brainpoolp320t1_mpinv[] = {
0x9e, 0x69,
};
TO_EC_STR_PARAM(brainpoolp320t1_mpinv);
static const u8 brainpoolp320t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp320t1_p_shift);
static const u8 brainpoolp320t1_p_normalized[] = {
0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
0xf9, 0x8f, 0xcf, 0xa6, 0xf6, 0xf4, 0x0d, 0xef,
0x4f, 0x92, 0xb9, 0xec, 0x78, 0x93, 0xec, 0x28,
0xfc, 0xd4, 0x12, 0xb1, 0xf1, 0xb3, 0x2e, 0x27,
};
TO_EC_STR_PARAM(brainpoolp320t1_p_normalized);
static const u8 brainpoolp320t1_p_reciprocal[] = {
0x36, 0x0e,
};
TO_EC_STR_PARAM(brainpoolp320t1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 brainpoolp320t1_a[] = {
0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
0xf9, 0x8f, 0xcf, 0xa6, 0xf6, 0xf4, 0x0d, 0xef,
0x4f, 0x92, 0xb9, 0xec, 0x78, 0x93, 0xec, 0x28,
0xfc, 0xd4, 0x12, 0xb1, 0xf1, 0xb3, 0x2e, 0x24,
};
TO_EC_STR_PARAM(brainpoolp320t1_a);
static const u8 brainpoolp320t1_b[] = {
0xa7, 0xf5, 0x61, 0xe0, 0x38, 0xeb, 0x1e, 0xd5,
0x60, 0xb3, 0xd1, 0x47, 0xdb, 0x78, 0x20, 0x13,
0x06, 0x4c, 0x19, 0xf2, 0x7e, 0xd2, 0x7c, 0x67,
0x80, 0xaa, 0xf7, 0x7f, 0xb8, 0xa5, 0x47, 0xce,
0xb5, 0xb4, 0xfe, 0xf4, 0x22, 0x34, 0x03, 0x53,
};
TO_EC_STR_PARAM(brainpoolp320t1_b);
#define CURVE_BRAINPOOLP320T1_CURVE_ORDER_BITLEN 320
static const u8 brainpoolp320t1_curve_order[] = {
0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
0xf9, 0x8f, 0xcf, 0xa5, 0xb6, 0x8f, 0x12, 0xa3,
0x2d, 0x48, 0x2e, 0xc7, 0xee, 0x86, 0x58, 0xe9,
0x86, 0x91, 0x55, 0x5b, 0x44, 0xc5, 0x93, 0x11,
};
TO_EC_STR_PARAM(brainpoolp320t1_curve_order);
static const u8 brainpoolp320t1_gx[] = {
0x92, 0x5b, 0xe9, 0xfb, 0x01, 0xaf, 0xc6, 0xfb,
0x4d, 0x3e, 0x7d, 0x49, 0x90, 0x01, 0x0f, 0x81,
0x34, 0x08, 0xab, 0x10, 0x6c, 0x4f, 0x09, 0xcb,
0x7e, 0xe0, 0x78, 0x68, 0xcc, 0x13, 0x6f, 0xff,
0x33, 0x57, 0xf6, 0x24, 0xa2, 0x1b, 0xed, 0x52,
};
TO_EC_STR_PARAM(brainpoolp320t1_gx);
static const u8 brainpoolp320t1_gy[] = {
0x63, 0xba, 0x3a, 0x7a, 0x27, 0x48, 0x3e, 0xbf,
0x66, 0x71, 0xdb, 0xef, 0x7a, 0xbb, 0x30, 0xeb,
0xee, 0x08, 0x4e, 0x58, 0xa0, 0xb0, 0x77, 0xad,
0x42, 0xa5, 0xa0, 0x98, 0x9d, 0x1e, 0xe7, 0x1b,
0x1b, 0x9b, 0xc0, 0x45, 0x5f, 0xb0, 0xd2, 0xc3,
};
TO_EC_STR_PARAM(brainpoolp320t1_gy);
static const u8 brainpoolp320t1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(brainpoolp320t1_gz);
static const u8 brainpoolp320t1_gen_order[] = {
0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
0xf9, 0x8f, 0xcf, 0xa5, 0xb6, 0x8f, 0x12, 0xa3,
0x2d, 0x48, 0x2e, 0xc7, 0xee, 0x86, 0x58, 0xe9,
0x86, 0x91, 0x55, 0x5b, 0x44, 0xc5, 0x93, 0x11,
};
TO_EC_STR_PARAM(brainpoolp320t1_gen_order);
#define CURVE_BRAINPOOLP320T1_Q_BITLEN 320
static const u8 brainpoolp320t1_gen_order_bitlen[] = {
0x01, 0x40,
};
TO_EC_STR_PARAM(brainpoolp320t1_gen_order_bitlen);
static const u8 brainpoolp320t1_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(brainpoolp320t1_cofactor);
static const u8 brainpoolp320t1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp320t1_alpha_montgomery, 0);
static const u8 brainpoolp320t1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp320t1_gamma_montgomery, 0);
static const u8 brainpoolp320t1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp320t1_alpha_edwards, 0);
static const u8 brainpoolp320t1_name[] = "BRAINPOOLP320T1";
TO_EC_STR_PARAM(brainpoolp320t1_name);
static const u8 brainpoolp320t1_oid[] = "1.3.36.3.3.2.8.1.1.10";
TO_EC_STR_PARAM(brainpoolp320t1_oid);
static const ec_str_params brainpoolp320t1_str_params = {
.p = &brainpoolp320t1_p_str_param,
.p_bitlen = &brainpoolp320t1_p_bitlen_str_param,
.r = &brainpoolp320t1_r_str_param,
.r_square = &brainpoolp320t1_r_square_str_param,
.mpinv = &brainpoolp320t1_mpinv_str_param,
.p_shift = &brainpoolp320t1_p_shift_str_param,
.p_normalized = &brainpoolp320t1_p_normalized_str_param,
.p_reciprocal = &brainpoolp320t1_p_reciprocal_str_param,
.a = &brainpoolp320t1_a_str_param,
.b = &brainpoolp320t1_b_str_param,
.curve_order = &brainpoolp320t1_curve_order_str_param,
.gx = &brainpoolp320t1_gx_str_param,
.gy = &brainpoolp320t1_gy_str_param,
.gz = &brainpoolp320t1_gz_str_param,
.gen_order = &brainpoolp320t1_gen_order_str_param,
.gen_order_bitlen = &brainpoolp320t1_gen_order_bitlen_str_param,
.cofactor = &brainpoolp320t1_cofactor_str_param,
.alpha_montgomery = &brainpoolp320t1_alpha_montgomery_str_param,
.gamma_montgomery = &brainpoolp320t1_gamma_montgomery_str_param,
.alpha_edwards = &brainpoolp320t1_alpha_edwards_str_param,
.oid = &brainpoolp320t1_oid_str_param,
.name = &brainpoolp320t1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_BRAINPOOLP320T1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_BRAINPOOLP320T1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_BRAINPOOLP320T1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_BRAINPOOLP320T1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BRAINPOOLP320T1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BRAINPOOLP320T1_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 29)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 29
#endif
#endif /* __EC_PARAMS_BRAINPOOLP320T1_H__ */
#endif /* WITH_CURVE_BRAINPOOLP320T1 */

View file

@ -0,0 +1,265 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_BRAINPOOLP384R1
#ifndef __EC_PARAMS_BRAINPOOLP384R1_H__
#define __EC_PARAMS_BRAINPOOLP384R1_H__
#include "ec_params_external.h"
static const u8 brainpoolp384r1_p[] = {
0x8C, 0xB9, 0x1E, 0x82, 0xA3, 0x38, 0x6D, 0x28,
0x0F, 0x5D, 0x6F, 0x7E, 0x50, 0xE6, 0x41, 0xDF,
0x15, 0x2F, 0x71, 0x09, 0xED, 0x54, 0x56, 0xB4,
0x12, 0xB1, 0xDA, 0x19, 0x7F, 0xB7, 0x11, 0x23,
0xAC, 0xD3, 0xA7, 0x29, 0x90, 0x1D, 0x1A, 0x71,
0x87, 0x47, 0x00, 0x13, 0x31, 0x07, 0xEC, 0x53
};
TO_EC_STR_PARAM(brainpoolp384r1_p);
#define CURVE_BRAINPOOLP384R1_P_BITLEN 384
static const u8 brainpoolp384r1_p_bitlen[] = { 0x01, 0x80 };
TO_EC_STR_PARAM(brainpoolp384r1_p_bitlen);
static const u8 brainpoolp384r1_r[] = {
0x73, 0x46, 0xE1, 0x7D, 0x5C, 0xC7, 0x92, 0xD7,
0xF0, 0xA2, 0x90, 0x81, 0xAF, 0x19, 0xBE, 0x20,
0xEA, 0xD0, 0x8E, 0xF6, 0x12, 0xAB, 0xA9, 0x4B,
0xED, 0x4E, 0x25, 0xE6, 0x80, 0x48, 0xEE, 0xDC,
0x53, 0x2C, 0x58, 0xD6, 0x6F, 0xE2, 0xE5, 0x8E,
0x78, 0xB8, 0xFF, 0xEC, 0xCE, 0xF8, 0x13, 0xAD
};
TO_EC_STR_PARAM(brainpoolp384r1_r);
static const u8 brainpoolp384r1_r_square[] = {
0x36, 0xBF, 0x68, 0x83, 0x17, 0x8D, 0xF8, 0x42,
0xD5, 0xC6, 0xEF, 0x3B, 0xA5, 0x7E, 0x05, 0x2C,
0x62, 0x14, 0x01, 0x91, 0x99, 0x18, 0xD5, 0xAF,
0x8E, 0x28, 0xF9, 0x9C, 0xC9, 0x94, 0x08, 0x99,
0x53, 0x52, 0x83, 0x34, 0x3D, 0x7F, 0xD9, 0x65,
0x08, 0x7C, 0xEF, 0xFF, 0x40, 0xB6, 0x4B, 0xDE
};
TO_EC_STR_PARAM(brainpoolp384r1_r_square);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 brainpoolp384r1_mpinv[] = {
0x9A, 0x6E, 0xA9, 0x6C, 0xEA, 0x9E, 0xC8, 0x25
};
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 brainpoolp384r1_mpinv[] = {
0xEA, 0x9E, 0xC8, 0x25
};
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 brainpoolp384r1_mpinv[] = {
0xC8, 0x25
};
#else /* unknown word size */
#error "Unsupported word size"
#endif
TO_EC_STR_PARAM(brainpoolp384r1_mpinv);
static const u8 brainpoolp384r1_p_shift[] = {
0x00
};
TO_EC_STR_PARAM(brainpoolp384r1_p_shift);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 brainpoolp384r1_p_reciprocal[] = {
0xD1, 0xB5, 0x75, 0xB1, 0x6D, 0x8E, 0xC6, 0xB8
};
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 brainpoolp384r1_p_reciprocal[] = {
0xD1, 0xB5, 0x75, 0xB1
};
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 brainpoolp384r1_p_reciprocal[] = {
0xD1, 0xB5
};
#else /* unknown word size */
#error "Unsupported word size"
#endif
TO_EC_STR_PARAM(brainpoolp384r1_p_reciprocal);
static const u8 brainpoolp384r1_a[] = {
0x7B, 0xC3, 0x82, 0xC6, 0x3D, 0x8C, 0x15, 0x0C,
0x3C, 0x72, 0x08, 0x0A, 0xCE, 0x05, 0xAF, 0xA0,
0xC2, 0xBE, 0xA2, 0x8E, 0x4F, 0xB2, 0x27, 0x87,
0x13, 0x91, 0x65, 0xEF, 0xBA, 0x91, 0xF9, 0x0F,
0x8A, 0xA5, 0x81, 0x4A, 0x50, 0x3A, 0xD4, 0xEB,
0x04, 0xA8, 0xC7, 0xDD, 0x22, 0xCE, 0x28, 0x26
};
TO_EC_STR_PARAM(brainpoolp384r1_a);
static const u8 brainpoolp384r1_b[] = {
0x04, 0xA8, 0xC7, 0xDD, 0x22, 0xCE, 0x28, 0x26,
0x8B, 0x39, 0xB5, 0x54, 0x16, 0xF0, 0x44, 0x7C,
0x2F, 0xB7, 0x7D, 0xE1, 0x07, 0xDC, 0xD2, 0xA6,
0x2E, 0x88, 0x0E, 0xA5, 0x3E, 0xEB, 0x62, 0xD5,
0x7C, 0xB4, 0x39, 0x02, 0x95, 0xDB, 0xC9, 0x94,
0x3A, 0xB7, 0x86, 0x96, 0xFA, 0x50, 0x4C, 0x11
};
TO_EC_STR_PARAM(brainpoolp384r1_b);
static const u8 brainpoolp384r1_curve_order[] = {
0x8C, 0xB9, 0x1E, 0x82, 0xA3, 0x38, 0x6D, 0x28,
0x0F, 0x5D, 0x6F, 0x7E, 0x50, 0xE6, 0x41, 0xDF,
0x15, 0x2F, 0x71, 0x09, 0xED, 0x54, 0x56, 0xB3,
0x1F, 0x16, 0x6E, 0x6C, 0xAC, 0x04, 0x25, 0xA7,
0xCF, 0x3A, 0xB6, 0xAF, 0x6B, 0x7F, 0xC3, 0x10,
0x3B, 0x88, 0x32, 0x02, 0xE9, 0x04, 0x65, 0x65
};
TO_EC_STR_PARAM(brainpoolp384r1_curve_order);
static const u8 brainpoolp384r1_gx[] = {
0x1D, 0x1C, 0x64, 0xF0, 0x68, 0xCF, 0x45, 0xFF,
0xA2, 0xA6, 0x3A, 0x81, 0xB7, 0xC1, 0x3F, 0x6B,
0x88, 0x47, 0xA3, 0xE7, 0x7E, 0xF1, 0x4F, 0xE3,
0xDB, 0x7F, 0xCA, 0xFE, 0x0C, 0xBD, 0x10, 0xE8,
0xE8, 0x26, 0xE0, 0x34, 0x36, 0xD6, 0x46, 0xAA,
0xEF, 0x87, 0xB2, 0xE2, 0x47, 0xD4, 0xAF, 0x1E
};
TO_EC_STR_PARAM(brainpoolp384r1_gx);
static const u8 brainpoolp384r1_gy[] = {
0x8A, 0xBE, 0x1D, 0x75, 0x20, 0xF9, 0xC2, 0xA4,
0x5C, 0xB1, 0xEB, 0x8E, 0x95, 0xCF, 0xD5, 0x52,
0x62, 0xB7, 0x0B, 0x29, 0xFE, 0xEC, 0x58, 0x64,
0xE1, 0x9C, 0x05, 0x4F, 0xF9, 0x91, 0x29, 0x28,
0x0E, 0x46, 0x46, 0x21, 0x77, 0x91, 0x81, 0x11,
0x42, 0x82, 0x03, 0x41, 0x26, 0x3C, 0x53, 0x15
};
TO_EC_STR_PARAM(brainpoolp384r1_gy);
static const u8 brainpoolp384r1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
};
TO_EC_STR_PARAM(brainpoolp384r1_gz);
#define CURVE_BRAINPOOLP384R1_CURVE_ORDER_BITLEN 384
static const u8 brainpoolp384r1_gen_order[] = {
0x8C, 0xB9, 0x1E, 0x82, 0xA3, 0x38, 0x6D, 0x28,
0x0F, 0x5D, 0x6F, 0x7E, 0x50, 0xE6, 0x41, 0xDF,
0x15, 0x2F, 0x71, 0x09, 0xED, 0x54, 0x56, 0xB3,
0x1F, 0x16, 0x6E, 0x6C, 0xAC, 0x04, 0x25, 0xA7,
0xCF, 0x3A, 0xB6, 0xAF, 0x6B, 0x7F, 0xC3, 0x10,
0x3B, 0x88, 0x32, 0x02, 0xE9, 0x04, 0x65, 0x65
};
TO_EC_STR_PARAM(brainpoolp384r1_gen_order);
#define CURVE_BRAINPOOLP384R1_Q_BITLEN 384
static const u8 brainpoolp384r1_gen_order_bitlen[] = { 0x01, 0x80 };
TO_EC_STR_PARAM(brainpoolp384r1_gen_order_bitlen);
static const u8 brainpoolp384r1_cofactor[] = { 0x01 };
TO_EC_STR_PARAM(brainpoolp384r1_cofactor);
static const u8 brainpoolp384r1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp384r1_alpha_montgomery, 0);
static const u8 brainpoolp384r1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp384r1_gamma_montgomery, 0);
static const u8 brainpoolp384r1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp384r1_alpha_edwards, 0);
static const u8 brainpoolp384r1_oid[] = "1.3.36.3.3.2.8.1.1.11";
TO_EC_STR_PARAM(brainpoolp384r1_oid);
static const u8 brainpoolp384r1_name[] = "BRAINPOOLP384R1";
TO_EC_STR_PARAM(brainpoolp384r1_name);
static const ec_str_params brainpoolp384r1_str_params = {
.p = &brainpoolp384r1_p_str_param,
.p_bitlen = &brainpoolp384r1_p_bitlen_str_param,
.r = &brainpoolp384r1_r_str_param,
.r_square = &brainpoolp384r1_r_square_str_param,
.mpinv = &brainpoolp384r1_mpinv_str_param,
.p_shift = &brainpoolp384r1_p_shift_str_param,
.p_normalized = &brainpoolp384r1_p_str_param,
.p_reciprocal = &brainpoolp384r1_p_reciprocal_str_param,
.a = &brainpoolp384r1_a_str_param,
.b = &brainpoolp384r1_b_str_param,
.curve_order = &brainpoolp384r1_curve_order_str_param,
.gx = &brainpoolp384r1_gx_str_param,
.gy = &brainpoolp384r1_gy_str_param,
.gz = &brainpoolp384r1_gz_str_param,
.gen_order = &brainpoolp384r1_gen_order_str_param,
.gen_order_bitlen = &brainpoolp384r1_gen_order_bitlen_str_param,
.cofactor = &brainpoolp384r1_cofactor_str_param,
.alpha_montgomery = &brainpoolp384r1_alpha_montgomery_str_param,
.gamma_montgomery = &brainpoolp384r1_gamma_montgomery_str_param,
.alpha_edwards = &brainpoolp384r1_alpha_edwards_str_param,
.oid = &brainpoolp384r1_oid_str_param,
.name = &brainpoolp384r1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_BRAINPOOLP384R1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_BRAINPOOLP384R1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_BRAINPOOLP384R1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_BRAINPOOLP384R1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BRAINPOOLP384R1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BRAINPOOLP384R1_CURVE_ORDER_BITLEN
#endif
#endif /* __EC_PARAMS_BRAINPOOLP384R1_H__ */
#endif /* WITH_CURVE_BRAINPOOLP384R1 */

View file

@ -0,0 +1,367 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_BRAINPOOLP384T1
#ifndef __EC_PARAMS_BRAINPOOLP384T1_H__
#define __EC_PARAMS_BRAINPOOLP384T1_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 brainpoolp384t1_p[] = {
0x8c, 0xb9, 0x1e, 0x82, 0xa3, 0x38, 0x6d, 0x28,
0x0f, 0x5d, 0x6f, 0x7e, 0x50, 0xe6, 0x41, 0xdf,
0x15, 0x2f, 0x71, 0x09, 0xed, 0x54, 0x56, 0xb4,
0x12, 0xb1, 0xda, 0x19, 0x7f, 0xb7, 0x11, 0x23,
0xac, 0xd3, 0xa7, 0x29, 0x90, 0x1d, 0x1a, 0x71,
0x87, 0x47, 0x00, 0x13, 0x31, 0x07, 0xec, 0x53,
};
TO_EC_STR_PARAM(brainpoolp384t1_p);
#define CURVE_BRAINPOOLP384T1_P_BITLEN 384
static const u8 brainpoolp384t1_p_bitlen[] = {
0x01, 0x80,
};
TO_EC_STR_PARAM(brainpoolp384t1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 brainpoolp384t1_r[] = {
0x73, 0x46, 0xe1, 0x7d, 0x5c, 0xc7, 0x92, 0xd7,
0xf0, 0xa2, 0x90, 0x81, 0xaf, 0x19, 0xbe, 0x20,
0xea, 0xd0, 0x8e, 0xf6, 0x12, 0xab, 0xa9, 0x4b,
0xed, 0x4e, 0x25, 0xe6, 0x80, 0x48, 0xee, 0xdc,
0x53, 0x2c, 0x58, 0xd6, 0x6f, 0xe2, 0xe5, 0x8e,
0x78, 0xb8, 0xff, 0xec, 0xce, 0xf8, 0x13, 0xad,
};
TO_EC_STR_PARAM(brainpoolp384t1_r);
static const u8 brainpoolp384t1_r_square[] = {
0x36, 0xbf, 0x68, 0x83, 0x17, 0x8d, 0xf8, 0x42,
0xd5, 0xc6, 0xef, 0x3b, 0xa5, 0x7e, 0x05, 0x2c,
0x62, 0x14, 0x01, 0x91, 0x99, 0x18, 0xd5, 0xaf,
0x8e, 0x28, 0xf9, 0x9c, 0xc9, 0x94, 0x08, 0x99,
0x53, 0x52, 0x83, 0x34, 0x3d, 0x7f, 0xd9, 0x65,
0x08, 0x7c, 0xef, 0xff, 0x40, 0xb6, 0x4b, 0xde,
};
TO_EC_STR_PARAM(brainpoolp384t1_r_square);
static const u8 brainpoolp384t1_mpinv[] = {
0x9a, 0x6e, 0xa9, 0x6c, 0xea, 0x9e, 0xc8, 0x25,
};
TO_EC_STR_PARAM(brainpoolp384t1_mpinv);
static const u8 brainpoolp384t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp384t1_p_shift);
static const u8 brainpoolp384t1_p_normalized[] = {
0x8c, 0xb9, 0x1e, 0x82, 0xa3, 0x38, 0x6d, 0x28,
0x0f, 0x5d, 0x6f, 0x7e, 0x50, 0xe6, 0x41, 0xdf,
0x15, 0x2f, 0x71, 0x09, 0xed, 0x54, 0x56, 0xb4,
0x12, 0xb1, 0xda, 0x19, 0x7f, 0xb7, 0x11, 0x23,
0xac, 0xd3, 0xa7, 0x29, 0x90, 0x1d, 0x1a, 0x71,
0x87, 0x47, 0x00, 0x13, 0x31, 0x07, 0xec, 0x53,
};
TO_EC_STR_PARAM(brainpoolp384t1_p_normalized);
static const u8 brainpoolp384t1_p_reciprocal[] = {
0xd1, 0xb5, 0x75, 0xb1, 0x6d, 0x8e, 0xc6, 0xb8,
};
TO_EC_STR_PARAM(brainpoolp384t1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 brainpoolp384t1_r[] = {
0x73, 0x46, 0xe1, 0x7d, 0x5c, 0xc7, 0x92, 0xd7,
0xf0, 0xa2, 0x90, 0x81, 0xaf, 0x19, 0xbe, 0x20,
0xea, 0xd0, 0x8e, 0xf6, 0x12, 0xab, 0xa9, 0x4b,
0xed, 0x4e, 0x25, 0xe6, 0x80, 0x48, 0xee, 0xdc,
0x53, 0x2c, 0x58, 0xd6, 0x6f, 0xe2, 0xe5, 0x8e,
0x78, 0xb8, 0xff, 0xec, 0xce, 0xf8, 0x13, 0xad,
};
TO_EC_STR_PARAM(brainpoolp384t1_r);
static const u8 brainpoolp384t1_r_square[] = {
0x36, 0xbf, 0x68, 0x83, 0x17, 0x8d, 0xf8, 0x42,
0xd5, 0xc6, 0xef, 0x3b, 0xa5, 0x7e, 0x05, 0x2c,
0x62, 0x14, 0x01, 0x91, 0x99, 0x18, 0xd5, 0xaf,
0x8e, 0x28, 0xf9, 0x9c, 0xc9, 0x94, 0x08, 0x99,
0x53, 0x52, 0x83, 0x34, 0x3d, 0x7f, 0xd9, 0x65,
0x08, 0x7c, 0xef, 0xff, 0x40, 0xb6, 0x4b, 0xde,
};
TO_EC_STR_PARAM(brainpoolp384t1_r_square);
static const u8 brainpoolp384t1_mpinv[] = {
0xea, 0x9e, 0xc8, 0x25,
};
TO_EC_STR_PARAM(brainpoolp384t1_mpinv);
static const u8 brainpoolp384t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp384t1_p_shift);
static const u8 brainpoolp384t1_p_normalized[] = {
0x8c, 0xb9, 0x1e, 0x82, 0xa3, 0x38, 0x6d, 0x28,
0x0f, 0x5d, 0x6f, 0x7e, 0x50, 0xe6, 0x41, 0xdf,
0x15, 0x2f, 0x71, 0x09, 0xed, 0x54, 0x56, 0xb4,
0x12, 0xb1, 0xda, 0x19, 0x7f, 0xb7, 0x11, 0x23,
0xac, 0xd3, 0xa7, 0x29, 0x90, 0x1d, 0x1a, 0x71,
0x87, 0x47, 0x00, 0x13, 0x31, 0x07, 0xec, 0x53,
};
TO_EC_STR_PARAM(brainpoolp384t1_p_normalized);
static const u8 brainpoolp384t1_p_reciprocal[] = {
0xd1, 0xb5, 0x75, 0xb1,
};
TO_EC_STR_PARAM(brainpoolp384t1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 brainpoolp384t1_r[] = {
0x73, 0x46, 0xe1, 0x7d, 0x5c, 0xc7, 0x92, 0xd7,
0xf0, 0xa2, 0x90, 0x81, 0xaf, 0x19, 0xbe, 0x20,
0xea, 0xd0, 0x8e, 0xf6, 0x12, 0xab, 0xa9, 0x4b,
0xed, 0x4e, 0x25, 0xe6, 0x80, 0x48, 0xee, 0xdc,
0x53, 0x2c, 0x58, 0xd6, 0x6f, 0xe2, 0xe5, 0x8e,
0x78, 0xb8, 0xff, 0xec, 0xce, 0xf8, 0x13, 0xad,
};
TO_EC_STR_PARAM(brainpoolp384t1_r);
static const u8 brainpoolp384t1_r_square[] = {
0x36, 0xbf, 0x68, 0x83, 0x17, 0x8d, 0xf8, 0x42,
0xd5, 0xc6, 0xef, 0x3b, 0xa5, 0x7e, 0x05, 0x2c,
0x62, 0x14, 0x01, 0x91, 0x99, 0x18, 0xd5, 0xaf,
0x8e, 0x28, 0xf9, 0x9c, 0xc9, 0x94, 0x08, 0x99,
0x53, 0x52, 0x83, 0x34, 0x3d, 0x7f, 0xd9, 0x65,
0x08, 0x7c, 0xef, 0xff, 0x40, 0xb6, 0x4b, 0xde,
};
TO_EC_STR_PARAM(brainpoolp384t1_r_square);
static const u8 brainpoolp384t1_mpinv[] = {
0xc8, 0x25,
};
TO_EC_STR_PARAM(brainpoolp384t1_mpinv);
static const u8 brainpoolp384t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp384t1_p_shift);
static const u8 brainpoolp384t1_p_normalized[] = {
0x8c, 0xb9, 0x1e, 0x82, 0xa3, 0x38, 0x6d, 0x28,
0x0f, 0x5d, 0x6f, 0x7e, 0x50, 0xe6, 0x41, 0xdf,
0x15, 0x2f, 0x71, 0x09, 0xed, 0x54, 0x56, 0xb4,
0x12, 0xb1, 0xda, 0x19, 0x7f, 0xb7, 0x11, 0x23,
0xac, 0xd3, 0xa7, 0x29, 0x90, 0x1d, 0x1a, 0x71,
0x87, 0x47, 0x00, 0x13, 0x31, 0x07, 0xec, 0x53,
};
TO_EC_STR_PARAM(brainpoolp384t1_p_normalized);
static const u8 brainpoolp384t1_p_reciprocal[] = {
0xd1, 0xb5,
};
TO_EC_STR_PARAM(brainpoolp384t1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 brainpoolp384t1_a[] = {
0x8c, 0xb9, 0x1e, 0x82, 0xa3, 0x38, 0x6d, 0x28,
0x0f, 0x5d, 0x6f, 0x7e, 0x50, 0xe6, 0x41, 0xdf,
0x15, 0x2f, 0x71, 0x09, 0xed, 0x54, 0x56, 0xb4,
0x12, 0xb1, 0xda, 0x19, 0x7f, 0xb7, 0x11, 0x23,
0xac, 0xd3, 0xa7, 0x29, 0x90, 0x1d, 0x1a, 0x71,
0x87, 0x47, 0x00, 0x13, 0x31, 0x07, 0xec, 0x50,
};
TO_EC_STR_PARAM(brainpoolp384t1_a);
static const u8 brainpoolp384t1_b[] = {
0x7f, 0x51, 0x9e, 0xad, 0xa7, 0xbd, 0xa8, 0x1b,
0xd8, 0x26, 0xdb, 0xa6, 0x47, 0x91, 0x0f, 0x8c,
0x4b, 0x93, 0x46, 0xed, 0x8c, 0xcd, 0xc6, 0x4e,
0x4b, 0x1a, 0xbd, 0x11, 0x75, 0x6d, 0xce, 0x1d,
0x20, 0x74, 0xaa, 0x26, 0x3b, 0x88, 0x80, 0x5c,
0xed, 0x70, 0x35, 0x5a, 0x33, 0xb4, 0x71, 0xee,
};
TO_EC_STR_PARAM(brainpoolp384t1_b);
#define CURVE_BRAINPOOLP384T1_CURVE_ORDER_BITLEN 384
static const u8 brainpoolp384t1_curve_order[] = {
0x8c, 0xb9, 0x1e, 0x82, 0xa3, 0x38, 0x6d, 0x28,
0x0f, 0x5d, 0x6f, 0x7e, 0x50, 0xe6, 0x41, 0xdf,
0x15, 0x2f, 0x71, 0x09, 0xed, 0x54, 0x56, 0xb3,
0x1f, 0x16, 0x6e, 0x6c, 0xac, 0x04, 0x25, 0xa7,
0xcf, 0x3a, 0xb6, 0xaf, 0x6b, 0x7f, 0xc3, 0x10,
0x3b, 0x88, 0x32, 0x02, 0xe9, 0x04, 0x65, 0x65,
};
TO_EC_STR_PARAM(brainpoolp384t1_curve_order);
static const u8 brainpoolp384t1_gx[] = {
0x18, 0xde, 0x98, 0xb0, 0x2d, 0xb9, 0xa3, 0x06,
0xf2, 0xaf, 0xcd, 0x72, 0x35, 0xf7, 0x2a, 0x81,
0x9b, 0x80, 0xab, 0x12, 0xeb, 0xd6, 0x53, 0x17,
0x24, 0x76, 0xfe, 0xcd, 0x46, 0x2a, 0xab, 0xff,
0xc4, 0xff, 0x19, 0x1b, 0x94, 0x6a, 0x5f, 0x54,
0xd8, 0xd0, 0xaa, 0x2f, 0x41, 0x88, 0x08, 0xcc,
};
TO_EC_STR_PARAM(brainpoolp384t1_gx);
static const u8 brainpoolp384t1_gy[] = {
0x25, 0xab, 0x05, 0x69, 0x62, 0xd3, 0x06, 0x51,
0xa1, 0x14, 0xaf, 0xd2, 0x75, 0x5a, 0xd3, 0x36,
0x74, 0x7f, 0x93, 0x47, 0x5b, 0x7a, 0x1f, 0xca,
0x3b, 0x88, 0xf2, 0xb6, 0xa2, 0x08, 0xcc, 0xfe,
0x46, 0x94, 0x08, 0x58, 0x4d, 0xc2, 0xb2, 0x91,
0x26, 0x75, 0xbf, 0x5b, 0x9e, 0x58, 0x29, 0x28,
};
TO_EC_STR_PARAM(brainpoolp384t1_gy);
static const u8 brainpoolp384t1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(brainpoolp384t1_gz);
static const u8 brainpoolp384t1_gen_order[] = {
0x8c, 0xb9, 0x1e, 0x82, 0xa3, 0x38, 0x6d, 0x28,
0x0f, 0x5d, 0x6f, 0x7e, 0x50, 0xe6, 0x41, 0xdf,
0x15, 0x2f, 0x71, 0x09, 0xed, 0x54, 0x56, 0xb3,
0x1f, 0x16, 0x6e, 0x6c, 0xac, 0x04, 0x25, 0xa7,
0xcf, 0x3a, 0xb6, 0xaf, 0x6b, 0x7f, 0xc3, 0x10,
0x3b, 0x88, 0x32, 0x02, 0xe9, 0x04, 0x65, 0x65,
};
TO_EC_STR_PARAM(brainpoolp384t1_gen_order);
#define CURVE_BRAINPOOLP384T1_Q_BITLEN 384
static const u8 brainpoolp384t1_gen_order_bitlen[] = {
0x01, 0x80,
};
TO_EC_STR_PARAM(brainpoolp384t1_gen_order_bitlen);
static const u8 brainpoolp384t1_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(brainpoolp384t1_cofactor);
static const u8 brainpoolp384t1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp384t1_alpha_montgomery, 0);
static const u8 brainpoolp384t1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp384t1_gamma_montgomery, 0);
static const u8 brainpoolp384t1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp384t1_alpha_edwards, 0);
static const u8 brainpoolp384t1_name[] = "BRAINPOOLP384T1";
TO_EC_STR_PARAM(brainpoolp384t1_name);
static const u8 brainpoolp384t1_oid[] = "1.3.36.3.3.2.8.1.1.12";
TO_EC_STR_PARAM(brainpoolp384t1_oid);
static const ec_str_params brainpoolp384t1_str_params = {
.p = &brainpoolp384t1_p_str_param,
.p_bitlen = &brainpoolp384t1_p_bitlen_str_param,
.r = &brainpoolp384t1_r_str_param,
.r_square = &brainpoolp384t1_r_square_str_param,
.mpinv = &brainpoolp384t1_mpinv_str_param,
.p_shift = &brainpoolp384t1_p_shift_str_param,
.p_normalized = &brainpoolp384t1_p_normalized_str_param,
.p_reciprocal = &brainpoolp384t1_p_reciprocal_str_param,
.a = &brainpoolp384t1_a_str_param,
.b = &brainpoolp384t1_b_str_param,
.curve_order = &brainpoolp384t1_curve_order_str_param,
.gx = &brainpoolp384t1_gx_str_param,
.gy = &brainpoolp384t1_gy_str_param,
.gz = &brainpoolp384t1_gz_str_param,
.gen_order = &brainpoolp384t1_gen_order_str_param,
.gen_order_bitlen = &brainpoolp384t1_gen_order_bitlen_str_param,
.cofactor = &brainpoolp384t1_cofactor_str_param,
.alpha_montgomery = &brainpoolp384t1_alpha_montgomery_str_param,
.gamma_montgomery = &brainpoolp384t1_gamma_montgomery_str_param,
.alpha_edwards = &brainpoolp384t1_alpha_edwards_str_param,
.oid = &brainpoolp384t1_oid_str_param,
.name = &brainpoolp384t1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_BRAINPOOLP384T1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_BRAINPOOLP384T1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_BRAINPOOLP384T1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_BRAINPOOLP384T1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BRAINPOOLP384T1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BRAINPOOLP384T1_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 29)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 29
#endif
#endif /* __EC_PARAMS_BRAINPOOLP384T1_H__ */
#endif /* WITH_CURVE_BRAINPOOLP384T1 */

View file

@ -0,0 +1,276 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_BRAINPOOLP512R1
#ifndef __EC_PARAMS_BRAINPOOLP512R1_H__
#define __EC_PARAMS_BRAINPOOLP512R1_H__
#include "ec_params_external.h"
static const u8 brainpoolp512r1_p[] = {
0xAA, 0xDD, 0x9D, 0xB8, 0xDB, 0xE9, 0xC4, 0x8B,
0x3F, 0xD4, 0xE6, 0xAE, 0x33, 0xC9, 0xFC, 0x07,
0xCB, 0x30, 0x8D, 0xB3, 0xB3, 0xC9, 0xD2, 0x0E,
0xD6, 0x63, 0x9C, 0xCA, 0x70, 0x33, 0x08, 0x71,
0x7D, 0x4D, 0x9B, 0x00, 0x9B, 0xC6, 0x68, 0x42,
0xAE, 0xCD, 0xA1, 0x2A, 0xE6, 0xA3, 0x80, 0xE6,
0x28, 0x81, 0xFF, 0x2F, 0x2D, 0x82, 0xC6, 0x85,
0x28, 0xAA, 0x60, 0x56, 0x58, 0x3A, 0x48, 0xF3
};
TO_EC_STR_PARAM(brainpoolp512r1_p);
#define CURVE_BRAINPOOLP512R1_P_BITLEN 512
static const u8 brainpoolp512r1_p_bitlen[] = { 0x02, 0x00 };
TO_EC_STR_PARAM(brainpoolp512r1_p_bitlen);
static const u8 brainpoolp512r1_r[] = {
0x55, 0x22, 0x62, 0x47, 0x24, 0x16, 0x3b, 0x74,
0xc0, 0x2b, 0x19, 0x51, 0xcc, 0x36, 0x03, 0xf8,
0x34, 0xcf, 0x72, 0x4c, 0x4c, 0x36, 0x2d, 0xf1,
0x29, 0x9c, 0x63, 0x35, 0x8f, 0xcc, 0xf7, 0x8e,
0x82, 0xb2, 0x64, 0xff, 0x64, 0x39, 0x97, 0xbd,
0x51, 0x32, 0x5e, 0xd5, 0x19, 0x5c, 0x7f, 0x19,
0xd7, 0x7e, 0x00, 0xd0, 0xd2, 0x7d, 0x39, 0x7a,
0xd7, 0x55, 0x9f, 0xa9, 0xa7, 0xc5, 0xb7, 0x0d
};
TO_EC_STR_PARAM(brainpoolp512r1_r);
static const u8 brainpoolp512r1_r_square[] = {
0x3c, 0x4c, 0x9d, 0x05, 0xa9, 0xff, 0x64, 0x50,
0x20, 0x2e, 0x19, 0x40, 0x20, 0x56, 0xee, 0xcc,
0xa1, 0x6d, 0xaa, 0x5f, 0xd4, 0x2b, 0xff, 0x83,
0x19, 0x48, 0x6f, 0xd8, 0xd5, 0x89, 0x80, 0x57,
0xe0, 0xc1, 0x9a, 0x77, 0x83, 0x51, 0x4a, 0x25,
0x53, 0xb7, 0xf9, 0xbc, 0x90, 0x5a, 0xff, 0xd3,
0x79, 0x3f, 0xb1, 0x30, 0x27, 0x15, 0x79, 0x05,
0x49, 0xad, 0x14, 0x4a, 0x61, 0x58, 0xf2, 0x05
};
TO_EC_STR_PARAM(brainpoolp512r1_r_square);
/*
* mpinv is -p^-1 mod 2^(bitsizeof(hword_t)), this means it depends
* on word size.
*/
static const u8 brainpoolp512r1_mpinv[] = {
0x83, 0x9b, 0x32, 0x20, 0x7d, 0x89, 0xef, 0xc5
};
TO_EC_STR_PARAM(brainpoolp512r1_mpinv);
static const u8 brainpoolp512r1_p_shift[] = {
0x00
};
TO_EC_STR_PARAM(brainpoolp512r1_p_shift);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 brainpoolp512r1_p_reciprocal[] = {
0x7f, 0x8d, 0x7f, 0x4e, 0xd6, 0xda, 0xeb, 0x8a
};
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 brainpoolp512r1_p_reciprocal[] = {
0x7f, 0x8d, 0x7f, 0x4e
};
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 brainpoolp512r1_p_reciprocal[] = {
0x7f, 0x8d
};
#else /* unknown word size */
#error "Unsupported word size"
#endif
TO_EC_STR_PARAM(brainpoolp512r1_p_reciprocal);
static const u8 brainpoolp512r1_a[] = {
0x78, 0x30, 0xA3, 0x31, 0x8B, 0x60, 0x3B, 0x89,
0xE2, 0x32, 0x71, 0x45, 0xAC, 0x23, 0x4C, 0xC5,
0x94, 0xCB, 0xDD, 0x8D, 0x3D, 0xF9, 0x16, 0x10,
0xA8, 0x34, 0x41, 0xCA, 0xEA, 0x98, 0x63, 0xBC,
0x2D, 0xED, 0x5D, 0x5A, 0xA8, 0x25, 0x3A, 0xA1,
0x0A, 0x2E, 0xF1, 0xC9, 0x8B, 0x9A, 0xC8, 0xB5,
0x7F, 0x11, 0x17, 0xA7, 0x2B, 0xF2, 0xC7, 0xB9,
0xE7, 0xC1, 0xAC, 0x4D, 0x77, 0xFC, 0x94, 0xCA
};
TO_EC_STR_PARAM(brainpoolp512r1_a);
static const u8 brainpoolp512r1_b[] = {
0x3D, 0xF9, 0x16, 0x10, 0xA8, 0x34, 0x41, 0xCA,
0xEA, 0x98, 0x63, 0xBC, 0x2D, 0xED, 0x5D, 0x5A,
0xA8, 0x25, 0x3A, 0xA1, 0x0A, 0x2E, 0xF1, 0xC9,
0x8B, 0x9A, 0xC8, 0xB5, 0x7F, 0x11, 0x17, 0xA7,
0x2B, 0xF2, 0xC7, 0xB9, 0xE7, 0xC1, 0xAC, 0x4D,
0x77, 0xFC, 0x94, 0xCA, 0xDC, 0x08, 0x3E, 0x67,
0x98, 0x40, 0x50, 0xB7, 0x5E, 0xBA, 0xE5, 0xDD,
0x28, 0x09, 0xBD, 0x63, 0x80, 0x16, 0xF7, 0x23
};
TO_EC_STR_PARAM(brainpoolp512r1_b);
#define CURVE_BRAINPOOLP512R1_CURVE_ORDER_BITLEN 512
static const u8 brainpoolp512r1_curve_order[] = {
0xAA, 0xDD, 0x9D, 0xB8, 0xDB, 0xE9, 0xC4, 0x8B,
0x3F, 0xD4, 0xE6, 0xAE, 0x33, 0xC9, 0xFC, 0x07,
0xCB, 0x30, 0x8D, 0xB3, 0xB3, 0xC9, 0xD2, 0x0E,
0xD6, 0x63, 0x9C, 0xCA, 0x70, 0x33, 0x08, 0x70,
0x55, 0x3E, 0x5C, 0x41, 0x4C, 0xA9, 0x26, 0x19,
0x41, 0x86, 0x61, 0x19, 0x7F, 0xAC, 0x10, 0x47,
0x1D, 0xB1, 0xD3, 0x81, 0x08, 0x5D, 0xDA, 0xDD,
0xB5, 0x87, 0x96, 0x82, 0x9C, 0xA9, 0x00, 0x69
};
TO_EC_STR_PARAM(brainpoolp512r1_curve_order);
static const u8 brainpoolp512r1_gx[] = {
0x81, 0xAE, 0xE4, 0xBD, 0xD8, 0x2E, 0xD9, 0x64,
0x5A, 0x21, 0x32, 0x2E, 0x9C, 0x4C, 0x6A, 0x93,
0x85, 0xED, 0x9F, 0x70, 0xB5, 0xD9, 0x16, 0xC1,
0xB4, 0x3B, 0x62, 0xEE, 0xF4, 0xD0, 0x09, 0x8E,
0xFF, 0x3B, 0x1F, 0x78, 0xE2, 0xD0, 0xD4, 0x8D,
0x50, 0xD1, 0x68, 0x7B, 0x93, 0xB9, 0x7D, 0x5F,
0x7C, 0x6D, 0x50, 0x47, 0x40, 0x6A, 0x5E, 0x68,
0x8B, 0x35, 0x22, 0x09, 0xBC, 0xB9, 0xF8, 0x22,
};
TO_EC_STR_PARAM(brainpoolp512r1_gx);
static const u8 brainpoolp512r1_gy[] = {
0x7D, 0xDE, 0x38, 0x5D, 0x56, 0x63, 0x32, 0xEC,
0xC0, 0xEA, 0xBF, 0xA9, 0xCF, 0x78, 0x22, 0xFD,
0xF2, 0x09, 0xF7, 0x00, 0x24, 0xA5, 0x7B, 0x1A,
0xA0, 0x00, 0xC5, 0x5B, 0x88, 0x1F, 0x81, 0x11,
0xB2, 0xDC, 0xDE, 0x49, 0x4A, 0x5F, 0x48, 0x5E,
0x5B, 0xCA, 0x4B, 0xD8, 0x8A, 0x27, 0x63, 0xAE,
0xD1, 0xCA, 0x2B, 0x2F, 0xA8, 0xF0, 0x54, 0x06,
0x78, 0xCD, 0x1E, 0x0F, 0x3A, 0xD8, 0x08, 0x92
};
TO_EC_STR_PARAM(brainpoolp512r1_gy);
static const u8 brainpoolp512r1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
};
TO_EC_STR_PARAM(brainpoolp512r1_gz);
static const u8 brainpoolp512r1_gen_order[] = {
0xAA, 0xDD, 0x9D, 0xB8, 0xDB, 0xE9, 0xC4, 0x8B,
0x3F, 0xD4, 0xE6, 0xAE, 0x33, 0xC9, 0xFC, 0x07,
0xCB, 0x30, 0x8D, 0xB3, 0xB3, 0xC9, 0xD2, 0x0E,
0xD6, 0x63, 0x9C, 0xCA, 0x70, 0x33, 0x08, 0x70,
0x55, 0x3E, 0x5C, 0x41, 0x4C, 0xA9, 0x26, 0x19,
0x41, 0x86, 0x61, 0x19, 0x7F, 0xAC, 0x10, 0x47,
0x1D, 0xB1, 0xD3, 0x81, 0x08, 0x5D, 0xDA, 0xDD,
0xB5, 0x87, 0x96, 0x82, 0x9C, 0xA9, 0x00, 0x69
};
TO_EC_STR_PARAM(brainpoolp512r1_gen_order);
#define CURVE_BRAINPOOLP512R1_Q_BITLEN 512
static const u8 brainpoolp512r1_gen_order_bitlen[] = { 0x02, 0x00 };
TO_EC_STR_PARAM(brainpoolp512r1_gen_order_bitlen);
static const u8 brainpoolp512r1_cofactor[] = { 0x01 };
TO_EC_STR_PARAM(brainpoolp512r1_cofactor);
static const u8 brainpoolp512r1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp512r1_alpha_montgomery, 0);
static const u8 brainpoolp512r1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp512r1_gamma_montgomery, 0);
static const u8 brainpoolp512r1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp512r1_alpha_edwards, 0);
static const u8 brainpoolp512r1_oid[] = "1.3.36.3.3.2.8.1.1.13";
TO_EC_STR_PARAM(brainpoolp512r1_oid);
static const u8 brainpoolp512r1_name[] = "BRAINPOOLP512R1";
TO_EC_STR_PARAM(brainpoolp512r1_name);
static const ec_str_params brainpoolp512r1_str_params = {
.p = &brainpoolp512r1_p_str_param,
.p_bitlen = &brainpoolp512r1_p_bitlen_str_param,
.r = &brainpoolp512r1_r_str_param,
.r_square = &brainpoolp512r1_r_square_str_param,
.mpinv = &brainpoolp512r1_mpinv_str_param,
.p_shift = &brainpoolp512r1_p_shift_str_param,
.p_normalized = &brainpoolp512r1_p_str_param,
.p_reciprocal = &brainpoolp512r1_p_reciprocal_str_param,
.a = &brainpoolp512r1_a_str_param,
.b = &brainpoolp512r1_b_str_param,
.curve_order = &brainpoolp512r1_curve_order_str_param,
.gx = &brainpoolp512r1_gx_str_param,
.gy = &brainpoolp512r1_gy_str_param,
.gz = &brainpoolp512r1_gz_str_param,
.gen_order = &brainpoolp512r1_gen_order_str_param,
.gen_order_bitlen = &brainpoolp512r1_gen_order_bitlen_str_param,
.cofactor = &brainpoolp512r1_cofactor_str_param,
.alpha_montgomery = &brainpoolp512r1_alpha_montgomery_str_param,
.gamma_montgomery = &brainpoolp512r1_gamma_montgomery_str_param,
.alpha_edwards = &brainpoolp512r1_alpha_edwards_str_param,
.oid = &brainpoolp512r1_oid_str_param,
.name = &brainpoolp512r1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_BRAINPOOLP512R1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_BRAINPOOLP512R1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_BRAINPOOLP512R1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_BRAINPOOLP512R1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BRAINPOOLP512R1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BRAINPOOLP512R1_CURVE_ORDER_BITLEN
#endif
#endif /* __EC_PARAMS_BRAINPOOLP512R1_H__ */
#endif /* WITH_CURVE_BRAINPOOLP512R1 */

View file

@ -0,0 +1,401 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_BRAINPOOLP512T1
#ifndef __EC_PARAMS_BRAINPOOLP512T1_H__
#define __EC_PARAMS_BRAINPOOLP512T1_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 brainpoolp512t1_p[] = {
0xaa, 0xdd, 0x9d, 0xb8, 0xdb, 0xe9, 0xc4, 0x8b,
0x3f, 0xd4, 0xe6, 0xae, 0x33, 0xc9, 0xfc, 0x07,
0xcb, 0x30, 0x8d, 0xb3, 0xb3, 0xc9, 0xd2, 0x0e,
0xd6, 0x63, 0x9c, 0xca, 0x70, 0x33, 0x08, 0x71,
0x7d, 0x4d, 0x9b, 0x00, 0x9b, 0xc6, 0x68, 0x42,
0xae, 0xcd, 0xa1, 0x2a, 0xe6, 0xa3, 0x80, 0xe6,
0x28, 0x81, 0xff, 0x2f, 0x2d, 0x82, 0xc6, 0x85,
0x28, 0xaa, 0x60, 0x56, 0x58, 0x3a, 0x48, 0xf3,
};
TO_EC_STR_PARAM(brainpoolp512t1_p);
#define CURVE_BRAINPOOLP512T1_P_BITLEN 512
static const u8 brainpoolp512t1_p_bitlen[] = {
0x02, 0x00,
};
TO_EC_STR_PARAM(brainpoolp512t1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 brainpoolp512t1_r[] = {
0x55, 0x22, 0x62, 0x47, 0x24, 0x16, 0x3b, 0x74,
0xc0, 0x2b, 0x19, 0x51, 0xcc, 0x36, 0x03, 0xf8,
0x34, 0xcf, 0x72, 0x4c, 0x4c, 0x36, 0x2d, 0xf1,
0x29, 0x9c, 0x63, 0x35, 0x8f, 0xcc, 0xf7, 0x8e,
0x82, 0xb2, 0x64, 0xff, 0x64, 0x39, 0x97, 0xbd,
0x51, 0x32, 0x5e, 0xd5, 0x19, 0x5c, 0x7f, 0x19,
0xd7, 0x7e, 0x00, 0xd0, 0xd2, 0x7d, 0x39, 0x7a,
0xd7, 0x55, 0x9f, 0xa9, 0xa7, 0xc5, 0xb7, 0x0d,
};
TO_EC_STR_PARAM(brainpoolp512t1_r);
static const u8 brainpoolp512t1_r_square[] = {
0x3c, 0x4c, 0x9d, 0x05, 0xa9, 0xff, 0x64, 0x50,
0x20, 0x2e, 0x19, 0x40, 0x20, 0x56, 0xee, 0xcc,
0xa1, 0x6d, 0xaa, 0x5f, 0xd4, 0x2b, 0xff, 0x83,
0x19, 0x48, 0x6f, 0xd8, 0xd5, 0x89, 0x80, 0x57,
0xe0, 0xc1, 0x9a, 0x77, 0x83, 0x51, 0x4a, 0x25,
0x53, 0xb7, 0xf9, 0xbc, 0x90, 0x5a, 0xff, 0xd3,
0x79, 0x3f, 0xb1, 0x30, 0x27, 0x15, 0x79, 0x05,
0x49, 0xad, 0x14, 0x4a, 0x61, 0x58, 0xf2, 0x05,
};
TO_EC_STR_PARAM(brainpoolp512t1_r_square);
static const u8 brainpoolp512t1_mpinv[] = {
0x83, 0x9b, 0x32, 0x20, 0x7d, 0x89, 0xef, 0xc5,
};
TO_EC_STR_PARAM(brainpoolp512t1_mpinv);
static const u8 brainpoolp512t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp512t1_p_shift);
static const u8 brainpoolp512t1_p_normalized[] = {
0xaa, 0xdd, 0x9d, 0xb8, 0xdb, 0xe9, 0xc4, 0x8b,
0x3f, 0xd4, 0xe6, 0xae, 0x33, 0xc9, 0xfc, 0x07,
0xcb, 0x30, 0x8d, 0xb3, 0xb3, 0xc9, 0xd2, 0x0e,
0xd6, 0x63, 0x9c, 0xca, 0x70, 0x33, 0x08, 0x71,
0x7d, 0x4d, 0x9b, 0x00, 0x9b, 0xc6, 0x68, 0x42,
0xae, 0xcd, 0xa1, 0x2a, 0xe6, 0xa3, 0x80, 0xe6,
0x28, 0x81, 0xff, 0x2f, 0x2d, 0x82, 0xc6, 0x85,
0x28, 0xaa, 0x60, 0x56, 0x58, 0x3a, 0x48, 0xf3,
};
TO_EC_STR_PARAM(brainpoolp512t1_p_normalized);
static const u8 brainpoolp512t1_p_reciprocal[] = {
0x7f, 0x8d, 0x7f, 0x4e, 0xd6, 0xda, 0xeb, 0x8a,
};
TO_EC_STR_PARAM(brainpoolp512t1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 brainpoolp512t1_r[] = {
0x55, 0x22, 0x62, 0x47, 0x24, 0x16, 0x3b, 0x74,
0xc0, 0x2b, 0x19, 0x51, 0xcc, 0x36, 0x03, 0xf8,
0x34, 0xcf, 0x72, 0x4c, 0x4c, 0x36, 0x2d, 0xf1,
0x29, 0x9c, 0x63, 0x35, 0x8f, 0xcc, 0xf7, 0x8e,
0x82, 0xb2, 0x64, 0xff, 0x64, 0x39, 0x97, 0xbd,
0x51, 0x32, 0x5e, 0xd5, 0x19, 0x5c, 0x7f, 0x19,
0xd7, 0x7e, 0x00, 0xd0, 0xd2, 0x7d, 0x39, 0x7a,
0xd7, 0x55, 0x9f, 0xa9, 0xa7, 0xc5, 0xb7, 0x0d,
};
TO_EC_STR_PARAM(brainpoolp512t1_r);
static const u8 brainpoolp512t1_r_square[] = {
0x3c, 0x4c, 0x9d, 0x05, 0xa9, 0xff, 0x64, 0x50,
0x20, 0x2e, 0x19, 0x40, 0x20, 0x56, 0xee, 0xcc,
0xa1, 0x6d, 0xaa, 0x5f, 0xd4, 0x2b, 0xff, 0x83,
0x19, 0x48, 0x6f, 0xd8, 0xd5, 0x89, 0x80, 0x57,
0xe0, 0xc1, 0x9a, 0x77, 0x83, 0x51, 0x4a, 0x25,
0x53, 0xb7, 0xf9, 0xbc, 0x90, 0x5a, 0xff, 0xd3,
0x79, 0x3f, 0xb1, 0x30, 0x27, 0x15, 0x79, 0x05,
0x49, 0xad, 0x14, 0x4a, 0x61, 0x58, 0xf2, 0x05,
};
TO_EC_STR_PARAM(brainpoolp512t1_r_square);
static const u8 brainpoolp512t1_mpinv[] = {
0x7d, 0x89, 0xef, 0xc5,
};
TO_EC_STR_PARAM(brainpoolp512t1_mpinv);
static const u8 brainpoolp512t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp512t1_p_shift);
static const u8 brainpoolp512t1_p_normalized[] = {
0xaa, 0xdd, 0x9d, 0xb8, 0xdb, 0xe9, 0xc4, 0x8b,
0x3f, 0xd4, 0xe6, 0xae, 0x33, 0xc9, 0xfc, 0x07,
0xcb, 0x30, 0x8d, 0xb3, 0xb3, 0xc9, 0xd2, 0x0e,
0xd6, 0x63, 0x9c, 0xca, 0x70, 0x33, 0x08, 0x71,
0x7d, 0x4d, 0x9b, 0x00, 0x9b, 0xc6, 0x68, 0x42,
0xae, 0xcd, 0xa1, 0x2a, 0xe6, 0xa3, 0x80, 0xe6,
0x28, 0x81, 0xff, 0x2f, 0x2d, 0x82, 0xc6, 0x85,
0x28, 0xaa, 0x60, 0x56, 0x58, 0x3a, 0x48, 0xf3,
};
TO_EC_STR_PARAM(brainpoolp512t1_p_normalized);
static const u8 brainpoolp512t1_p_reciprocal[] = {
0x7f, 0x8d, 0x7f, 0x4e,
};
TO_EC_STR_PARAM(brainpoolp512t1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 brainpoolp512t1_r[] = {
0x55, 0x22, 0x62, 0x47, 0x24, 0x16, 0x3b, 0x74,
0xc0, 0x2b, 0x19, 0x51, 0xcc, 0x36, 0x03, 0xf8,
0x34, 0xcf, 0x72, 0x4c, 0x4c, 0x36, 0x2d, 0xf1,
0x29, 0x9c, 0x63, 0x35, 0x8f, 0xcc, 0xf7, 0x8e,
0x82, 0xb2, 0x64, 0xff, 0x64, 0x39, 0x97, 0xbd,
0x51, 0x32, 0x5e, 0xd5, 0x19, 0x5c, 0x7f, 0x19,
0xd7, 0x7e, 0x00, 0xd0, 0xd2, 0x7d, 0x39, 0x7a,
0xd7, 0x55, 0x9f, 0xa9, 0xa7, 0xc5, 0xb7, 0x0d,
};
TO_EC_STR_PARAM(brainpoolp512t1_r);
static const u8 brainpoolp512t1_r_square[] = {
0x3c, 0x4c, 0x9d, 0x05, 0xa9, 0xff, 0x64, 0x50,
0x20, 0x2e, 0x19, 0x40, 0x20, 0x56, 0xee, 0xcc,
0xa1, 0x6d, 0xaa, 0x5f, 0xd4, 0x2b, 0xff, 0x83,
0x19, 0x48, 0x6f, 0xd8, 0xd5, 0x89, 0x80, 0x57,
0xe0, 0xc1, 0x9a, 0x77, 0x83, 0x51, 0x4a, 0x25,
0x53, 0xb7, 0xf9, 0xbc, 0x90, 0x5a, 0xff, 0xd3,
0x79, 0x3f, 0xb1, 0x30, 0x27, 0x15, 0x79, 0x05,
0x49, 0xad, 0x14, 0x4a, 0x61, 0x58, 0xf2, 0x05,
};
TO_EC_STR_PARAM(brainpoolp512t1_r_square);
static const u8 brainpoolp512t1_mpinv[] = {
0xef, 0xc5,
};
TO_EC_STR_PARAM(brainpoolp512t1_mpinv);
static const u8 brainpoolp512t1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(brainpoolp512t1_p_shift);
static const u8 brainpoolp512t1_p_normalized[] = {
0xaa, 0xdd, 0x9d, 0xb8, 0xdb, 0xe9, 0xc4, 0x8b,
0x3f, 0xd4, 0xe6, 0xae, 0x33, 0xc9, 0xfc, 0x07,
0xcb, 0x30, 0x8d, 0xb3, 0xb3, 0xc9, 0xd2, 0x0e,
0xd6, 0x63, 0x9c, 0xca, 0x70, 0x33, 0x08, 0x71,
0x7d, 0x4d, 0x9b, 0x00, 0x9b, 0xc6, 0x68, 0x42,
0xae, 0xcd, 0xa1, 0x2a, 0xe6, 0xa3, 0x80, 0xe6,
0x28, 0x81, 0xff, 0x2f, 0x2d, 0x82, 0xc6, 0x85,
0x28, 0xaa, 0x60, 0x56, 0x58, 0x3a, 0x48, 0xf3,
};
TO_EC_STR_PARAM(brainpoolp512t1_p_normalized);
static const u8 brainpoolp512t1_p_reciprocal[] = {
0x7f, 0x8d,
};
TO_EC_STR_PARAM(brainpoolp512t1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 brainpoolp512t1_a[] = {
0xaa, 0xdd, 0x9d, 0xb8, 0xdb, 0xe9, 0xc4, 0x8b,
0x3f, 0xd4, 0xe6, 0xae, 0x33, 0xc9, 0xfc, 0x07,
0xcb, 0x30, 0x8d, 0xb3, 0xb3, 0xc9, 0xd2, 0x0e,
0xd6, 0x63, 0x9c, 0xca, 0x70, 0x33, 0x08, 0x71,
0x7d, 0x4d, 0x9b, 0x00, 0x9b, 0xc6, 0x68, 0x42,
0xae, 0xcd, 0xa1, 0x2a, 0xe6, 0xa3, 0x80, 0xe6,
0x28, 0x81, 0xff, 0x2f, 0x2d, 0x82, 0xc6, 0x85,
0x28, 0xaa, 0x60, 0x56, 0x58, 0x3a, 0x48, 0xf0,
};
TO_EC_STR_PARAM(brainpoolp512t1_a);
static const u8 brainpoolp512t1_b[] = {
0x7c, 0xbb, 0xbc, 0xf9, 0x44, 0x1c, 0xfa, 0xb7,
0x6e, 0x18, 0x90, 0xe4, 0x68, 0x84, 0xea, 0xe3,
0x21, 0xf7, 0x0c, 0x0b, 0xcb, 0x49, 0x81, 0x52,
0x78, 0x97, 0x50, 0x4b, 0xec, 0x3e, 0x36, 0xa6,
0x2b, 0xcd, 0xfa, 0x23, 0x04, 0x97, 0x65, 0x40,
0xf6, 0x45, 0x00, 0x85, 0xf2, 0xda, 0xe1, 0x45,
0xc2, 0x25, 0x53, 0xb4, 0x65, 0x76, 0x36, 0x89,
0x18, 0x0e, 0xa2, 0x57, 0x18, 0x67, 0x42, 0x3e,
};
TO_EC_STR_PARAM(brainpoolp512t1_b);
#define CURVE_BRAINPOOLP512T1_CURVE_ORDER_BITLEN 512
static const u8 brainpoolp512t1_curve_order[] = {
0xaa, 0xdd, 0x9d, 0xb8, 0xdb, 0xe9, 0xc4, 0x8b,
0x3f, 0xd4, 0xe6, 0xae, 0x33, 0xc9, 0xfc, 0x07,
0xcb, 0x30, 0x8d, 0xb3, 0xb3, 0xc9, 0xd2, 0x0e,
0xd6, 0x63, 0x9c, 0xca, 0x70, 0x33, 0x08, 0x70,
0x55, 0x3e, 0x5c, 0x41, 0x4c, 0xa9, 0x26, 0x19,
0x41, 0x86, 0x61, 0x19, 0x7f, 0xac, 0x10, 0x47,
0x1d, 0xb1, 0xd3, 0x81, 0x08, 0x5d, 0xda, 0xdd,
0xb5, 0x87, 0x96, 0x82, 0x9c, 0xa9, 0x00, 0x69,
};
TO_EC_STR_PARAM(brainpoolp512t1_curve_order);
static const u8 brainpoolp512t1_gx[] = {
0x64, 0x0e, 0xce, 0x5c, 0x12, 0x78, 0x87, 0x17,
0xb9, 0xc1, 0xba, 0x06, 0xcb, 0xc2, 0xa6, 0xfe,
0xba, 0x85, 0x84, 0x24, 0x58, 0xc5, 0x6d, 0xde,
0x9d, 0xb1, 0x75, 0x8d, 0x39, 0xc0, 0x31, 0x3d,
0x82, 0xba, 0x51, 0x73, 0x5c, 0xdb, 0x3e, 0xa4,
0x99, 0xaa, 0x77, 0xa7, 0xd6, 0x94, 0x3a, 0x64,
0xf7, 0xa3, 0xf2, 0x5f, 0xe2, 0x6f, 0x06, 0xb5,
0x1b, 0xaa, 0x26, 0x96, 0xfa, 0x90, 0x35, 0xda,
};
TO_EC_STR_PARAM(brainpoolp512t1_gx);
static const u8 brainpoolp512t1_gy[] = {
0x5b, 0x53, 0x4b, 0xd5, 0x95, 0xf5, 0xaf, 0x0f,
0xa2, 0xc8, 0x92, 0x37, 0x6c, 0x84, 0xac, 0xe1,
0xbb, 0x4e, 0x30, 0x19, 0xb7, 0x16, 0x34, 0xc0,
0x11, 0x31, 0x15, 0x9c, 0xae, 0x03, 0xce, 0xe9,
0xd9, 0x93, 0x21, 0x84, 0xbe, 0xef, 0x21, 0x6b,
0xd7, 0x1d, 0xf2, 0xda, 0xdf, 0x86, 0xa6, 0x27,
0x30, 0x6e, 0xcf, 0xf9, 0x6d, 0xbb, 0x8b, 0xac,
0xe1, 0x98, 0xb6, 0x1e, 0x00, 0xf8, 0xb3, 0x32,
};
TO_EC_STR_PARAM(brainpoolp512t1_gy);
static const u8 brainpoolp512t1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(brainpoolp512t1_gz);
static const u8 brainpoolp512t1_gen_order[] = {
0xaa, 0xdd, 0x9d, 0xb8, 0xdb, 0xe9, 0xc4, 0x8b,
0x3f, 0xd4, 0xe6, 0xae, 0x33, 0xc9, 0xfc, 0x07,
0xcb, 0x30, 0x8d, 0xb3, 0xb3, 0xc9, 0xd2, 0x0e,
0xd6, 0x63, 0x9c, 0xca, 0x70, 0x33, 0x08, 0x70,
0x55, 0x3e, 0x5c, 0x41, 0x4c, 0xa9, 0x26, 0x19,
0x41, 0x86, 0x61, 0x19, 0x7f, 0xac, 0x10, 0x47,
0x1d, 0xb1, 0xd3, 0x81, 0x08, 0x5d, 0xda, 0xdd,
0xb5, 0x87, 0x96, 0x82, 0x9c, 0xa9, 0x00, 0x69,
};
TO_EC_STR_PARAM(brainpoolp512t1_gen_order);
#define CURVE_BRAINPOOLP512T1_Q_BITLEN 512
static const u8 brainpoolp512t1_gen_order_bitlen[] = {
0x02, 0x00,
};
TO_EC_STR_PARAM(brainpoolp512t1_gen_order_bitlen);
static const u8 brainpoolp512t1_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(brainpoolp512t1_cofactor);
static const u8 brainpoolp512t1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp512t1_alpha_montgomery, 0);
static const u8 brainpoolp512t1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp512t1_gamma_montgomery, 0);
static const u8 brainpoolp512t1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp512t1_alpha_edwards, 0);
static const u8 brainpoolp512t1_name[] = "BRAINPOOLP512T1";
TO_EC_STR_PARAM(brainpoolp512t1_name);
static const u8 brainpoolp512t1_oid[] = "1.3.36.3.3.2.8.1.1.14";
TO_EC_STR_PARAM(brainpoolp512t1_oid);
static const ec_str_params brainpoolp512t1_str_params = {
.p = &brainpoolp512t1_p_str_param,
.p_bitlen = &brainpoolp512t1_p_bitlen_str_param,
.r = &brainpoolp512t1_r_str_param,
.r_square = &brainpoolp512t1_r_square_str_param,
.mpinv = &brainpoolp512t1_mpinv_str_param,
.p_shift = &brainpoolp512t1_p_shift_str_param,
.p_normalized = &brainpoolp512t1_p_normalized_str_param,
.p_reciprocal = &brainpoolp512t1_p_reciprocal_str_param,
.a = &brainpoolp512t1_a_str_param,
.b = &brainpoolp512t1_b_str_param,
.curve_order = &brainpoolp512t1_curve_order_str_param,
.gx = &brainpoolp512t1_gx_str_param,
.gy = &brainpoolp512t1_gy_str_param,
.gz = &brainpoolp512t1_gz_str_param,
.gen_order = &brainpoolp512t1_gen_order_str_param,
.gen_order_bitlen = &brainpoolp512t1_gen_order_bitlen_str_param,
.cofactor = &brainpoolp512t1_cofactor_str_param,
.alpha_montgomery = &brainpoolp512t1_alpha_montgomery_str_param,
.gamma_montgomery = &brainpoolp512t1_gamma_montgomery_str_param,
.alpha_edwards = &brainpoolp512t1_alpha_edwards_str_param,
.oid = &brainpoolp512t1_oid_str_param,
.name = &brainpoolp512t1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_BRAINPOOLP512T1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_BRAINPOOLP512T1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_BRAINPOOLP512T1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_BRAINPOOLP512T1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BRAINPOOLP512T1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BRAINPOOLP512T1_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 29)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 29
#endif
#endif /* __EC_PARAMS_BRAINPOOLP512T1_H__ */
#endif /* WITH_CURVE_BRAINPOOLP512T1 */

View file

@ -0,0 +1,104 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __EC_PARAMS_EXTERNAL_H__
#define __EC_PARAMS_EXTERNAL_H__
#include <libecc/words/words.h>
typedef struct {
const u8 *buf;
const u8 buflen;
} ec_str_param;
#define TO_EC_STR_PARAM(pname) \
static const ec_str_param pname##_str_param = { \
.buf = pname, \
.buflen = sizeof(pname) \
}
#define TO_EC_STR_PARAM_FIXED_SIZE(pname, sz) \
static const ec_str_param pname##_str_param = { \
.buf = pname, \
.buflen = (sz) \
}
#define PARAM_BUF_LEN(param) ((param)->buflen)
#define PARAM_BUF_PTR(param) ((param)->buf)
typedef struct {
/*
* Prime p:
* o p_bitlen = bitsizeof(p)
*/
const ec_str_param *p;
const ec_str_param *p_bitlen;
/*
* Precomputed Montgomery parameters:
* o r = 2^bitsizeof(p) mod p
* o r_square = 2^(2*bitsizeof(p)) mod p
* o mpinv = -p^-1 mod B
* where B = 2^(bitsizeof(word_t))
*/
const ec_str_param *r;
const ec_str_param *r_square;
const ec_str_param *mpinv;
/*
* Precomputed division parameters:
* o p_shift = nn_clz(p)
* o p_normalized = p << p_shift
* o p_reciprocal = floor(B^3/(DMSW(p_normalized) + 1)) - B
* where B = 2^(bitsizeof(word_t))
*/
const ec_str_param *p_shift;
const ec_str_param *p_normalized;
const ec_str_param *p_reciprocal;
/* Curve coefficients and number of points */
const ec_str_param *a;
const ec_str_param *b;
const ec_str_param *curve_order;
/*
* Projective coordinates of generator
* and order and cofactor of associated subgroup.
*/
const ec_str_param *gx;
const ec_str_param *gy;
const ec_str_param *gz;
const ec_str_param *gen_order;
const ec_str_param *gen_order_bitlen;
const ec_str_param *cofactor;
/*
* Optional transfert coefficients to Montgomery curve.
*/
const ec_str_param *alpha_montgomery;
const ec_str_param *gamma_montgomery;
/*
* Optional transfert coefficient to Edwards curve.
*/
const ec_str_param *alpha_edwards;
/* OID and pretty name */
const ec_str_param *oid;
const ec_str_param *name;
} ec_str_params;
#endif /* __EC_PARAMS_EXTERNAL_H__ */

View file

@ -0,0 +1,233 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_FRP256V1
#ifndef __EC_PARAMS_FRP256V1_H__
#define __EC_PARAMS_FRP256V1_H__
#include "ec_params_external.h"
static const u8 frp256v1_p[] = {
0xf1, 0xfd, 0x17, 0x8c, 0x0b, 0x3a, 0xd5, 0x8f,
0x10, 0x12, 0x6d, 0xe8, 0xce, 0x42, 0x43, 0x5b,
0x39, 0x61, 0xad, 0xbc, 0xab, 0xc8, 0xca, 0x6d,
0xe8, 0xfc, 0xf3, 0x53, 0xd8, 0x6e, 0x9c, 0x03
};
TO_EC_STR_PARAM(frp256v1_p);
#define CURVE_FRP256V1_P_BITLEN 256
static const u8 frp256v1_p_bitlen[] = { 0x01, 0x00 };
TO_EC_STR_PARAM(frp256v1_p_bitlen);
static const u8 frp256v1_r[] = {
0x0e, 0x02, 0xe8, 0x73, 0xf4, 0xc5, 0x2a, 0x70,
0xef, 0xed, 0x92, 0x17, 0x31, 0xbd, 0xbc, 0xa4,
0xc6, 0x9e, 0x52, 0x43, 0x54, 0x37, 0x35, 0x92,
0x17, 0x03, 0x0c, 0xac, 0x27, 0x91, 0x63, 0xfd
};
TO_EC_STR_PARAM(frp256v1_r);
static const u8 frp256v1_r_square[] = {
0xb0, 0x2c, 0x8f, 0x9f, 0x88, 0xeb, 0x98, 0xac,
0x62, 0xb7, 0x01, 0x2f, 0xce, 0x13, 0x7e, 0xee,
0x84, 0x6f, 0x80, 0x83, 0x0c, 0x96, 0x0f, 0x92,
0xb0, 0xc2, 0x4e, 0x77, 0xc9, 0x9f, 0x15, 0x13
};
TO_EC_STR_PARAM(frp256v1_r_square);
static const u8 frp256v1_mpinv[] = {
0xc7, 0x97, 0x48, 0x3a, 0x16, 0x4e, 0x11, 0x55
};
TO_EC_STR_PARAM(frp256v1_mpinv);
static const u8 frp256v1_p_shift[] = {
0x00
};
TO_EC_STR_PARAM(frp256v1_p_shift);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 frp256v1_p_reciprocal[] = {
0x0e, 0xd2, 0x97, 0xdc, 0xc7, 0xd2, 0xb0, 0x40
};
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 frp256v1_p_reciprocal[] = {
0x0e, 0xd2, 0x97, 0xdc
};
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 frp256v1_p_reciprocal[] = {
0x0e, 0xd2
};
#else /* unknown word size */
#error "Unsupported word size"
#endif
TO_EC_STR_PARAM(frp256v1_p_reciprocal);
static const u8 frp256v1_a[] = {
0xf1, 0xfd, 0x17, 0x8c, 0x0b, 0x3a, 0xd5, 0x8f,
0x10, 0x12, 0x6d, 0xe8, 0xce, 0x42, 0x43, 0x5b,
0x39, 0x61, 0xad, 0xbc, 0xab, 0xc8, 0xca, 0x6d,
0xe8, 0xfc, 0xf3, 0x53, 0xd8, 0x6e, 0x9c, 0x00
};
TO_EC_STR_PARAM(frp256v1_a);
static const u8 frp256v1_b[] = {
0xee, 0x35, 0x3f, 0xca, 0x54, 0x28, 0xa9, 0x30,
0x0d, 0x4a, 0xba, 0x75, 0x4a, 0x44, 0xc0, 0x0f,
0xdf, 0xec, 0x0c, 0x9a, 0xe4, 0xb1, 0xa1, 0x80,
0x30, 0x75, 0xed, 0x96, 0x7b, 0x7b, 0xb7, 0x3f
};
TO_EC_STR_PARAM(frp256v1_b);
#define CURVE_FRP256V1_CURVE_ORDER_BITLEN 256
static const u8 frp256v1_curve_order[] = {
0xf1, 0xfd, 0x17, 0x8c, 0x0b, 0x3a, 0xd5, 0x8f,
0x10, 0x12, 0x6d, 0xe8, 0xce, 0x42, 0x43, 0x5b,
0x53, 0xdc, 0x67, 0xe1, 0x40, 0xd2, 0xbf, 0x94,
0x1f, 0xfd, 0xd4, 0x59, 0xc6, 0xd6, 0x55, 0xe1
};
TO_EC_STR_PARAM(frp256v1_curve_order);
static const u8 frp256v1_gx[] = {
0xb6, 0xb3, 0xd4, 0xc3, 0x56, 0xc1, 0x39, 0xeb,
0x31, 0x18, 0x3d, 0x47, 0x49, 0xd4, 0x23, 0x95,
0x8c, 0x27, 0xd2, 0xdc, 0xaf, 0x98, 0xb7, 0x01,
0x64, 0xc9, 0x7a, 0x2d, 0xd9, 0x8f, 0x5c, 0xff
};
TO_EC_STR_PARAM(frp256v1_gx);
static const u8 frp256v1_gy[] = {
0x61, 0x42, 0xe0, 0xf7, 0xc8, 0xb2, 0x04, 0x91,
0x1f, 0x92, 0x71, 0xf0, 0xf3, 0xec, 0xef, 0x8c,
0x27, 0x01, 0xc3, 0x07, 0xe8, 0xe4, 0xc9, 0xe1,
0x83, 0x11, 0x5a, 0x15, 0x54, 0x06, 0x2c, 0xfb
};
TO_EC_STR_PARAM(frp256v1_gy);
static const u8 frp256v1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
};
TO_EC_STR_PARAM(frp256v1_gz);
static const u8 frp256v1_gen_order[] = {
0xf1, 0xfd, 0x17, 0x8c, 0x0b, 0x3a, 0xd5, 0x8f,
0x10, 0x12, 0x6d, 0xe8, 0xce, 0x42, 0x43, 0x5b,
0x53, 0xdc, 0x67, 0xe1, 0x40, 0xd2, 0xbf, 0x94,
0x1f, 0xfd, 0xd4, 0x59, 0xc6, 0xd6, 0x55, 0xe1
};
TO_EC_STR_PARAM(frp256v1_gen_order);
#define CURVE_FRP256V1_Q_BITLEN 256
static const u8 frp256v1_gen_order_bitlen[] = { 0x01, 0x00 };
TO_EC_STR_PARAM(frp256v1_gen_order_bitlen);
static const u8 frp256v1_cofactor[] = { 0x01 };
TO_EC_STR_PARAM(frp256v1_cofactor);
static const u8 frp256v1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(frp256v1_alpha_montgomery, 0);
static const u8 frp256v1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(frp256v1_gamma_montgomery, 0);
static const u8 frp256v1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(frp256v1_alpha_edwards, 0);
static const u8 frp256v1_oid[] = "1.2.250.1.223.101.256.1";
TO_EC_STR_PARAM(frp256v1_oid);
static const u8 frp256v1_name[] = "FRP256V1";
TO_EC_STR_PARAM(frp256v1_name);
static const ec_str_params frp256v1_str_params = {
.p = &frp256v1_p_str_param,
.p_bitlen = &frp256v1_p_bitlen_str_param,
.r = &frp256v1_r_str_param,
.r_square = &frp256v1_r_square_str_param,
.mpinv = &frp256v1_mpinv_str_param,
.p_shift = &frp256v1_p_shift_str_param,
.p_normalized = &frp256v1_p_str_param,
.p_reciprocal = &frp256v1_p_reciprocal_str_param,
.a = &frp256v1_a_str_param,
.b = &frp256v1_b_str_param,
.curve_order = &frp256v1_curve_order_str_param,
.gx = &frp256v1_gx_str_param,
.gy = &frp256v1_gy_str_param,
.gz = &frp256v1_gz_str_param,
.gen_order = &frp256v1_gen_order_str_param,
.gen_order_bitlen = &frp256v1_gen_order_bitlen_str_param,
.cofactor = &frp256v1_cofactor_str_param,
.alpha_montgomery = &frp256v1_alpha_montgomery_str_param,
.gamma_montgomery = &frp256v1_gamma_montgomery_str_param,
.alpha_edwards = &frp256v1_alpha_edwards_str_param,
.oid = &frp256v1_oid_str_param,
.name = &frp256v1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_FRP256V1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_FRP256V1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_FRP256V1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_FRP256V1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_FRP256V1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_FRP256V1_CURVE_ORDER_BITLEN
#endif
#endif /* __EC_PARAMS_FRP256V1_H__ */
#endif /* WITH_CURVE_FRP256V1 */

View file

@ -0,0 +1,233 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_GOST256
#ifndef __EC_PARAMS_GOST256_H__
#define __EC_PARAMS_GOST256_H__
#include "ec_params_external.h"
static const u8 GOST_256bits_curve_p[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x31
};
TO_EC_STR_PARAM(GOST_256bits_curve_p);
#define CURVE_GOST256_P_BITLEN 256
static const u8 GOST_256bits_curve_p_bitlen[] = { 0x01, 0x00 };
TO_EC_STR_PARAM(GOST_256bits_curve_p_bitlen);
static const u8 GOST_256bits_curve_r[] = {
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xcf
};
TO_EC_STR_PARAM(GOST_256bits_curve_r);
static const u8 GOST_256bits_curve_r_square[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x45, 0x84
};
TO_EC_STR_PARAM(GOST_256bits_curve_r_square);
static const u8 GOST_256bits_curve_mpinv[] = {
0xdb, 0xf9, 0x51, 0xd5, 0x88, 0x3b, 0x2b, 0x2f
};
TO_EC_STR_PARAM(GOST_256bits_curve_mpinv);
static const u8 GOST_256bits_curve_p_shift[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
TO_EC_STR_PARAM(GOST_256bits_curve_p_shift);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 GOST_256bits_curve_p_reciprocal[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 GOST_256bits_curve_p_reciprocal[] = {
0xff, 0xff, 0xff, 0xff
};
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 GOST_256bits_curve_p_reciprocal[] = {
0xff, 0xff
};
#else /* unknown word size */
#error "Unsupported word size"
#endif
TO_EC_STR_PARAM(GOST_256bits_curve_p_reciprocal);
static const u8 GOST_256bits_curve_a[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07
};
TO_EC_STR_PARAM(GOST_256bits_curve_a);
static const u8 GOST_256bits_curve_b[] = {
0x5F, 0xBF, 0xF4, 0x98, 0xAA, 0x93, 0x8C, 0xE7,
0x39, 0xB8, 0xE0, 0x22, 0xFB, 0xAF, 0xEF, 0x40,
0x56, 0x3F, 0x6E, 0x6A, 0x34, 0x72, 0xFC, 0x2A,
0x51, 0x4C, 0x0C, 0xE9, 0xDA, 0xE2, 0x3B, 0x7E
};
TO_EC_STR_PARAM(GOST_256bits_curve_b);
#define CURVE_GOST256_CURVE_ORDER_BITLEN 256
static const u8 GOST_256bits_curve_order[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x50, 0xFE, 0x8A, 0x18, 0x92, 0x97, 0x61, 0x54,
0xC5, 0x9C, 0xFC, 0x19, 0x3A, 0xCC, 0xF5, 0xB3
};
TO_EC_STR_PARAM(GOST_256bits_curve_order);
static const u8 GOST_256bits_curve_gx[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02
};
TO_EC_STR_PARAM(GOST_256bits_curve_gx);
static const u8 GOST_256bits_curve_gy[] = {
0x08, 0xE2, 0xA8, 0xA0, 0xE6, 0x51, 0x47, 0xD4,
0xBD, 0x63, 0x16, 0x03, 0x0E, 0x16, 0xD1, 0x9C,
0x85, 0xC9, 0x7F, 0x0A, 0x9C, 0xA2, 0x67, 0x12,
0x2B, 0x96, 0xAB, 0xBC, 0xEA, 0x7E, 0x8F, 0xC8
};
TO_EC_STR_PARAM(GOST_256bits_curve_gy);
static const u8 GOST_256bits_curve_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
};
TO_EC_STR_PARAM(GOST_256bits_curve_gz);
static const u8 GOST_256bits_curve_gen_order[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x50, 0xFE, 0x8A, 0x18, 0x92, 0x97, 0x61, 0x54,
0xC5, 0x9C, 0xFC, 0x19, 0x3A, 0xCC, 0xF5, 0xB3
};
TO_EC_STR_PARAM(GOST_256bits_curve_gen_order);
#define CURVE_GOST256_Q_BITLEN 256
static const u8 GOST_256bits_curve_gen_order_bitlen[] = { 0x01, 0x00 };
TO_EC_STR_PARAM(GOST_256bits_curve_gen_order_bitlen);
static const u8 GOST_256bits_curve_cofactor[] = { 0x01 };
TO_EC_STR_PARAM(GOST_256bits_curve_cofactor);
static const u8 GOST_256bits_curve_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(GOST_256bits_curve_alpha_montgomery, 0);
static const u8 GOST_256bits_curve_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(GOST_256bits_curve_gamma_montgomery, 0);
static const u8 GOST_256bits_curve_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(GOST_256bits_curve_alpha_edwards, 0);
static const u8 GOST_256bits_curve_oid[] = "unknown";
TO_EC_STR_PARAM(GOST_256bits_curve_oid);
static const u8 GOST_256bits_curve_name[] = "GOST256";
TO_EC_STR_PARAM(GOST_256bits_curve_name);
static const ec_str_params GOST_256bits_curve_str_params = {
.p = &GOST_256bits_curve_p_str_param,
.p_bitlen = &GOST_256bits_curve_p_bitlen_str_param,
.r = &GOST_256bits_curve_r_str_param,
.r_square = &GOST_256bits_curve_r_square_str_param,
.mpinv = &GOST_256bits_curve_mpinv_str_param,
.p_shift = &GOST_256bits_curve_p_shift_str_param,
.p_normalized = &GOST_256bits_curve_p_str_param,
.p_reciprocal = &GOST_256bits_curve_p_reciprocal_str_param,
.a = &GOST_256bits_curve_a_str_param,
.b = &GOST_256bits_curve_b_str_param,
.curve_order = &GOST_256bits_curve_order_str_param,
.gx = &GOST_256bits_curve_gx_str_param,
.gy = &GOST_256bits_curve_gy_str_param,
.gz = &GOST_256bits_curve_gz_str_param,
.gen_order = &GOST_256bits_curve_gen_order_str_param,
.gen_order_bitlen = &GOST_256bits_curve_gen_order_bitlen_str_param,
.cofactor = &GOST_256bits_curve_cofactor_str_param,
.alpha_montgomery = &GOST_256bits_curve_alpha_montgomery_str_param,
.gamma_montgomery = &GOST_256bits_curve_gamma_montgomery_str_param,
.alpha_edwards = &GOST_256bits_curve_alpha_edwards_str_param,
.oid = &GOST_256bits_curve_oid_str_param,
.name = &GOST_256bits_curve_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_GOST256_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_GOST256_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST256_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_GOST256_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST256_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST256_CURVE_ORDER_BITLEN
#endif
#endif /* __EC_PARAMS_GOST256_H__ */
#endif /* WITH_CURVE_GOST256 */

View file

@ -0,0 +1,286 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_GOST512
#ifndef __EC_PARAMS_GOST512_H__
#define __EC_PARAMS_GOST512_H__
#include "ec_params_external.h"
static const u8 GOST_512bits_curve_p[] = {
0x45, 0x31, 0xAC, 0xD1, 0xFE, 0x00, 0x23, 0xC7,
0x55, 0x0D, 0x26, 0x7B, 0x6B, 0x2F, 0xEE, 0x80,
0x92, 0x2B, 0x14, 0xB2, 0xFF, 0xB9, 0x0F, 0x04,
0xD4, 0xEB, 0x7C, 0x09, 0xB5, 0xD2, 0xD1, 0x5D,
0xF1, 0xD8, 0x52, 0x74, 0x1A, 0xF4, 0x70, 0x4A,
0x04, 0x58, 0x04, 0x7E, 0x80, 0xE4, 0x54, 0x6D,
0x35, 0xB8, 0x33, 0x6F, 0xAC, 0x22, 0x4D, 0xD8,
0x16, 0x64, 0xBB, 0xF5, 0x28, 0xBE, 0x63, 0x73
};
TO_EC_STR_PARAM(GOST_512bits_curve_p);
#define CURVE_GOST512_P_BITLEN 512
static const u8 GOST_512bits_curve_p_bitlen[] = { 0x01, 0xff };
TO_EC_STR_PARAM(GOST_512bits_curve_p_bitlen);
static const u8 GOST_512bits_curve_p_normalized[] = {
0x8a, 0x63, 0x59, 0xa3, 0xfc, 0x00, 0x47, 0x8e,
0xaa, 0x1a, 0x4c, 0xf6, 0xd6, 0x5f, 0xdd, 0x01,
0x24, 0x56, 0x29, 0x65, 0xff, 0x72, 0x1e, 0x09,
0xa9, 0xd6, 0xf8, 0x13, 0x6b, 0xa5, 0xa2, 0xbb,
0xe3, 0xb0, 0xa4, 0xe8, 0x35, 0xe8, 0xe0, 0x94,
0x08, 0xb0, 0x08, 0xfd, 0x01, 0xc8, 0xa8, 0xda,
0x6b, 0x70, 0x66, 0xdf, 0x58, 0x44, 0x9b, 0xb0,
0x2c, 0xc9, 0x77, 0xea, 0x51, 0x7c, 0xc6, 0xe6
};
TO_EC_STR_PARAM(GOST_512bits_curve_p_normalized);
static const u8 GOST_512bits_curve_r[] = {
0x30, 0x6a, 0xf9, 0x8a, 0x05, 0xff, 0x94, 0xaa,
0x00, 0xd8, 0x8c, 0x8d, 0xbe, 0x70, 0x34, 0x7e,
0x49, 0x7e, 0xc1, 0xe7, 0x00, 0xd4, 0xd2, 0xf1,
0x81, 0x3d, 0x8b, 0xe2, 0xde, 0x87, 0x8b, 0xe6,
0x2a, 0x77, 0x08, 0xa3, 0xaf, 0x22, 0xaf, 0x21,
0xf2, 0xf7, 0xf2, 0x84, 0x7d, 0x53, 0x02, 0xb8,
0x5e, 0xd7, 0x65, 0xb0, 0xfb, 0x99, 0x16, 0x77,
0xbc, 0xd1, 0xcc, 0x20, 0x85, 0xc4, 0xd5, 0xa7
};
TO_EC_STR_PARAM(GOST_512bits_curve_r);
static const u8 GOST_512bits_curve_r_square[] = {
0x1d, 0x88, 0x7d, 0xcd, 0x9c, 0xd1, 0x9c, 0x10,
0x01, 0xfd, 0xe9, 0xca, 0x99, 0xde, 0x08, 0x52,
0xfc, 0xd9, 0x83, 0xcf, 0xb7, 0xc6, 0x63, 0xd9,
0xca, 0x0b, 0xc8, 0xaf, 0x77, 0xc8, 0x69, 0x0a,
0x08, 0x15, 0xb9, 0xeb, 0x1e, 0x7d, 0xd3, 0x00,
0xe4, 0x17, 0xd5, 0x8d, 0x20, 0x0c, 0x2a, 0xa0,
0x4b, 0x90, 0x7a, 0x71, 0xe6, 0x47, 0xee, 0x63,
0x00, 0x1c, 0x10, 0xbc, 0x2d, 0x00, 0x5b, 0x65
};
TO_EC_STR_PARAM(GOST_512bits_curve_r_square);
static const u8 GOST_512bits_curve_mpinv[] = {
0xd6, 0x41, 0x2f, 0xf7, 0xc2, 0x9b, 0x86, 0x45
};
TO_EC_STR_PARAM(GOST_512bits_curve_mpinv);
static const u8 GOST_512bits_curve_p_shift[] = { 0x01 };
TO_EC_STR_PARAM(GOST_512bits_curve_p_shift);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 GOST_512bits_curve_p_reciprocal[] = {
0xd9, 0x91, 0x18, 0x3c, 0xe8, 0xbf, 0x25, 0x61
};
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 GOST_512bits_curve_p_reciprocal[] = {
0xd9, 0x91, 0x18, 0x3c
};
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 GOST_512bits_curve_p_reciprocal[] = {
0xd9, 0x91
};
#else /* unknown word size */
#error "Unsupported word size"
#endif
TO_EC_STR_PARAM(GOST_512bits_curve_p_reciprocal);
static const u8 GOST_512bits_curve_a[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07
};
TO_EC_STR_PARAM(GOST_512bits_curve_a);
static const u8 GOST_512bits_curve_b[] = {
0x1C, 0xFF, 0x08, 0x06, 0xA3, 0x11, 0x16, 0xDA,
0x29, 0xD8, 0xCF, 0xA5, 0x4E, 0x57, 0xEB, 0x74,
0x8B, 0xC5, 0xF3, 0x77, 0xE4, 0x94, 0x00, 0xFD,
0xD7, 0x88, 0xB6, 0x49, 0xEC, 0xA1, 0xAC, 0x43,
0x61, 0x83, 0x40, 0x13, 0xB2, 0xAD, 0x73, 0x22,
0x48, 0x0A, 0x89, 0xCA, 0x58, 0xE0, 0xCF, 0x74,
0xBC, 0x9E, 0x54, 0x0C, 0x2A, 0xDD, 0x68, 0x97,
0xFA, 0xD0, 0xA3, 0x08, 0x4F, 0x30, 0x2A, 0xDC
};
TO_EC_STR_PARAM(GOST_512bits_curve_b);
#define CURVE_GOST512_CURVE_ORDER_BITLEN 511
static const u8 GOST_512bits_curve_order[] = {
0x45, 0x31, 0xac, 0xd1, 0xfe, 0x00, 0x23, 0xc7,
0x55, 0x0d, 0x26, 0x7b, 0x6b, 0x2f, 0xee, 0x80,
0x92, 0x2b, 0x14, 0xb2, 0xff, 0xb9, 0x0f, 0x04,
0xd4, 0xeb, 0x7c, 0x09, 0xb5, 0xd2, 0xd1, 0x5d,
0xa8, 0x2f, 0x2d, 0x7e, 0xcb, 0x1d, 0xba, 0xc7,
0x19, 0x90, 0x5c, 0x5e, 0xec, 0xc4, 0x23, 0xf1,
0xd8, 0x6e, 0x25, 0xed, 0xbe, 0x23, 0xc5, 0x95,
0xd6, 0x44, 0xaa, 0xf1, 0x87, 0xe6, 0xe6, 0xdf
};
TO_EC_STR_PARAM(GOST_512bits_curve_order);
static const u8 GOST_512bits_curve_gx[] = {
0x24, 0xD1, 0x9C, 0xC6, 0x45, 0x72, 0xEE, 0x30,
0xF3, 0x96, 0xBF, 0x6E, 0xBB, 0xFD, 0x7A, 0x6C,
0x52, 0x13, 0xB3, 0xB3, 0xD7, 0x05, 0x7C, 0xC8,
0x25, 0xF9, 0x10, 0x93, 0xA6, 0x8C, 0xD7, 0x62,
0xFD, 0x60, 0x61, 0x12, 0x62, 0xCD, 0x83, 0x8D,
0xC6, 0xB6, 0x0A, 0xA7, 0xEE, 0xE8, 0x04, 0xE2,
0x8B, 0xC8, 0x49, 0x97, 0x7F, 0xAC, 0x33, 0xB4,
0xB5, 0x30, 0xF1, 0xB1, 0x20, 0x24, 0x8A, 0x9A
};
TO_EC_STR_PARAM(GOST_512bits_curve_gx);
static const u8 GOST_512bits_curve_gy[] = {
0x2B, 0xB3, 0x12, 0xA4, 0x3B, 0xD2, 0xCE, 0x6E,
0x0D, 0x02, 0x06, 0x13, 0xC8, 0x57, 0xAC, 0xDD,
0xCF, 0xBF, 0x06, 0x1E, 0x91, 0xE5, 0xF2, 0xC3,
0xF3, 0x24, 0x47, 0xC2, 0x59, 0xF3, 0x9B, 0x2C,
0x83, 0xAB, 0x15, 0x6D, 0x77, 0xF1, 0x49, 0x6B,
0xF7, 0xEB, 0x33, 0x51, 0xE1, 0xEE, 0x4E, 0x43,
0xDC, 0x1A, 0x18, 0xB9, 0x1B, 0x24, 0x64, 0x0B,
0x6D, 0xBB, 0x92, 0xCB, 0x1A, 0xDD, 0x37, 0x1E
};
TO_EC_STR_PARAM(GOST_512bits_curve_gy);
static const u8 GOST_512bits_curve_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
};
TO_EC_STR_PARAM(GOST_512bits_curve_gz);
static const u8 GOST_512bits_curve_gen_order[] = {
0x45, 0x31, 0xac, 0xd1, 0xfe, 0x00, 0x23, 0xc7,
0x55, 0x0d, 0x26, 0x7b, 0x6b, 0x2f, 0xee, 0x80,
0x92, 0x2b, 0x14, 0xb2, 0xff, 0xb9, 0x0f, 0x04,
0xd4, 0xeb, 0x7c, 0x09, 0xb5, 0xd2, 0xd1, 0x5d,
0xa8, 0x2f, 0x2d, 0x7e, 0xcb, 0x1d, 0xba, 0xc7,
0x19, 0x90, 0x5c, 0x5e, 0xec, 0xc4, 0x23, 0xf1,
0xd8, 0x6e, 0x25, 0xed, 0xbe, 0x23, 0xc5, 0x95,
0xd6, 0x44, 0xaa, 0xf1, 0x87, 0xe6, 0xe6, 0xdf
};
TO_EC_STR_PARAM(GOST_512bits_curve_gen_order);
#define CURVE_GOST512_Q_BITLEN 511
static const u8 GOST_512bits_curve_gen_order_bitlen[] = { 0x01, 0xff };
TO_EC_STR_PARAM(GOST_512bits_curve_gen_order_bitlen);
static const u8 GOST_512bits_curve_cofactor[] = { 0x01 };
TO_EC_STR_PARAM(GOST_512bits_curve_cofactor);
static const u8 GOST_512bits_curve_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(GOST_512bits_curve_alpha_montgomery, 0);
static const u8 GOST_512bits_curve_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(GOST_512bits_curve_gamma_montgomery, 0);
static const u8 GOST_512bits_curve_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(GOST_512bits_curve_alpha_edwards, 0);
static const u8 GOST_512bits_curve_oid[] = "unknown2";
TO_EC_STR_PARAM(GOST_512bits_curve_oid);
static const u8 GOST_512bits_curve_name[] = "GOST512";
TO_EC_STR_PARAM(GOST_512bits_curve_name);
static const ec_str_params GOST_512bits_curve_str_params = {
.p = &GOST_512bits_curve_p_str_param,
.p_bitlen = &GOST_512bits_curve_p_bitlen_str_param,
.r = &GOST_512bits_curve_r_str_param,
.r_square = &GOST_512bits_curve_r_square_str_param,
.mpinv = &GOST_512bits_curve_mpinv_str_param,
.p_shift = &GOST_512bits_curve_p_shift_str_param,
.p_normalized = &GOST_512bits_curve_p_normalized_str_param,
.p_reciprocal = &GOST_512bits_curve_p_reciprocal_str_param,
.a = &GOST_512bits_curve_a_str_param,
.b = &GOST_512bits_curve_b_str_param,
.curve_order = &GOST_512bits_curve_order_str_param,
.gx = &GOST_512bits_curve_gx_str_param,
.gy = &GOST_512bits_curve_gy_str_param,
.gz = &GOST_512bits_curve_gz_str_param,
.gen_order = &GOST_512bits_curve_gen_order_str_param,
.gen_order_bitlen = &GOST_512bits_curve_gen_order_bitlen_str_param,
.cofactor = &GOST_512bits_curve_cofactor_str_param,
.alpha_montgomery = &GOST_512bits_curve_alpha_montgomery_str_param,
.gamma_montgomery = &GOST_512bits_curve_gamma_montgomery_str_param,
.alpha_edwards = &GOST_512bits_curve_alpha_edwards_str_param,
.oid = &GOST_512bits_curve_oid_str_param,
.name = &GOST_512bits_curve_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_GOST512_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_GOST512_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST512_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_GOST512_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST512_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST512_CURVE_ORDER_BITLEN
#endif
#endif /* __EC_PARAMS_GOST512_H__ */
#endif /* WITH_CURVE_GOST512 */

View file

@ -0,0 +1,315 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET
#ifndef __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET_H__
#define __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_p[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_p);
#define CURVE_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET_P_BITLEN 256
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_p_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_r[] = {
0x02, 0x69,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_r);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_r_square[] = {
0x05, 0xcf, 0x11,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_r_square);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_mpinv[] = {
0x46, 0xf3, 0x23, 0x44, 0x75, 0xd5, 0xad, 0xd9,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_mpinv);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_p_shift);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_p_normalized);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_r[] = {
0x02, 0x69,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_r);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_r_square[] = {
0x05, 0xcf, 0x11,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_r_square);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_mpinv[] = {
0x75, 0xd5, 0xad, 0xd9,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_mpinv);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_p_shift);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_p_normalized);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_r[] = {
0x02, 0x69,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_r);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_r_square[] = {
0x05, 0xcf, 0x11,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_r_square);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_mpinv[] = {
0xad, 0xd9,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_mpinv);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_p_shift);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_p_normalized);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_a[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x94,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_a);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_b[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_b);
#define CURVE_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET_CURVE_ORDER_BITLEN 256
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_curve_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x6c, 0x61, 0x10, 0x70, 0x99, 0x5a, 0xd1, 0x00,
0x45, 0x84, 0x1b, 0x09, 0xb7, 0x61, 0xb8, 0x93,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_curve_order);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_gx[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_gx);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_gy[] = {
0x8d, 0x91, 0xe4, 0x71, 0xe0, 0x98, 0x9c, 0xda,
0x27, 0xdf, 0x50, 0x5a, 0x45, 0x3f, 0x2b, 0x76,
0x35, 0x29, 0x4f, 0x2d, 0xdf, 0x23, 0xe3, 0xb1,
0x22, 0xac, 0xc9, 0x9c, 0x9e, 0x9f, 0x1e, 0x14,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_gy);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_gz);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_gen_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x6c, 0x61, 0x10, 0x70, 0x99, 0x5a, 0xd1, 0x00,
0x45, 0x84, 0x1b, 0x09, 0xb7, 0x61, 0xb8, 0x93,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_gen_order);
#define CURVE_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET_Q_BITLEN 256
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_gen_order_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_gen_order_bitlen);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_cofactor);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_A_ParamSet_alpha_montgomery, 0);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_A_ParamSet_gamma_montgomery, 0);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_A_ParamSet_alpha_edwards, 0);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_name[] = "GOST_R3410_2001_CRYPTOPRO_A_PARAMSET";
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_name);
static const u8 gost_R3410_2001_CryptoPro_A_ParamSet_oid[] = "1.2.643.2.2.35.1";
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_A_ParamSet_oid);
static const ec_str_params gost_R3410_2001_CryptoPro_A_ParamSet_str_params = {
.p = &gost_R3410_2001_CryptoPro_A_ParamSet_p_str_param,
.p_bitlen = &gost_R3410_2001_CryptoPro_A_ParamSet_p_bitlen_str_param,
.r = &gost_R3410_2001_CryptoPro_A_ParamSet_r_str_param,
.r_square = &gost_R3410_2001_CryptoPro_A_ParamSet_r_square_str_param,
.mpinv = &gost_R3410_2001_CryptoPro_A_ParamSet_mpinv_str_param,
.p_shift = &gost_R3410_2001_CryptoPro_A_ParamSet_p_shift_str_param,
.p_normalized = &gost_R3410_2001_CryptoPro_A_ParamSet_p_normalized_str_param,
.p_reciprocal = &gost_R3410_2001_CryptoPro_A_ParamSet_p_reciprocal_str_param,
.a = &gost_R3410_2001_CryptoPro_A_ParamSet_a_str_param,
.b = &gost_R3410_2001_CryptoPro_A_ParamSet_b_str_param,
.curve_order = &gost_R3410_2001_CryptoPro_A_ParamSet_curve_order_str_param,
.gx = &gost_R3410_2001_CryptoPro_A_ParamSet_gx_str_param,
.gy = &gost_R3410_2001_CryptoPro_A_ParamSet_gy_str_param,
.gz = &gost_R3410_2001_CryptoPro_A_ParamSet_gz_str_param,
.gen_order = &gost_R3410_2001_CryptoPro_A_ParamSet_gen_order_str_param,
.gen_order_bitlen = &gost_R3410_2001_CryptoPro_A_ParamSet_gen_order_bitlen_str_param,
.cofactor = &gost_R3410_2001_CryptoPro_A_ParamSet_cofactor_str_param,
.alpha_montgomery = &gost_R3410_2001_CryptoPro_A_ParamSet_alpha_montgomery_str_param,
.gamma_montgomery = &gost_R3410_2001_CryptoPro_A_ParamSet_gamma_montgomery_str_param,
.alpha_edwards = &gost_R3410_2001_CryptoPro_A_ParamSet_alpha_edwards_str_param,
.oid = &gost_R3410_2001_CryptoPro_A_ParamSet_oid_str_param,
.name = &gost_R3410_2001_CryptoPro_A_ParamSet_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 17)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 17
#endif
#if (MAX_CURVE_NAME_LEN < 52)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 52
#endif
#endif /* __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET_H__ */
#endif /* WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET */

View file

@ -0,0 +1,324 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET
#ifndef __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET_H__
#define __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_p[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x99,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_p);
#define CURVE_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET_P_BITLEN 256
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_p_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_r[] = {
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x67,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_r);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_r_square[] = {
0x02, 0x7a, 0xcd, 0xc4,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_r_square);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_mpinv[] = {
0xbd, 0x66, 0x7a, 0xb8, 0xa3, 0x34, 0x78, 0x57,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_mpinv);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_p_shift);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_p_normalized[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x99,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_p_normalized);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_p_reciprocal[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_r[] = {
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x67,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_r);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_r_square[] = {
0x02, 0x7a, 0xcd, 0xc4,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_r_square);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_mpinv[] = {
0xa3, 0x34, 0x78, 0x57,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_mpinv);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_p_shift);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_p_normalized[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x99,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_p_normalized);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_p_reciprocal[] = {
0xff, 0xff, 0xff, 0xff,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_r[] = {
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x67,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_r);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_r_square[] = {
0x02, 0x7a, 0xcd, 0xc4,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_r_square);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_mpinv[] = {
0x78, 0x57,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_mpinv);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_p_shift);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_p_normalized[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x99,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_p_normalized);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_p_reciprocal[] = {
0xff, 0xff,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_a[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x96,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_a);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_b[] = {
0x3e, 0x1a, 0xf4, 0x19, 0xa2, 0x69, 0xa5, 0xf8,
0x66, 0xa7, 0xd3, 0xc2, 0x5c, 0x3d, 0xf8, 0x0a,
0xe9, 0x79, 0x25, 0x93, 0x73, 0xff, 0x2b, 0x18,
0x2f, 0x49, 0xd4, 0xce, 0x7e, 0x1b, 0xbc, 0x8b,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_b);
#define CURVE_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET_CURVE_ORDER_BITLEN 256
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_curve_order[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x5f, 0x70, 0x0c, 0xff, 0xf1, 0xa6, 0x24, 0xe5,
0xe4, 0x97, 0x16, 0x1b, 0xcc, 0x8a, 0x19, 0x8f,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_curve_order);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_gx[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_gx);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_gy[] = {
0x3f, 0xa8, 0x12, 0x43, 0x59, 0xf9, 0x66, 0x80,
0xb8, 0x3d, 0x1c, 0x3e, 0xb2, 0xc0, 0x70, 0xe5,
0xc5, 0x45, 0xc9, 0x85, 0x8d, 0x03, 0xec, 0xfb,
0x74, 0x4b, 0xf8, 0xd7, 0x17, 0x71, 0x7e, 0xfc,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_gy);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_gz);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_gen_order[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x5f, 0x70, 0x0c, 0xff, 0xf1, 0xa6, 0x24, 0xe5,
0xe4, 0x97, 0x16, 0x1b, 0xcc, 0x8a, 0x19, 0x8f,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_gen_order);
#define CURVE_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET_Q_BITLEN 256
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_gen_order_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_gen_order_bitlen);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_cofactor);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_B_ParamSet_alpha_montgomery, 0);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_B_ParamSet_gamma_montgomery, 0);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_B_ParamSet_alpha_edwards, 0);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_name[] = "GOST_R3410_2001_CRYPTOPRO_B_PARAMSET";
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_name);
static const u8 gost_R3410_2001_CryptoPro_B_ParamSet_oid[] = "1.2.643.2.2.35.2";
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_B_ParamSet_oid);
static const ec_str_params gost_R3410_2001_CryptoPro_B_ParamSet_str_params = {
.p = &gost_R3410_2001_CryptoPro_B_ParamSet_p_str_param,
.p_bitlen = &gost_R3410_2001_CryptoPro_B_ParamSet_p_bitlen_str_param,
.r = &gost_R3410_2001_CryptoPro_B_ParamSet_r_str_param,
.r_square = &gost_R3410_2001_CryptoPro_B_ParamSet_r_square_str_param,
.mpinv = &gost_R3410_2001_CryptoPro_B_ParamSet_mpinv_str_param,
.p_shift = &gost_R3410_2001_CryptoPro_B_ParamSet_p_shift_str_param,
.p_normalized = &gost_R3410_2001_CryptoPro_B_ParamSet_p_normalized_str_param,
.p_reciprocal = &gost_R3410_2001_CryptoPro_B_ParamSet_p_reciprocal_str_param,
.a = &gost_R3410_2001_CryptoPro_B_ParamSet_a_str_param,
.b = &gost_R3410_2001_CryptoPro_B_ParamSet_b_str_param,
.curve_order = &gost_R3410_2001_CryptoPro_B_ParamSet_curve_order_str_param,
.gx = &gost_R3410_2001_CryptoPro_B_ParamSet_gx_str_param,
.gy = &gost_R3410_2001_CryptoPro_B_ParamSet_gy_str_param,
.gz = &gost_R3410_2001_CryptoPro_B_ParamSet_gz_str_param,
.gen_order = &gost_R3410_2001_CryptoPro_B_ParamSet_gen_order_str_param,
.gen_order_bitlen = &gost_R3410_2001_CryptoPro_B_ParamSet_gen_order_bitlen_str_param,
.cofactor = &gost_R3410_2001_CryptoPro_B_ParamSet_cofactor_str_param,
.alpha_montgomery = &gost_R3410_2001_CryptoPro_B_ParamSet_alpha_montgomery_str_param,
.gamma_montgomery = &gost_R3410_2001_CryptoPro_B_ParamSet_gamma_montgomery_str_param,
.alpha_edwards = &gost_R3410_2001_CryptoPro_B_ParamSet_alpha_edwards_str_param,
.oid = &gost_R3410_2001_CryptoPro_B_ParamSet_oid_str_param,
.name = &gost_R3410_2001_CryptoPro_B_ParamSet_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 17)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 17
#endif
#if (MAX_CURVE_NAME_LEN < 52)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 52
#endif
#endif /* __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET_H__ */
#endif /* WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET */

View file

@ -0,0 +1,333 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET
#ifndef __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_H__
#define __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3,
0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x9b,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p);
#define CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_P_BITLEN 256
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_r[] = {
0x64, 0x60, 0x9f, 0xa0, 0xa5, 0x7a, 0x7e, 0xf8,
0x54, 0xe1, 0x37, 0xa1, 0x94, 0xbe, 0x37, 0x55,
0x30, 0x7b, 0x91, 0x79, 0x87, 0x6f, 0xae, 0x2c,
0x86, 0x67, 0x08, 0x46, 0xfd, 0xd2, 0x8a, 0x65,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_r);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_r_square[] = {
0x80, 0x7a, 0x39, 0x4e, 0xde, 0x09, 0x76, 0x52,
0x18, 0x63, 0x04, 0x21, 0x28, 0x49, 0xc0, 0x7b,
0x10, 0x17, 0xbb, 0x39, 0xc2, 0xd3, 0x46, 0xc5,
0x40, 0x99, 0x73, 0xb4, 0xc4, 0x27, 0xfc, 0xea,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_r_square);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_mpinv[] = {
0xdf, 0x6e, 0x6c, 0x2c, 0x72, 0x7c, 0x17, 0x6d,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_mpinv);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_shift);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_normalized[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3,
0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x9b,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_normalized);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_reciprocal[] = {
0xa5, 0x1f, 0x17, 0x61, 0x61, 0xf1, 0xd7, 0x34,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_r[] = {
0x64, 0x60, 0x9f, 0xa0, 0xa5, 0x7a, 0x7e, 0xf8,
0x54, 0xe1, 0x37, 0xa1, 0x94, 0xbe, 0x37, 0x55,
0x30, 0x7b, 0x91, 0x79, 0x87, 0x6f, 0xae, 0x2c,
0x86, 0x67, 0x08, 0x46, 0xfd, 0xd2, 0x8a, 0x65,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_r);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_r_square[] = {
0x80, 0x7a, 0x39, 0x4e, 0xde, 0x09, 0x76, 0x52,
0x18, 0x63, 0x04, 0x21, 0x28, 0x49, 0xc0, 0x7b,
0x10, 0x17, 0xbb, 0x39, 0xc2, 0xd3, 0x46, 0xc5,
0x40, 0x99, 0x73, 0xb4, 0xc4, 0x27, 0xfc, 0xea,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_r_square);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_mpinv[] = {
0x72, 0x7c, 0x17, 0x6d,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_mpinv);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_shift);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_normalized[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3,
0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x9b,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_normalized);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_reciprocal[] = {
0xa5, 0x1f, 0x17, 0x61,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_r[] = {
0x64, 0x60, 0x9f, 0xa0, 0xa5, 0x7a, 0x7e, 0xf8,
0x54, 0xe1, 0x37, 0xa1, 0x94, 0xbe, 0x37, 0x55,
0x30, 0x7b, 0x91, 0x79, 0x87, 0x6f, 0xae, 0x2c,
0x86, 0x67, 0x08, 0x46, 0xfd, 0xd2, 0x8a, 0x65,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_r);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_r_square[] = {
0x80, 0x7a, 0x39, 0x4e, 0xde, 0x09, 0x76, 0x52,
0x18, 0x63, 0x04, 0x21, 0x28, 0x49, 0xc0, 0x7b,
0x10, 0x17, 0xbb, 0x39, 0xc2, 0xd3, 0x46, 0xc5,
0x40, 0x99, 0x73, 0xb4, 0xc4, 0x27, 0xfc, 0xea,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_r_square);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_mpinv[] = {
0x17, 0x6d,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_mpinv);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_shift);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_normalized[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3,
0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x9b,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_normalized);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_reciprocal[] = {
0xa5, 0x1f,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_a[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3,
0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x98,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_a);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_b[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x5a,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_b);
#define CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_CURVE_ORDER_BITLEN 256
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_curve_order[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0x58, 0x2c, 0xa3, 0x51, 0x1e, 0xdd, 0xfb, 0x74,
0xf0, 0x2f, 0x3a, 0x65, 0x98, 0x98, 0x0b, 0xb9,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_curve_order);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_gx[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_gx);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_gy[] = {
0x41, 0xec, 0xe5, 0x57, 0x43, 0x71, 0x1a, 0x8c,
0x3c, 0xbf, 0x37, 0x83, 0xcd, 0x08, 0xc0, 0xee,
0x4d, 0x4d, 0xc4, 0x40, 0xd4, 0x64, 0x1a, 0x8f,
0x36, 0x6e, 0x55, 0x0d, 0xfd, 0xb3, 0xbb, 0x67,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_gy);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_gz);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_gen_order[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0x58, 0x2c, 0xa3, 0x51, 0x1e, 0xdd, 0xfb, 0x74,
0xf0, 0x2f, 0x3a, 0x65, 0x98, 0x98, 0x0b, 0xb9,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_gen_order);
#define CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_Q_BITLEN 256
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_gen_order_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_gen_order_bitlen);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_cofactor);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_C_ParamSet_alpha_montgomery, 0);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_C_ParamSet_gamma_montgomery, 0);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_C_ParamSet_alpha_edwards, 0);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_name[] = "GOST_R3410_2001_CRYPTOPRO_C_PARAMSET";
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_name);
static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_oid[] = "1.2.643.2.2.35.3";
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_oid);
static const ec_str_params gost_R3410_2001_CryptoPro_C_ParamSet_str_params = {
.p = &gost_R3410_2001_CryptoPro_C_ParamSet_p_str_param,
.p_bitlen = &gost_R3410_2001_CryptoPro_C_ParamSet_p_bitlen_str_param,
.r = &gost_R3410_2001_CryptoPro_C_ParamSet_r_str_param,
.r_square = &gost_R3410_2001_CryptoPro_C_ParamSet_r_square_str_param,
.mpinv = &gost_R3410_2001_CryptoPro_C_ParamSet_mpinv_str_param,
.p_shift = &gost_R3410_2001_CryptoPro_C_ParamSet_p_shift_str_param,
.p_normalized = &gost_R3410_2001_CryptoPro_C_ParamSet_p_normalized_str_param,
.p_reciprocal = &gost_R3410_2001_CryptoPro_C_ParamSet_p_reciprocal_str_param,
.a = &gost_R3410_2001_CryptoPro_C_ParamSet_a_str_param,
.b = &gost_R3410_2001_CryptoPro_C_ParamSet_b_str_param,
.curve_order = &gost_R3410_2001_CryptoPro_C_ParamSet_curve_order_str_param,
.gx = &gost_R3410_2001_CryptoPro_C_ParamSet_gx_str_param,
.gy = &gost_R3410_2001_CryptoPro_C_ParamSet_gy_str_param,
.gz = &gost_R3410_2001_CryptoPro_C_ParamSet_gz_str_param,
.gen_order = &gost_R3410_2001_CryptoPro_C_ParamSet_gen_order_str_param,
.gen_order_bitlen = &gost_R3410_2001_CryptoPro_C_ParamSet_gen_order_bitlen_str_param,
.cofactor = &gost_R3410_2001_CryptoPro_C_ParamSet_cofactor_str_param,
.alpha_montgomery = &gost_R3410_2001_CryptoPro_C_ParamSet_alpha_montgomery_str_param,
.gamma_montgomery = &gost_R3410_2001_CryptoPro_C_ParamSet_gamma_montgomery_str_param,
.alpha_edwards = &gost_R3410_2001_CryptoPro_C_ParamSet_alpha_edwards_str_param,
.oid = &gost_R3410_2001_CryptoPro_C_ParamSet_oid_str_param,
.name = &gost_R3410_2001_CryptoPro_C_ParamSet_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 17)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 17
#endif
#if (MAX_CURVE_NAME_LEN < 52)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 52
#endif
#endif /* __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_H__ */
#endif /* WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET */

View file

@ -0,0 +1,315 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET
#ifndef __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET_H__
#define __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_p[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_p);
#define CURVE_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET_P_BITLEN 256
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_p_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_r[] = {
0x02, 0x69,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_r);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_r_square[] = {
0x05, 0xcf, 0x11,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_r_square);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_mpinv[] = {
0x46, 0xf3, 0x23, 0x44, 0x75, 0xd5, 0xad, 0xd9,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_mpinv);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_p_shift);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_p_normalized);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_r[] = {
0x02, 0x69,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_r);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_r_square[] = {
0x05, 0xcf, 0x11,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_r_square);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_mpinv[] = {
0x75, 0xd5, 0xad, 0xd9,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_mpinv);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_p_shift);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_p_normalized);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_r[] = {
0x02, 0x69,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_r);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_r_square[] = {
0x05, 0xcf, 0x11,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_r_square);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_mpinv[] = {
0xad, 0xd9,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_mpinv);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_p_shift);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_p_normalized);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_a[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x94,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_a);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_b[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_b);
#define CURVE_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET_CURVE_ORDER_BITLEN 256
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_curve_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x6c, 0x61, 0x10, 0x70, 0x99, 0x5a, 0xd1, 0x00,
0x45, 0x84, 0x1b, 0x09, 0xb7, 0x61, 0xb8, 0x93,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_curve_order);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_gx[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_gx);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_gy[] = {
0x8d, 0x91, 0xe4, 0x71, 0xe0, 0x98, 0x9c, 0xda,
0x27, 0xdf, 0x50, 0x5a, 0x45, 0x3f, 0x2b, 0x76,
0x35, 0x29, 0x4f, 0x2d, 0xdf, 0x23, 0xe3, 0xb1,
0x22, 0xac, 0xc9, 0x9c, 0x9e, 0x9f, 0x1e, 0x14,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_gy);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_gz);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_gen_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x6c, 0x61, 0x10, 0x70, 0x99, 0x5a, 0xd1, 0x00,
0x45, 0x84, 0x1b, 0x09, 0xb7, 0x61, 0xb8, 0x93,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_gen_order);
#define CURVE_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET_Q_BITLEN 256
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_gen_order_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_gen_order_bitlen);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_cofactor);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_XchA_ParamSet_alpha_montgomery, 0);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_XchA_ParamSet_gamma_montgomery, 0);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_XchA_ParamSet_alpha_edwards, 0);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_name[] = "GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET";
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_name);
static const u8 gost_R3410_2001_CryptoPro_XchA_ParamSet_oid[] = "1.2.643.2.2.36.0";
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchA_ParamSet_oid);
static const ec_str_params gost_R3410_2001_CryptoPro_XchA_ParamSet_str_params = {
.p = &gost_R3410_2001_CryptoPro_XchA_ParamSet_p_str_param,
.p_bitlen = &gost_R3410_2001_CryptoPro_XchA_ParamSet_p_bitlen_str_param,
.r = &gost_R3410_2001_CryptoPro_XchA_ParamSet_r_str_param,
.r_square = &gost_R3410_2001_CryptoPro_XchA_ParamSet_r_square_str_param,
.mpinv = &gost_R3410_2001_CryptoPro_XchA_ParamSet_mpinv_str_param,
.p_shift = &gost_R3410_2001_CryptoPro_XchA_ParamSet_p_shift_str_param,
.p_normalized = &gost_R3410_2001_CryptoPro_XchA_ParamSet_p_normalized_str_param,
.p_reciprocal = &gost_R3410_2001_CryptoPro_XchA_ParamSet_p_reciprocal_str_param,
.a = &gost_R3410_2001_CryptoPro_XchA_ParamSet_a_str_param,
.b = &gost_R3410_2001_CryptoPro_XchA_ParamSet_b_str_param,
.curve_order = &gost_R3410_2001_CryptoPro_XchA_ParamSet_curve_order_str_param,
.gx = &gost_R3410_2001_CryptoPro_XchA_ParamSet_gx_str_param,
.gy = &gost_R3410_2001_CryptoPro_XchA_ParamSet_gy_str_param,
.gz = &gost_R3410_2001_CryptoPro_XchA_ParamSet_gz_str_param,
.gen_order = &gost_R3410_2001_CryptoPro_XchA_ParamSet_gen_order_str_param,
.gen_order_bitlen = &gost_R3410_2001_CryptoPro_XchA_ParamSet_gen_order_bitlen_str_param,
.cofactor = &gost_R3410_2001_CryptoPro_XchA_ParamSet_cofactor_str_param,
.alpha_montgomery = &gost_R3410_2001_CryptoPro_XchA_ParamSet_alpha_montgomery_str_param,
.gamma_montgomery = &gost_R3410_2001_CryptoPro_XchA_ParamSet_gamma_montgomery_str_param,
.alpha_edwards = &gost_R3410_2001_CryptoPro_XchA_ParamSet_alpha_edwards_str_param,
.oid = &gost_R3410_2001_CryptoPro_XchA_ParamSet_oid_str_param,
.name = &gost_R3410_2001_CryptoPro_XchA_ParamSet_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 17)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 17
#endif
#if (MAX_CURVE_NAME_LEN < 55)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 55
#endif
#endif /* __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET_H__ */
#endif /* WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET */

View file

@ -0,0 +1,333 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET
#ifndef __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET_H__
#define __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_p[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3,
0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x9b,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_p);
#define CURVE_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET_P_BITLEN 256
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_p_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_r[] = {
0x64, 0x60, 0x9f, 0xa0, 0xa5, 0x7a, 0x7e, 0xf8,
0x54, 0xe1, 0x37, 0xa1, 0x94, 0xbe, 0x37, 0x55,
0x30, 0x7b, 0x91, 0x79, 0x87, 0x6f, 0xae, 0x2c,
0x86, 0x67, 0x08, 0x46, 0xfd, 0xd2, 0x8a, 0x65,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_r);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_r_square[] = {
0x80, 0x7a, 0x39, 0x4e, 0xde, 0x09, 0x76, 0x52,
0x18, 0x63, 0x04, 0x21, 0x28, 0x49, 0xc0, 0x7b,
0x10, 0x17, 0xbb, 0x39, 0xc2, 0xd3, 0x46, 0xc5,
0x40, 0x99, 0x73, 0xb4, 0xc4, 0x27, 0xfc, 0xea,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_r_square);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_mpinv[] = {
0xdf, 0x6e, 0x6c, 0x2c, 0x72, 0x7c, 0x17, 0x6d,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_mpinv);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_p_shift);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_p_normalized[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3,
0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x9b,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_p_normalized);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_p_reciprocal[] = {
0xa5, 0x1f, 0x17, 0x61, 0x61, 0xf1, 0xd7, 0x34,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_r[] = {
0x64, 0x60, 0x9f, 0xa0, 0xa5, 0x7a, 0x7e, 0xf8,
0x54, 0xe1, 0x37, 0xa1, 0x94, 0xbe, 0x37, 0x55,
0x30, 0x7b, 0x91, 0x79, 0x87, 0x6f, 0xae, 0x2c,
0x86, 0x67, 0x08, 0x46, 0xfd, 0xd2, 0x8a, 0x65,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_r);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_r_square[] = {
0x80, 0x7a, 0x39, 0x4e, 0xde, 0x09, 0x76, 0x52,
0x18, 0x63, 0x04, 0x21, 0x28, 0x49, 0xc0, 0x7b,
0x10, 0x17, 0xbb, 0x39, 0xc2, 0xd3, 0x46, 0xc5,
0x40, 0x99, 0x73, 0xb4, 0xc4, 0x27, 0xfc, 0xea,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_r_square);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_mpinv[] = {
0x72, 0x7c, 0x17, 0x6d,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_mpinv);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_p_shift);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_p_normalized[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3,
0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x9b,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_p_normalized);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_p_reciprocal[] = {
0xa5, 0x1f, 0x17, 0x61,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_r[] = {
0x64, 0x60, 0x9f, 0xa0, 0xa5, 0x7a, 0x7e, 0xf8,
0x54, 0xe1, 0x37, 0xa1, 0x94, 0xbe, 0x37, 0x55,
0x30, 0x7b, 0x91, 0x79, 0x87, 0x6f, 0xae, 0x2c,
0x86, 0x67, 0x08, 0x46, 0xfd, 0xd2, 0x8a, 0x65,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_r);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_r_square[] = {
0x80, 0x7a, 0x39, 0x4e, 0xde, 0x09, 0x76, 0x52,
0x18, 0x63, 0x04, 0x21, 0x28, 0x49, 0xc0, 0x7b,
0x10, 0x17, 0xbb, 0x39, 0xc2, 0xd3, 0x46, 0xc5,
0x40, 0x99, 0x73, 0xb4, 0xc4, 0x27, 0xfc, 0xea,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_r_square);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_mpinv[] = {
0x17, 0x6d,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_mpinv);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_p_shift);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_p_normalized[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3,
0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x9b,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_p_normalized);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_p_reciprocal[] = {
0xa5, 0x1f,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_a[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3,
0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x98,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_a);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_b[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x5a,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_b);
#define CURVE_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET_CURVE_ORDER_BITLEN 256
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_curve_order[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0x58, 0x2c, 0xa3, 0x51, 0x1e, 0xdd, 0xfb, 0x74,
0xf0, 0x2f, 0x3a, 0x65, 0x98, 0x98, 0x0b, 0xb9,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_curve_order);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_gx[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_gx);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_gy[] = {
0x41, 0xec, 0xe5, 0x57, 0x43, 0x71, 0x1a, 0x8c,
0x3c, 0xbf, 0x37, 0x83, 0xcd, 0x08, 0xc0, 0xee,
0x4d, 0x4d, 0xc4, 0x40, 0xd4, 0x64, 0x1a, 0x8f,
0x36, 0x6e, 0x55, 0x0d, 0xfd, 0xb3, 0xbb, 0x67,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_gy);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_gz);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_gen_order[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0x58, 0x2c, 0xa3, 0x51, 0x1e, 0xdd, 0xfb, 0x74,
0xf0, 0x2f, 0x3a, 0x65, 0x98, 0x98, 0x0b, 0xb9,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_gen_order);
#define CURVE_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET_Q_BITLEN 256
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_gen_order_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_gen_order_bitlen);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_cofactor);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_XchB_ParamSet_alpha_montgomery, 0);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_XchB_ParamSet_gamma_montgomery, 0);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_XchB_ParamSet_alpha_edwards, 0);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_name[] = "GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET";
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_name);
static const u8 gost_R3410_2001_CryptoPro_XchB_ParamSet_oid[] = "1.2.643.2.2.36.1";
TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_XchB_ParamSet_oid);
static const ec_str_params gost_R3410_2001_CryptoPro_XchB_ParamSet_str_params = {
.p = &gost_R3410_2001_CryptoPro_XchB_ParamSet_p_str_param,
.p_bitlen = &gost_R3410_2001_CryptoPro_XchB_ParamSet_p_bitlen_str_param,
.r = &gost_R3410_2001_CryptoPro_XchB_ParamSet_r_str_param,
.r_square = &gost_R3410_2001_CryptoPro_XchB_ParamSet_r_square_str_param,
.mpinv = &gost_R3410_2001_CryptoPro_XchB_ParamSet_mpinv_str_param,
.p_shift = &gost_R3410_2001_CryptoPro_XchB_ParamSet_p_shift_str_param,
.p_normalized = &gost_R3410_2001_CryptoPro_XchB_ParamSet_p_normalized_str_param,
.p_reciprocal = &gost_R3410_2001_CryptoPro_XchB_ParamSet_p_reciprocal_str_param,
.a = &gost_R3410_2001_CryptoPro_XchB_ParamSet_a_str_param,
.b = &gost_R3410_2001_CryptoPro_XchB_ParamSet_b_str_param,
.curve_order = &gost_R3410_2001_CryptoPro_XchB_ParamSet_curve_order_str_param,
.gx = &gost_R3410_2001_CryptoPro_XchB_ParamSet_gx_str_param,
.gy = &gost_R3410_2001_CryptoPro_XchB_ParamSet_gy_str_param,
.gz = &gost_R3410_2001_CryptoPro_XchB_ParamSet_gz_str_param,
.gen_order = &gost_R3410_2001_CryptoPro_XchB_ParamSet_gen_order_str_param,
.gen_order_bitlen = &gost_R3410_2001_CryptoPro_XchB_ParamSet_gen_order_bitlen_str_param,
.cofactor = &gost_R3410_2001_CryptoPro_XchB_ParamSet_cofactor_str_param,
.alpha_montgomery = &gost_R3410_2001_CryptoPro_XchB_ParamSet_alpha_montgomery_str_param,
.gamma_montgomery = &gost_R3410_2001_CryptoPro_XchB_ParamSet_gamma_montgomery_str_param,
.alpha_edwards = &gost_R3410_2001_CryptoPro_XchB_ParamSet_alpha_edwards_str_param,
.oid = &gost_R3410_2001_CryptoPro_XchB_ParamSet_oid_str_param,
.name = &gost_R3410_2001_CryptoPro_XchB_ParamSet_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 17)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 17
#endif
#if (MAX_CURVE_NAME_LEN < 55)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 55
#endif
#endif /* __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET_H__ */
#endif /* WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET */

View file

@ -0,0 +1,324 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_GOST_R3410_2001_TESTPARAMSET
#ifndef __EC_PARAMS_GOST_R3410_2001_TESTPARAMSET_H__
#define __EC_PARAMS_GOST_R3410_2001_TESTPARAMSET_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 gost_R3410_2001_TestParamSet_p[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x31,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p);
#define CURVE_GOST_R3410_2001_TESTPARAMSET_P_BITLEN 256
static const u8 gost_R3410_2001_TestParamSet_p_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 gost_R3410_2001_TestParamSet_r[] = {
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xcf,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_r);
static const u8 gost_R3410_2001_TestParamSet_r_square[] = {
0x46, 0x45, 0x84,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_r_square);
static const u8 gost_R3410_2001_TestParamSet_mpinv[] = {
0xdb, 0xf9, 0x51, 0xd5, 0x88, 0x3b, 0x2b, 0x2f,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_mpinv);
static const u8 gost_R3410_2001_TestParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_shift);
static const u8 gost_R3410_2001_TestParamSet_p_normalized[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x31,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_normalized);
static const u8 gost_R3410_2001_TestParamSet_p_reciprocal[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 gost_R3410_2001_TestParamSet_r[] = {
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xcf,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_r);
static const u8 gost_R3410_2001_TestParamSet_r_square[] = {
0x46, 0x45, 0x84,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_r_square);
static const u8 gost_R3410_2001_TestParamSet_mpinv[] = {
0x88, 0x3b, 0x2b, 0x2f,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_mpinv);
static const u8 gost_R3410_2001_TestParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_shift);
static const u8 gost_R3410_2001_TestParamSet_p_normalized[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x31,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_normalized);
static const u8 gost_R3410_2001_TestParamSet_p_reciprocal[] = {
0xff, 0xff, 0xff, 0xff,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 gost_R3410_2001_TestParamSet_r[] = {
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xcf,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_r);
static const u8 gost_R3410_2001_TestParamSet_r_square[] = {
0x46, 0x45, 0x84,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_r_square);
static const u8 gost_R3410_2001_TestParamSet_mpinv[] = {
0x2b, 0x2f,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_mpinv);
static const u8 gost_R3410_2001_TestParamSet_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_shift);
static const u8 gost_R3410_2001_TestParamSet_p_normalized[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x31,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_normalized);
static const u8 gost_R3410_2001_TestParamSet_p_reciprocal[] = {
0xff, 0xff,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 gost_R3410_2001_TestParamSet_a[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_a);
static const u8 gost_R3410_2001_TestParamSet_b[] = {
0x5f, 0xbf, 0xf4, 0x98, 0xaa, 0x93, 0x8c, 0xe7,
0x39, 0xb8, 0xe0, 0x22, 0xfb, 0xaf, 0xef, 0x40,
0x56, 0x3f, 0x6e, 0x6a, 0x34, 0x72, 0xfc, 0x2a,
0x51, 0x4c, 0x0c, 0xe9, 0xda, 0xe2, 0x3b, 0x7e,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_b);
#define CURVE_GOST_R3410_2001_TESTPARAMSET_CURVE_ORDER_BITLEN 256
static const u8 gost_R3410_2001_TestParamSet_curve_order[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x50, 0xfe, 0x8a, 0x18, 0x92, 0x97, 0x61, 0x54,
0xc5, 0x9c, 0xfc, 0x19, 0x3a, 0xcc, 0xf5, 0xb3,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_curve_order);
static const u8 gost_R3410_2001_TestParamSet_gx[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_gx);
static const u8 gost_R3410_2001_TestParamSet_gy[] = {
0x08, 0xe2, 0xa8, 0xa0, 0xe6, 0x51, 0x47, 0xd4,
0xbd, 0x63, 0x16, 0x03, 0x0e, 0x16, 0xd1, 0x9c,
0x85, 0xc9, 0x7f, 0x0a, 0x9c, 0xa2, 0x67, 0x12,
0x2b, 0x96, 0xab, 0xbc, 0xea, 0x7e, 0x8f, 0xc8,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_gy);
static const u8 gost_R3410_2001_TestParamSet_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_gz);
static const u8 gost_R3410_2001_TestParamSet_gen_order[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x50, 0xfe, 0x8a, 0x18, 0x92, 0x97, 0x61, 0x54,
0xc5, 0x9c, 0xfc, 0x19, 0x3a, 0xcc, 0xf5, 0xb3,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_gen_order);
#define CURVE_GOST_R3410_2001_TESTPARAMSET_Q_BITLEN 256
static const u8 gost_R3410_2001_TestParamSet_gen_order_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_gen_order_bitlen);
static const u8 gost_R3410_2001_TestParamSet_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_cofactor);
static const u8 gost_R3410_2001_TestParamSet_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_TestParamSet_alpha_montgomery, 0);
static const u8 gost_R3410_2001_TestParamSet_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_TestParamSet_gamma_montgomery, 0);
static const u8 gost_R3410_2001_TestParamSet_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_TestParamSet_alpha_edwards, 0);
static const u8 gost_R3410_2001_TestParamSet_name[] = "GOST_R3410_2001_TESTPARAMSET";
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_name);
static const u8 gost_R3410_2001_TestParamSet_oid[] = "1.2.643.2.2.35.0";
TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_oid);
static const ec_str_params gost_R3410_2001_TestParamSet_str_params = {
.p = &gost_R3410_2001_TestParamSet_p_str_param,
.p_bitlen = &gost_R3410_2001_TestParamSet_p_bitlen_str_param,
.r = &gost_R3410_2001_TestParamSet_r_str_param,
.r_square = &gost_R3410_2001_TestParamSet_r_square_str_param,
.mpinv = &gost_R3410_2001_TestParamSet_mpinv_str_param,
.p_shift = &gost_R3410_2001_TestParamSet_p_shift_str_param,
.p_normalized = &gost_R3410_2001_TestParamSet_p_normalized_str_param,
.p_reciprocal = &gost_R3410_2001_TestParamSet_p_reciprocal_str_param,
.a = &gost_R3410_2001_TestParamSet_a_str_param,
.b = &gost_R3410_2001_TestParamSet_b_str_param,
.curve_order = &gost_R3410_2001_TestParamSet_curve_order_str_param,
.gx = &gost_R3410_2001_TestParamSet_gx_str_param,
.gy = &gost_R3410_2001_TestParamSet_gy_str_param,
.gz = &gost_R3410_2001_TestParamSet_gz_str_param,
.gen_order = &gost_R3410_2001_TestParamSet_gen_order_str_param,
.gen_order_bitlen = &gost_R3410_2001_TestParamSet_gen_order_bitlen_str_param,
.cofactor = &gost_R3410_2001_TestParamSet_cofactor_str_param,
.alpha_montgomery = &gost_R3410_2001_TestParamSet_alpha_montgomery_str_param,
.gamma_montgomery = &gost_R3410_2001_TestParamSet_gamma_montgomery_str_param,
.alpha_edwards = &gost_R3410_2001_TestParamSet_alpha_edwards_str_param,
.oid = &gost_R3410_2001_TestParamSet_oid_str_param,
.name = &gost_R3410_2001_TestParamSet_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2001_TESTPARAMSET_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2001_TESTPARAMSET_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2001_TESTPARAMSET_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2001_TESTPARAMSET_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2001_TESTPARAMSET_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2001_TESTPARAMSET_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 17)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 17
#endif
#if (MAX_CURVE_NAME_LEN < 44)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 44
#endif
#endif /* __EC_PARAMS_GOST_R3410_2001_TESTPARAMSET_H__ */
#endif /* WITH_CURVE_GOST_R3410_2001_TESTPARAMSET */

View file

@ -0,0 +1,316 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_GOST_R3410_2012_256_PARAMSETA
#ifndef __EC_PARAMS_GOST_R3410_2012_256_PARAMSETA_H__
#define __EC_PARAMS_GOST_R3410_2012_256_PARAMSETA_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 gost_R3410_2012_256_paramSetA_p[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p);
#define CURVE_GOST_R3410_2012_256_PARAMSETA_P_BITLEN 256
static const u8 gost_R3410_2012_256_paramSetA_p_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 gost_R3410_2012_256_paramSetA_r[] = {
0x02, 0x69,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_r);
static const u8 gost_R3410_2012_256_paramSetA_r_square[] = {
0x05, 0xcf, 0x11,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_r_square);
static const u8 gost_R3410_2012_256_paramSetA_mpinv[] = {
0x46, 0xf3, 0x23, 0x44, 0x75, 0xd5, 0xad, 0xd9,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_mpinv);
static const u8 gost_R3410_2012_256_paramSetA_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_shift);
static const u8 gost_R3410_2012_256_paramSetA_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_normalized);
static const u8 gost_R3410_2012_256_paramSetA_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 gost_R3410_2012_256_paramSetA_r[] = {
0x02, 0x69,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_r);
static const u8 gost_R3410_2012_256_paramSetA_r_square[] = {
0x05, 0xcf, 0x11,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_r_square);
static const u8 gost_R3410_2012_256_paramSetA_mpinv[] = {
0x75, 0xd5, 0xad, 0xd9,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_mpinv);
static const u8 gost_R3410_2012_256_paramSetA_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_shift);
static const u8 gost_R3410_2012_256_paramSetA_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_normalized);
static const u8 gost_R3410_2012_256_paramSetA_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 gost_R3410_2012_256_paramSetA_r[] = {
0x02, 0x69,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_r);
static const u8 gost_R3410_2012_256_paramSetA_r_square[] = {
0x05, 0xcf, 0x11,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_r_square);
static const u8 gost_R3410_2012_256_paramSetA_mpinv[] = {
0xad, 0xd9,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_mpinv);
static const u8 gost_R3410_2012_256_paramSetA_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_shift);
static const u8 gost_R3410_2012_256_paramSetA_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_normalized);
static const u8 gost_R3410_2012_256_paramSetA_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 gost_R3410_2012_256_paramSetA_a[] = {
0xc2, 0x17, 0x3f, 0x15, 0x13, 0x98, 0x16, 0x73,
0xaf, 0x48, 0x92, 0xc2, 0x30, 0x35, 0xa2, 0x7c,
0xe2, 0x5e, 0x20, 0x13, 0xbf, 0x95, 0xaa, 0x33,
0xb2, 0x2c, 0x65, 0x6f, 0x27, 0x7e, 0x73, 0x35,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_a);
static const u8 gost_R3410_2012_256_paramSetA_b[] = {
0x29, 0x5f, 0x9b, 0xae, 0x74, 0x28, 0xed, 0x9c,
0xcc, 0x20, 0xe7, 0xc3, 0x59, 0xa9, 0xd4, 0x1a,
0x22, 0xfc, 0xcd, 0x91, 0x08, 0xe1, 0x7b, 0xf7,
0xba, 0x93, 0x37, 0xa6, 0xf8, 0xae, 0x95, 0x13,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_b);
#define CURVE_GOST_R3410_2012_256_PARAMSETA_CURVE_ORDER_BITLEN 257
static const u8 gost_R3410_2012_256_paramSetA_curve_order[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3f, 0x63, 0x37, 0x7f, 0x21, 0xed, 0x98,
0xd7, 0x04, 0x56, 0xbd, 0x55, 0xb0, 0xd8, 0x31,
0x9c,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_curve_order);
static const u8 gost_R3410_2012_256_paramSetA_gx[] = {
0x91, 0xe3, 0x84, 0x43, 0xa5, 0xe8, 0x2c, 0x0d,
0x88, 0x09, 0x23, 0x42, 0x57, 0x12, 0xb2, 0xbb,
0x65, 0x8b, 0x91, 0x96, 0x93, 0x2e, 0x02, 0xc7,
0x8b, 0x25, 0x82, 0xfe, 0x74, 0x2d, 0xaa, 0x28,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_gx);
static const u8 gost_R3410_2012_256_paramSetA_gy[] = {
0x32, 0x87, 0x94, 0x23, 0xab, 0x1a, 0x03, 0x75,
0x89, 0x57, 0x86, 0xc4, 0xbb, 0x46, 0xe9, 0x56,
0x5f, 0xde, 0x0b, 0x53, 0x44, 0x76, 0x67, 0x40,
0xaf, 0x26, 0x8a, 0xdb, 0x32, 0x32, 0x2e, 0x5c,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_gy);
static const u8 gost_R3410_2012_256_paramSetA_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_gz);
static const u8 gost_R3410_2012_256_paramSetA_gen_order[] = {
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0f, 0xd8, 0xcd, 0xdf, 0xc8, 0x7b, 0x66, 0x35,
0xc1, 0x15, 0xaf, 0x55, 0x6c, 0x36, 0x0c, 0x67,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_gen_order);
#define CURVE_GOST_R3410_2012_256_PARAMSETA_Q_BITLEN 255
static const u8 gost_R3410_2012_256_paramSetA_gen_order_bitlen[] = {
0xff,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_gen_order_bitlen);
static const u8 gost_R3410_2012_256_paramSetA_cofactor[] = {
0x04,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_cofactor);
static const u8 gost_R3410_2012_256_paramSetA_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetA_alpha_montgomery, 0);
static const u8 gost_R3410_2012_256_paramSetA_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetA_gamma_montgomery, 0);
static const u8 gost_R3410_2012_256_paramSetA_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetA_alpha_edwards, 0);
static const u8 gost_R3410_2012_256_paramSetA_name[] = "GOST_R3410_2012_256_PARAMSETA";
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_name);
static const u8 gost_R3410_2012_256_paramSetA_oid[] = "1.2.643.7.1.2.1.1.1";
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_oid);
static const ec_str_params gost_R3410_2012_256_paramSetA_str_params = {
.p = &gost_R3410_2012_256_paramSetA_p_str_param,
.p_bitlen = &gost_R3410_2012_256_paramSetA_p_bitlen_str_param,
.r = &gost_R3410_2012_256_paramSetA_r_str_param,
.r_square = &gost_R3410_2012_256_paramSetA_r_square_str_param,
.mpinv = &gost_R3410_2012_256_paramSetA_mpinv_str_param,
.p_shift = &gost_R3410_2012_256_paramSetA_p_shift_str_param,
.p_normalized = &gost_R3410_2012_256_paramSetA_p_normalized_str_param,
.p_reciprocal = &gost_R3410_2012_256_paramSetA_p_reciprocal_str_param,
.a = &gost_R3410_2012_256_paramSetA_a_str_param,
.b = &gost_R3410_2012_256_paramSetA_b_str_param,
.curve_order = &gost_R3410_2012_256_paramSetA_curve_order_str_param,
.gx = &gost_R3410_2012_256_paramSetA_gx_str_param,
.gy = &gost_R3410_2012_256_paramSetA_gy_str_param,
.gz = &gost_R3410_2012_256_paramSetA_gz_str_param,
.gen_order = &gost_R3410_2012_256_paramSetA_gen_order_str_param,
.gen_order_bitlen = &gost_R3410_2012_256_paramSetA_gen_order_bitlen_str_param,
.cofactor = &gost_R3410_2012_256_paramSetA_cofactor_str_param,
.alpha_montgomery = &gost_R3410_2012_256_paramSetA_alpha_montgomery_str_param,
.gamma_montgomery = &gost_R3410_2012_256_paramSetA_gamma_montgomery_str_param,
.alpha_edwards = &gost_R3410_2012_256_paramSetA_alpha_edwards_str_param,
.oid = &gost_R3410_2012_256_paramSetA_oid_str_param,
.name = &gost_R3410_2012_256_paramSetA_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETA_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETA_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETA_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETA_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETA_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETA_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 20)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 20
#endif
#if (MAX_CURVE_NAME_LEN < 50)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 50
#endif
#endif /* __EC_PARAMS_GOST_R3410_2012_256_PARAMSETA_H__ */
#endif /* WITH_CURVE_GOST_R3410_2012_256_PARAMSETA */

View file

@ -0,0 +1,315 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_GOST_R3410_2012_256_PARAMSETB
#ifndef __EC_PARAMS_GOST_R3410_2012_256_PARAMSETB_H__
#define __EC_PARAMS_GOST_R3410_2012_256_PARAMSETB_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 gost_R3410_2012_256_paramSetB_p[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p);
#define CURVE_GOST_R3410_2012_256_PARAMSETB_P_BITLEN 256
static const u8 gost_R3410_2012_256_paramSetB_p_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 gost_R3410_2012_256_paramSetB_r[] = {
0x02, 0x69,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_r);
static const u8 gost_R3410_2012_256_paramSetB_r_square[] = {
0x05, 0xcf, 0x11,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_r_square);
static const u8 gost_R3410_2012_256_paramSetB_mpinv[] = {
0x46, 0xf3, 0x23, 0x44, 0x75, 0xd5, 0xad, 0xd9,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_mpinv);
static const u8 gost_R3410_2012_256_paramSetB_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_shift);
static const u8 gost_R3410_2012_256_paramSetB_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_normalized);
static const u8 gost_R3410_2012_256_paramSetB_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 gost_R3410_2012_256_paramSetB_r[] = {
0x02, 0x69,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_r);
static const u8 gost_R3410_2012_256_paramSetB_r_square[] = {
0x05, 0xcf, 0x11,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_r_square);
static const u8 gost_R3410_2012_256_paramSetB_mpinv[] = {
0x75, 0xd5, 0xad, 0xd9,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_mpinv);
static const u8 gost_R3410_2012_256_paramSetB_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_shift);
static const u8 gost_R3410_2012_256_paramSetB_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_normalized);
static const u8 gost_R3410_2012_256_paramSetB_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 gost_R3410_2012_256_paramSetB_r[] = {
0x02, 0x69,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_r);
static const u8 gost_R3410_2012_256_paramSetB_r_square[] = {
0x05, 0xcf, 0x11,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_r_square);
static const u8 gost_R3410_2012_256_paramSetB_mpinv[] = {
0xad, 0xd9,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_mpinv);
static const u8 gost_R3410_2012_256_paramSetB_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_shift);
static const u8 gost_R3410_2012_256_paramSetB_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_normalized);
static const u8 gost_R3410_2012_256_paramSetB_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 gost_R3410_2012_256_paramSetB_a[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x94,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_a);
static const u8 gost_R3410_2012_256_paramSetB_b[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_b);
#define CURVE_GOST_R3410_2012_256_PARAMSETB_CURVE_ORDER_BITLEN 256
static const u8 gost_R3410_2012_256_paramSetB_curve_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x6c, 0x61, 0x10, 0x70, 0x99, 0x5a, 0xd1, 0x00,
0x45, 0x84, 0x1b, 0x09, 0xb7, 0x61, 0xb8, 0x93,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_curve_order);
static const u8 gost_R3410_2012_256_paramSetB_gx[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_gx);
static const u8 gost_R3410_2012_256_paramSetB_gy[] = {
0x8d, 0x91, 0xe4, 0x71, 0xe0, 0x98, 0x9c, 0xda,
0x27, 0xdf, 0x50, 0x5a, 0x45, 0x3f, 0x2b, 0x76,
0x35, 0x29, 0x4f, 0x2d, 0xdf, 0x23, 0xe3, 0xb1,
0x22, 0xac, 0xc9, 0x9c, 0x9e, 0x9f, 0x1e, 0x14,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_gy);
static const u8 gost_R3410_2012_256_paramSetB_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_gz);
static const u8 gost_R3410_2012_256_paramSetB_gen_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x6c, 0x61, 0x10, 0x70, 0x99, 0x5a, 0xd1, 0x00,
0x45, 0x84, 0x1b, 0x09, 0xb7, 0x61, 0xb8, 0x93,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_gen_order);
#define CURVE_GOST_R3410_2012_256_PARAMSETB_Q_BITLEN 256
static const u8 gost_R3410_2012_256_paramSetB_gen_order_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_gen_order_bitlen);
static const u8 gost_R3410_2012_256_paramSetB_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_cofactor);
static const u8 gost_R3410_2012_256_paramSetB_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetB_alpha_montgomery, 0);
static const u8 gost_R3410_2012_256_paramSetB_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetB_gamma_montgomery, 0);
static const u8 gost_R3410_2012_256_paramSetB_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetB_alpha_edwards, 0);
static const u8 gost_R3410_2012_256_paramSetB_name[] = "GOST_R3410_2012_256_PARAMSETB";
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_name);
static const u8 gost_R3410_2012_256_paramSetB_oid[] = "1.2.643.7.1.2.1.1.2";
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_oid);
static const ec_str_params gost_R3410_2012_256_paramSetB_str_params = {
.p = &gost_R3410_2012_256_paramSetB_p_str_param,
.p_bitlen = &gost_R3410_2012_256_paramSetB_p_bitlen_str_param,
.r = &gost_R3410_2012_256_paramSetB_r_str_param,
.r_square = &gost_R3410_2012_256_paramSetB_r_square_str_param,
.mpinv = &gost_R3410_2012_256_paramSetB_mpinv_str_param,
.p_shift = &gost_R3410_2012_256_paramSetB_p_shift_str_param,
.p_normalized = &gost_R3410_2012_256_paramSetB_p_normalized_str_param,
.p_reciprocal = &gost_R3410_2012_256_paramSetB_p_reciprocal_str_param,
.a = &gost_R3410_2012_256_paramSetB_a_str_param,
.b = &gost_R3410_2012_256_paramSetB_b_str_param,
.curve_order = &gost_R3410_2012_256_paramSetB_curve_order_str_param,
.gx = &gost_R3410_2012_256_paramSetB_gx_str_param,
.gy = &gost_R3410_2012_256_paramSetB_gy_str_param,
.gz = &gost_R3410_2012_256_paramSetB_gz_str_param,
.gen_order = &gost_R3410_2012_256_paramSetB_gen_order_str_param,
.gen_order_bitlen = &gost_R3410_2012_256_paramSetB_gen_order_bitlen_str_param,
.cofactor = &gost_R3410_2012_256_paramSetB_cofactor_str_param,
.alpha_montgomery = &gost_R3410_2012_256_paramSetB_alpha_montgomery_str_param,
.gamma_montgomery = &gost_R3410_2012_256_paramSetB_gamma_montgomery_str_param,
.alpha_edwards = &gost_R3410_2012_256_paramSetB_alpha_edwards_str_param,
.oid = &gost_R3410_2012_256_paramSetB_oid_str_param,
.name = &gost_R3410_2012_256_paramSetB_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETB_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETB_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETB_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETB_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETB_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETB_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 20)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 20
#endif
#if (MAX_CURVE_NAME_LEN < 50)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 50
#endif
#endif /* __EC_PARAMS_GOST_R3410_2012_256_PARAMSETB_H__ */
#endif /* WITH_CURVE_GOST_R3410_2012_256_PARAMSETB */

View file

@ -0,0 +1,324 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_GOST_R3410_2012_256_PARAMSETC
#ifndef __EC_PARAMS_GOST_R3410_2012_256_PARAMSETC_H__
#define __EC_PARAMS_GOST_R3410_2012_256_PARAMSETC_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 gost_R3410_2012_256_paramSetC_p[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x99,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_p);
#define CURVE_GOST_R3410_2012_256_PARAMSETC_P_BITLEN 256
static const u8 gost_R3410_2012_256_paramSetC_p_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 gost_R3410_2012_256_paramSetC_r[] = {
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x67,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_r);
static const u8 gost_R3410_2012_256_paramSetC_r_square[] = {
0x02, 0x7a, 0xcd, 0xc4,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_r_square);
static const u8 gost_R3410_2012_256_paramSetC_mpinv[] = {
0xbd, 0x66, 0x7a, 0xb8, 0xa3, 0x34, 0x78, 0x57,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_mpinv);
static const u8 gost_R3410_2012_256_paramSetC_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_p_shift);
static const u8 gost_R3410_2012_256_paramSetC_p_normalized[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x99,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_p_normalized);
static const u8 gost_R3410_2012_256_paramSetC_p_reciprocal[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 gost_R3410_2012_256_paramSetC_r[] = {
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x67,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_r);
static const u8 gost_R3410_2012_256_paramSetC_r_square[] = {
0x02, 0x7a, 0xcd, 0xc4,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_r_square);
static const u8 gost_R3410_2012_256_paramSetC_mpinv[] = {
0xa3, 0x34, 0x78, 0x57,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_mpinv);
static const u8 gost_R3410_2012_256_paramSetC_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_p_shift);
static const u8 gost_R3410_2012_256_paramSetC_p_normalized[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x99,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_p_normalized);
static const u8 gost_R3410_2012_256_paramSetC_p_reciprocal[] = {
0xff, 0xff, 0xff, 0xff,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 gost_R3410_2012_256_paramSetC_r[] = {
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x67,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_r);
static const u8 gost_R3410_2012_256_paramSetC_r_square[] = {
0x02, 0x7a, 0xcd, 0xc4,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_r_square);
static const u8 gost_R3410_2012_256_paramSetC_mpinv[] = {
0x78, 0x57,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_mpinv);
static const u8 gost_R3410_2012_256_paramSetC_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_p_shift);
static const u8 gost_R3410_2012_256_paramSetC_p_normalized[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x99,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_p_normalized);
static const u8 gost_R3410_2012_256_paramSetC_p_reciprocal[] = {
0xff, 0xff,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 gost_R3410_2012_256_paramSetC_a[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x96,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_a);
static const u8 gost_R3410_2012_256_paramSetC_b[] = {
0x3e, 0x1a, 0xf4, 0x19, 0xa2, 0x69, 0xa5, 0xf8,
0x66, 0xa7, 0xd3, 0xc2, 0x5c, 0x3d, 0xf8, 0x0a,
0xe9, 0x79, 0x25, 0x93, 0x73, 0xff, 0x2b, 0x18,
0x2f, 0x49, 0xd4, 0xce, 0x7e, 0x1b, 0xbc, 0x8b,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_b);
#define CURVE_GOST_R3410_2012_256_PARAMSETC_CURVE_ORDER_BITLEN 256
static const u8 gost_R3410_2012_256_paramSetC_curve_order[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x5f, 0x70, 0x0c, 0xff, 0xf1, 0xa6, 0x24, 0xe5,
0xe4, 0x97, 0x16, 0x1b, 0xcc, 0x8a, 0x19, 0x8f,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_curve_order);
static const u8 gost_R3410_2012_256_paramSetC_gx[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_gx);
static const u8 gost_R3410_2012_256_paramSetC_gy[] = {
0x3f, 0xa8, 0x12, 0x43, 0x59, 0xf9, 0x66, 0x80,
0xb8, 0x3d, 0x1c, 0x3e, 0xb2, 0xc0, 0x70, 0xe5,
0xc5, 0x45, 0xc9, 0x85, 0x8d, 0x03, 0xec, 0xfb,
0x74, 0x4b, 0xf8, 0xd7, 0x17, 0x71, 0x7e, 0xfc,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_gy);
static const u8 gost_R3410_2012_256_paramSetC_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_gz);
static const u8 gost_R3410_2012_256_paramSetC_gen_order[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x5f, 0x70, 0x0c, 0xff, 0xf1, 0xa6, 0x24, 0xe5,
0xe4, 0x97, 0x16, 0x1b, 0xcc, 0x8a, 0x19, 0x8f,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_gen_order);
#define CURVE_GOST_R3410_2012_256_PARAMSETC_Q_BITLEN 256
static const u8 gost_R3410_2012_256_paramSetC_gen_order_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_gen_order_bitlen);
static const u8 gost_R3410_2012_256_paramSetC_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_cofactor);
static const u8 gost_R3410_2012_256_paramSetC_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetC_alpha_montgomery, 0);
static const u8 gost_R3410_2012_256_paramSetC_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetC_gamma_montgomery, 0);
static const u8 gost_R3410_2012_256_paramSetC_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetC_alpha_edwards, 0);
static const u8 gost_R3410_2012_256_paramSetC_name[] = "GOST_R3410_2012_256_PARAMSETC";
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_name);
static const u8 gost_R3410_2012_256_paramSetC_oid[] = "1.2.643.7.1.2.1.1.3";
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetC_oid);
static const ec_str_params gost_R3410_2012_256_paramSetC_str_params = {
.p = &gost_R3410_2012_256_paramSetC_p_str_param,
.p_bitlen = &gost_R3410_2012_256_paramSetC_p_bitlen_str_param,
.r = &gost_R3410_2012_256_paramSetC_r_str_param,
.r_square = &gost_R3410_2012_256_paramSetC_r_square_str_param,
.mpinv = &gost_R3410_2012_256_paramSetC_mpinv_str_param,
.p_shift = &gost_R3410_2012_256_paramSetC_p_shift_str_param,
.p_normalized = &gost_R3410_2012_256_paramSetC_p_normalized_str_param,
.p_reciprocal = &gost_R3410_2012_256_paramSetC_p_reciprocal_str_param,
.a = &gost_R3410_2012_256_paramSetC_a_str_param,
.b = &gost_R3410_2012_256_paramSetC_b_str_param,
.curve_order = &gost_R3410_2012_256_paramSetC_curve_order_str_param,
.gx = &gost_R3410_2012_256_paramSetC_gx_str_param,
.gy = &gost_R3410_2012_256_paramSetC_gy_str_param,
.gz = &gost_R3410_2012_256_paramSetC_gz_str_param,
.gen_order = &gost_R3410_2012_256_paramSetC_gen_order_str_param,
.gen_order_bitlen = &gost_R3410_2012_256_paramSetC_gen_order_bitlen_str_param,
.cofactor = &gost_R3410_2012_256_paramSetC_cofactor_str_param,
.alpha_montgomery = &gost_R3410_2012_256_paramSetC_alpha_montgomery_str_param,
.gamma_montgomery = &gost_R3410_2012_256_paramSetC_gamma_montgomery_str_param,
.alpha_edwards = &gost_R3410_2012_256_paramSetC_alpha_edwards_str_param,
.oid = &gost_R3410_2012_256_paramSetC_oid_str_param,
.name = &gost_R3410_2012_256_paramSetC_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETC_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETC_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETC_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETC_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETC_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETC_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 20)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 20
#endif
#if (MAX_CURVE_NAME_LEN < 50)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 50
#endif
#endif /* __EC_PARAMS_GOST_R3410_2012_256_PARAMSETC_H__ */
#endif /* WITH_CURVE_GOST_R3410_2012_256_PARAMSETC */

View file

@ -0,0 +1,333 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_GOST_R3410_2012_256_PARAMSETD
#ifndef __EC_PARAMS_GOST_R3410_2012_256_PARAMSETD_H__
#define __EC_PARAMS_GOST_R3410_2012_256_PARAMSETD_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 gost_R3410_2012_256_paramSetD_p[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3,
0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x9b,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_p);
#define CURVE_GOST_R3410_2012_256_PARAMSETD_P_BITLEN 256
static const u8 gost_R3410_2012_256_paramSetD_p_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 gost_R3410_2012_256_paramSetD_r[] = {
0x64, 0x60, 0x9f, 0xa0, 0xa5, 0x7a, 0x7e, 0xf8,
0x54, 0xe1, 0x37, 0xa1, 0x94, 0xbe, 0x37, 0x55,
0x30, 0x7b, 0x91, 0x79, 0x87, 0x6f, 0xae, 0x2c,
0x86, 0x67, 0x08, 0x46, 0xfd, 0xd2, 0x8a, 0x65,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_r);
static const u8 gost_R3410_2012_256_paramSetD_r_square[] = {
0x80, 0x7a, 0x39, 0x4e, 0xde, 0x09, 0x76, 0x52,
0x18, 0x63, 0x04, 0x21, 0x28, 0x49, 0xc0, 0x7b,
0x10, 0x17, 0xbb, 0x39, 0xc2, 0xd3, 0x46, 0xc5,
0x40, 0x99, 0x73, 0xb4, 0xc4, 0x27, 0xfc, 0xea,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_r_square);
static const u8 gost_R3410_2012_256_paramSetD_mpinv[] = {
0xdf, 0x6e, 0x6c, 0x2c, 0x72, 0x7c, 0x17, 0x6d,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_mpinv);
static const u8 gost_R3410_2012_256_paramSetD_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_p_shift);
static const u8 gost_R3410_2012_256_paramSetD_p_normalized[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3,
0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x9b,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_p_normalized);
static const u8 gost_R3410_2012_256_paramSetD_p_reciprocal[] = {
0xa5, 0x1f, 0x17, 0x61, 0x61, 0xf1, 0xd7, 0x34,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 gost_R3410_2012_256_paramSetD_r[] = {
0x64, 0x60, 0x9f, 0xa0, 0xa5, 0x7a, 0x7e, 0xf8,
0x54, 0xe1, 0x37, 0xa1, 0x94, 0xbe, 0x37, 0x55,
0x30, 0x7b, 0x91, 0x79, 0x87, 0x6f, 0xae, 0x2c,
0x86, 0x67, 0x08, 0x46, 0xfd, 0xd2, 0x8a, 0x65,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_r);
static const u8 gost_R3410_2012_256_paramSetD_r_square[] = {
0x80, 0x7a, 0x39, 0x4e, 0xde, 0x09, 0x76, 0x52,
0x18, 0x63, 0x04, 0x21, 0x28, 0x49, 0xc0, 0x7b,
0x10, 0x17, 0xbb, 0x39, 0xc2, 0xd3, 0x46, 0xc5,
0x40, 0x99, 0x73, 0xb4, 0xc4, 0x27, 0xfc, 0xea,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_r_square);
static const u8 gost_R3410_2012_256_paramSetD_mpinv[] = {
0x72, 0x7c, 0x17, 0x6d,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_mpinv);
static const u8 gost_R3410_2012_256_paramSetD_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_p_shift);
static const u8 gost_R3410_2012_256_paramSetD_p_normalized[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3,
0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x9b,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_p_normalized);
static const u8 gost_R3410_2012_256_paramSetD_p_reciprocal[] = {
0xa5, 0x1f, 0x17, 0x61,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 gost_R3410_2012_256_paramSetD_r[] = {
0x64, 0x60, 0x9f, 0xa0, 0xa5, 0x7a, 0x7e, 0xf8,
0x54, 0xe1, 0x37, 0xa1, 0x94, 0xbe, 0x37, 0x55,
0x30, 0x7b, 0x91, 0x79, 0x87, 0x6f, 0xae, 0x2c,
0x86, 0x67, 0x08, 0x46, 0xfd, 0xd2, 0x8a, 0x65,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_r);
static const u8 gost_R3410_2012_256_paramSetD_r_square[] = {
0x80, 0x7a, 0x39, 0x4e, 0xde, 0x09, 0x76, 0x52,
0x18, 0x63, 0x04, 0x21, 0x28, 0x49, 0xc0, 0x7b,
0x10, 0x17, 0xbb, 0x39, 0xc2, 0xd3, 0x46, 0xc5,
0x40, 0x99, 0x73, 0xb4, 0xc4, 0x27, 0xfc, 0xea,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_r_square);
static const u8 gost_R3410_2012_256_paramSetD_mpinv[] = {
0x17, 0x6d,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_mpinv);
static const u8 gost_R3410_2012_256_paramSetD_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_p_shift);
static const u8 gost_R3410_2012_256_paramSetD_p_normalized[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3,
0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x9b,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_p_normalized);
static const u8 gost_R3410_2012_256_paramSetD_p_reciprocal[] = {
0xa5, 0x1f,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 gost_R3410_2012_256_paramSetD_a[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3,
0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x98,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_a);
static const u8 gost_R3410_2012_256_paramSetD_b[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x5a,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_b);
#define CURVE_GOST_R3410_2012_256_PARAMSETD_CURVE_ORDER_BITLEN 256
static const u8 gost_R3410_2012_256_paramSetD_curve_order[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0x58, 0x2c, 0xa3, 0x51, 0x1e, 0xdd, 0xfb, 0x74,
0xf0, 0x2f, 0x3a, 0x65, 0x98, 0x98, 0x0b, 0xb9,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_curve_order);
static const u8 gost_R3410_2012_256_paramSetD_gx[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_gx);
static const u8 gost_R3410_2012_256_paramSetD_gy[] = {
0x41, 0xec, 0xe5, 0x57, 0x43, 0x71, 0x1a, 0x8c,
0x3c, 0xbf, 0x37, 0x83, 0xcd, 0x08, 0xc0, 0xee,
0x4d, 0x4d, 0xc4, 0x40, 0xd4, 0x64, 0x1a, 0x8f,
0x36, 0x6e, 0x55, 0x0d, 0xfd, 0xb3, 0xbb, 0x67,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_gy);
static const u8 gost_R3410_2012_256_paramSetD_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_gz);
static const u8 gost_R3410_2012_256_paramSetD_gen_order[] = {
0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07,
0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa,
0x58, 0x2c, 0xa3, 0x51, 0x1e, 0xdd, 0xfb, 0x74,
0xf0, 0x2f, 0x3a, 0x65, 0x98, 0x98, 0x0b, 0xb9,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_gen_order);
#define CURVE_GOST_R3410_2012_256_PARAMSETD_Q_BITLEN 256
static const u8 gost_R3410_2012_256_paramSetD_gen_order_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_gen_order_bitlen);
static const u8 gost_R3410_2012_256_paramSetD_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_cofactor);
static const u8 gost_R3410_2012_256_paramSetD_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetD_alpha_montgomery, 0);
static const u8 gost_R3410_2012_256_paramSetD_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetD_gamma_montgomery, 0);
static const u8 gost_R3410_2012_256_paramSetD_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetD_alpha_edwards, 0);
static const u8 gost_R3410_2012_256_paramSetD_name[] = "GOST_R3410_2012_256_PARAMSETD";
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_name);
static const u8 gost_R3410_2012_256_paramSetD_oid[] = "1.2.643.7.1.2.1.1.4";
TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetD_oid);
static const ec_str_params gost_R3410_2012_256_paramSetD_str_params = {
.p = &gost_R3410_2012_256_paramSetD_p_str_param,
.p_bitlen = &gost_R3410_2012_256_paramSetD_p_bitlen_str_param,
.r = &gost_R3410_2012_256_paramSetD_r_str_param,
.r_square = &gost_R3410_2012_256_paramSetD_r_square_str_param,
.mpinv = &gost_R3410_2012_256_paramSetD_mpinv_str_param,
.p_shift = &gost_R3410_2012_256_paramSetD_p_shift_str_param,
.p_normalized = &gost_R3410_2012_256_paramSetD_p_normalized_str_param,
.p_reciprocal = &gost_R3410_2012_256_paramSetD_p_reciprocal_str_param,
.a = &gost_R3410_2012_256_paramSetD_a_str_param,
.b = &gost_R3410_2012_256_paramSetD_b_str_param,
.curve_order = &gost_R3410_2012_256_paramSetD_curve_order_str_param,
.gx = &gost_R3410_2012_256_paramSetD_gx_str_param,
.gy = &gost_R3410_2012_256_paramSetD_gy_str_param,
.gz = &gost_R3410_2012_256_paramSetD_gz_str_param,
.gen_order = &gost_R3410_2012_256_paramSetD_gen_order_str_param,
.gen_order_bitlen = &gost_R3410_2012_256_paramSetD_gen_order_bitlen_str_param,
.cofactor = &gost_R3410_2012_256_paramSetD_cofactor_str_param,
.alpha_montgomery = &gost_R3410_2012_256_paramSetD_alpha_montgomery_str_param,
.gamma_montgomery = &gost_R3410_2012_256_paramSetD_gamma_montgomery_str_param,
.alpha_edwards = &gost_R3410_2012_256_paramSetD_alpha_edwards_str_param,
.oid = &gost_R3410_2012_256_paramSetD_oid_str_param,
.name = &gost_R3410_2012_256_paramSetD_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETD_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETD_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETD_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETD_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETD_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETD_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 20)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 20
#endif
#if (MAX_CURVE_NAME_LEN < 50)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 50
#endif
#endif /* __EC_PARAMS_GOST_R3410_2012_256_PARAMSETD_H__ */
#endif /* WITH_CURVE_GOST_R3410_2012_256_PARAMSETD */

View file

@ -0,0 +1,359 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_GOST_R3410_2012_512_PARAMSETA
#ifndef __EC_PARAMS_GOST_R3410_2012_512_PARAMSETA_H__
#define __EC_PARAMS_GOST_R3410_2012_512_PARAMSETA_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 gost_R3410_2012_512_paramSetA_p[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc7,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_p);
#define CURVE_GOST_R3410_2012_512_PARAMSETA_P_BITLEN 512
static const u8 gost_R3410_2012_512_paramSetA_p_bitlen[] = {
0x02, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 gost_R3410_2012_512_paramSetA_r[] = {
0x02, 0x39,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_r);
static const u8 gost_R3410_2012_512_paramSetA_r_square[] = {
0x04, 0xf0, 0xb1,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_r_square);
static const u8 gost_R3410_2012_512_paramSetA_mpinv[] = {
0x58, 0xa1, 0xf7, 0xe6, 0xce, 0x0f, 0x4c, 0x09,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_mpinv);
static const u8 gost_R3410_2012_512_paramSetA_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_p_shift);
static const u8 gost_R3410_2012_512_paramSetA_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc7,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_p_normalized);
static const u8 gost_R3410_2012_512_paramSetA_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 gost_R3410_2012_512_paramSetA_r[] = {
0x02, 0x39,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_r);
static const u8 gost_R3410_2012_512_paramSetA_r_square[] = {
0x04, 0xf0, 0xb1,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_r_square);
static const u8 gost_R3410_2012_512_paramSetA_mpinv[] = {
0xce, 0x0f, 0x4c, 0x09,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_mpinv);
static const u8 gost_R3410_2012_512_paramSetA_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_p_shift);
static const u8 gost_R3410_2012_512_paramSetA_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc7,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_p_normalized);
static const u8 gost_R3410_2012_512_paramSetA_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 gost_R3410_2012_512_paramSetA_r[] = {
0x02, 0x39,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_r);
static const u8 gost_R3410_2012_512_paramSetA_r_square[] = {
0x04, 0xf0, 0xb1,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_r_square);
static const u8 gost_R3410_2012_512_paramSetA_mpinv[] = {
0x4c, 0x09,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_mpinv);
static const u8 gost_R3410_2012_512_paramSetA_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_p_shift);
static const u8 gost_R3410_2012_512_paramSetA_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc7,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_p_normalized);
static const u8 gost_R3410_2012_512_paramSetA_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 gost_R3410_2012_512_paramSetA_a[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc4,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_a);
static const u8 gost_R3410_2012_512_paramSetA_b[] = {
0xe8, 0xc2, 0x50, 0x5d, 0xed, 0xfc, 0x86, 0xdd,
0xc1, 0xbd, 0x0b, 0x2b, 0x66, 0x67, 0xf1, 0xda,
0x34, 0xb8, 0x25, 0x74, 0x76, 0x1c, 0xb0, 0xe8,
0x79, 0xbd, 0x08, 0x1c, 0xfd, 0x0b, 0x62, 0x65,
0xee, 0x3c, 0xb0, 0x90, 0xf3, 0x0d, 0x27, 0x61,
0x4c, 0xb4, 0x57, 0x40, 0x10, 0xda, 0x90, 0xdd,
0x86, 0x2e, 0xf9, 0xd4, 0xeb, 0xee, 0x47, 0x61,
0x50, 0x31, 0x90, 0x78, 0x5a, 0x71, 0xc7, 0x60,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_b);
#define CURVE_GOST_R3410_2012_512_PARAMSETA_CURVE_ORDER_BITLEN 512
static const u8 gost_R3410_2012_512_paramSetA_curve_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x27, 0xe6, 0x95, 0x32, 0xf4, 0x8d, 0x89, 0x11,
0x6f, 0xf2, 0x2b, 0x8d, 0x4e, 0x05, 0x60, 0x60,
0x9b, 0x4b, 0x38, 0xab, 0xfa, 0xd2, 0xb8, 0x5d,
0xca, 0xcd, 0xb1, 0x41, 0x1f, 0x10, 0xb2, 0x75,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_curve_order);
static const u8 gost_R3410_2012_512_paramSetA_gx[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_gx);
static const u8 gost_R3410_2012_512_paramSetA_gy[] = {
0x75, 0x03, 0xcf, 0xe8, 0x7a, 0x83, 0x6a, 0xe3,
0xa6, 0x1b, 0x88, 0x16, 0xe2, 0x54, 0x50, 0xe6,
0xce, 0x5e, 0x1c, 0x93, 0xac, 0xf1, 0xab, 0xc1,
0x77, 0x80, 0x64, 0xfd, 0xcb, 0xef, 0xa9, 0x21,
0xdf, 0x16, 0x26, 0xbe, 0x4f, 0xd0, 0x36, 0xe9,
0x3d, 0x75, 0xe6, 0xa5, 0x0e, 0x3a, 0x41, 0xe9,
0x80, 0x28, 0xfe, 0x5f, 0xc2, 0x35, 0xf5, 0xb8,
0x89, 0xa5, 0x89, 0xcb, 0x52, 0x15, 0xf2, 0xa4,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_gy);
static const u8 gost_R3410_2012_512_paramSetA_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_gz);
static const u8 gost_R3410_2012_512_paramSetA_gen_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x27, 0xe6, 0x95, 0x32, 0xf4, 0x8d, 0x89, 0x11,
0x6f, 0xf2, 0x2b, 0x8d, 0x4e, 0x05, 0x60, 0x60,
0x9b, 0x4b, 0x38, 0xab, 0xfa, 0xd2, 0xb8, 0x5d,
0xca, 0xcd, 0xb1, 0x41, 0x1f, 0x10, 0xb2, 0x75,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_gen_order);
#define CURVE_GOST_R3410_2012_512_PARAMSETA_Q_BITLEN 512
static const u8 gost_R3410_2012_512_paramSetA_gen_order_bitlen[] = {
0x02, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_gen_order_bitlen);
static const u8 gost_R3410_2012_512_paramSetA_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_cofactor);
static const u8 gost_R3410_2012_512_paramSetA_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_512_paramSetA_alpha_montgomery, 0);
static const u8 gost_R3410_2012_512_paramSetA_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_512_paramSetA_gamma_montgomery, 0);
static const u8 gost_R3410_2012_512_paramSetA_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_512_paramSetA_alpha_edwards, 0);
static const u8 gost_R3410_2012_512_paramSetA_name[] = "GOST_R3410_2012_512_PARAMSETA";
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_name);
static const u8 gost_R3410_2012_512_paramSetA_oid[] = "1.2.643.7.1.2.1.2.1";
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetA_oid);
static const ec_str_params gost_R3410_2012_512_paramSetA_str_params = {
.p = &gost_R3410_2012_512_paramSetA_p_str_param,
.p_bitlen = &gost_R3410_2012_512_paramSetA_p_bitlen_str_param,
.r = &gost_R3410_2012_512_paramSetA_r_str_param,
.r_square = &gost_R3410_2012_512_paramSetA_r_square_str_param,
.mpinv = &gost_R3410_2012_512_paramSetA_mpinv_str_param,
.p_shift = &gost_R3410_2012_512_paramSetA_p_shift_str_param,
.p_normalized = &gost_R3410_2012_512_paramSetA_p_normalized_str_param,
.p_reciprocal = &gost_R3410_2012_512_paramSetA_p_reciprocal_str_param,
.a = &gost_R3410_2012_512_paramSetA_a_str_param,
.b = &gost_R3410_2012_512_paramSetA_b_str_param,
.curve_order = &gost_R3410_2012_512_paramSetA_curve_order_str_param,
.gx = &gost_R3410_2012_512_paramSetA_gx_str_param,
.gy = &gost_R3410_2012_512_paramSetA_gy_str_param,
.gz = &gost_R3410_2012_512_paramSetA_gz_str_param,
.gen_order = &gost_R3410_2012_512_paramSetA_gen_order_str_param,
.gen_order_bitlen = &gost_R3410_2012_512_paramSetA_gen_order_bitlen_str_param,
.cofactor = &gost_R3410_2012_512_paramSetA_cofactor_str_param,
.alpha_montgomery = &gost_R3410_2012_512_paramSetA_alpha_montgomery_str_param,
.gamma_montgomery = &gost_R3410_2012_512_paramSetA_gamma_montgomery_str_param,
.alpha_edwards = &gost_R3410_2012_512_paramSetA_alpha_edwards_str_param,
.oid = &gost_R3410_2012_512_paramSetA_oid_str_param,
.name = &gost_R3410_2012_512_paramSetA_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2012_512_PARAMSETA_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2012_512_PARAMSETA_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2012_512_PARAMSETA_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2012_512_PARAMSETA_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2012_512_PARAMSETA_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2012_512_PARAMSETA_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 20)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 20
#endif
#if (MAX_CURVE_NAME_LEN < 50)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 50
#endif
#endif /* __EC_PARAMS_GOST_R3410_2012_512_PARAMSETA_H__ */
#endif /* WITH_CURVE_GOST_R3410_2012_512_PARAMSETA */

View file

@ -0,0 +1,380 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_GOST_R3410_2012_512_PARAMSETB
#ifndef __EC_PARAMS_GOST_R3410_2012_512_PARAMSETB_H__
#define __EC_PARAMS_GOST_R3410_2012_512_PARAMSETB_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 gost_R3410_2012_512_paramSetB_p[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_p);
#define CURVE_GOST_R3410_2012_512_PARAMSETB_P_BITLEN 512
static const u8 gost_R3410_2012_512_paramSetB_p_bitlen[] = {
0x02, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 gost_R3410_2012_512_paramSetB_r[] = {
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x91,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_r);
static const u8 gost_R3410_2012_512_paramSetB_r_square[] = {
0xc0, 0x84,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_r_square);
static const u8 gost_R3410_2012_512_paramSetB_mpinv[] = {
0x4e, 0x6a, 0x17, 0x10, 0x24, 0xe6, 0xa1, 0x71,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_mpinv);
static const u8 gost_R3410_2012_512_paramSetB_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_p_shift);
static const u8 gost_R3410_2012_512_paramSetB_p_normalized[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_p_normalized);
static const u8 gost_R3410_2012_512_paramSetB_p_reciprocal[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 gost_R3410_2012_512_paramSetB_r[] = {
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x91,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_r);
static const u8 gost_R3410_2012_512_paramSetB_r_square[] = {
0xc0, 0x84,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_r_square);
static const u8 gost_R3410_2012_512_paramSetB_mpinv[] = {
0x24, 0xe6, 0xa1, 0x71,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_mpinv);
static const u8 gost_R3410_2012_512_paramSetB_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_p_shift);
static const u8 gost_R3410_2012_512_paramSetB_p_normalized[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_p_normalized);
static const u8 gost_R3410_2012_512_paramSetB_p_reciprocal[] = {
0xff, 0xff, 0xff, 0xff,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 gost_R3410_2012_512_paramSetB_r[] = {
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x91,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_r);
static const u8 gost_R3410_2012_512_paramSetB_r_square[] = {
0xc0, 0x84,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_r_square);
static const u8 gost_R3410_2012_512_paramSetB_mpinv[] = {
0xa1, 0x71,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_mpinv);
static const u8 gost_R3410_2012_512_paramSetB_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_p_shift);
static const u8 gost_R3410_2012_512_paramSetB_p_normalized[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_p_normalized);
static const u8 gost_R3410_2012_512_paramSetB_p_reciprocal[] = {
0xff, 0xff,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 gost_R3410_2012_512_paramSetB_a[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_a);
static const u8 gost_R3410_2012_512_paramSetB_b[] = {
0x68, 0x7d, 0x1b, 0x45, 0x9d, 0xc8, 0x41, 0x45,
0x7e, 0x3e, 0x06, 0xcf, 0x6f, 0x5e, 0x25, 0x17,
0xb9, 0x7c, 0x7d, 0x61, 0x4a, 0xf1, 0x38, 0xbc,
0xbf, 0x85, 0xdc, 0x80, 0x6c, 0x4b, 0x28, 0x9f,
0x3e, 0x96, 0x5d, 0x2d, 0xb1, 0x41, 0x6d, 0x21,
0x7f, 0x8b, 0x27, 0x6f, 0xad, 0x1a, 0xb6, 0x9c,
0x50, 0xf7, 0x8b, 0xee, 0x1f, 0xa3, 0x10, 0x6e,
0xfb, 0x8c, 0xcb, 0xc7, 0xc5, 0x14, 0x01, 0x16,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_b);
#define CURVE_GOST_R3410_2012_512_PARAMSETB_CURVE_ORDER_BITLEN 512
static const u8 gost_R3410_2012_512_paramSetB_curve_order[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x49, 0xa1, 0xec, 0x14, 0x25, 0x65, 0xa5, 0x45,
0xac, 0xfd, 0xb7, 0x7b, 0xd9, 0xd4, 0x0c, 0xfa,
0x8b, 0x99, 0x67, 0x12, 0x10, 0x1b, 0xea, 0x0e,
0xc6, 0x34, 0x6c, 0x54, 0x37, 0x4f, 0x25, 0xbd,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_curve_order);
static const u8 gost_R3410_2012_512_paramSetB_gx[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_gx);
static const u8 gost_R3410_2012_512_paramSetB_gy[] = {
0x1a, 0x8f, 0x7e, 0xda, 0x38, 0x9b, 0x09, 0x4c,
0x2c, 0x07, 0x1e, 0x36, 0x47, 0xa8, 0x94, 0x0f,
0x3c, 0x12, 0x3b, 0x69, 0x75, 0x78, 0xc2, 0x13,
0xbe, 0x6d, 0xd9, 0xe6, 0xc8, 0xec, 0x73, 0x35,
0xdc, 0xb2, 0x28, 0xfd, 0x1e, 0xdf, 0x4a, 0x39,
0x15, 0x2c, 0xbc, 0xaa, 0xf8, 0xc0, 0x39, 0x88,
0x28, 0x04, 0x10, 0x55, 0xf9, 0x4c, 0xee, 0xec,
0x7e, 0x21, 0x34, 0x07, 0x80, 0xfe, 0x41, 0xbd,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_gy);
static const u8 gost_R3410_2012_512_paramSetB_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_gz);
static const u8 gost_R3410_2012_512_paramSetB_gen_order[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x49, 0xa1, 0xec, 0x14, 0x25, 0x65, 0xa5, 0x45,
0xac, 0xfd, 0xb7, 0x7b, 0xd9, 0xd4, 0x0c, 0xfa,
0x8b, 0x99, 0x67, 0x12, 0x10, 0x1b, 0xea, 0x0e,
0xc6, 0x34, 0x6c, 0x54, 0x37, 0x4f, 0x25, 0xbd,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_gen_order);
#define CURVE_GOST_R3410_2012_512_PARAMSETB_Q_BITLEN 512
static const u8 gost_R3410_2012_512_paramSetB_gen_order_bitlen[] = {
0x02, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_gen_order_bitlen);
static const u8 gost_R3410_2012_512_paramSetB_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_cofactor);
static const u8 gost_R3410_2012_512_paramSetB_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_512_paramSetB_alpha_montgomery, 0);
static const u8 gost_R3410_2012_512_paramSetB_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_512_paramSetB_gamma_montgomery, 0);
static const u8 gost_R3410_2012_512_paramSetB_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_512_paramSetB_alpha_edwards, 0);
static const u8 gost_R3410_2012_512_paramSetB_name[] = "GOST_R3410_2012_512_PARAMSETB";
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_name);
static const u8 gost_R3410_2012_512_paramSetB_oid[] = "1.2.643.7.1.2.1.2.2";
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetB_oid);
static const ec_str_params gost_R3410_2012_512_paramSetB_str_params = {
.p = &gost_R3410_2012_512_paramSetB_p_str_param,
.p_bitlen = &gost_R3410_2012_512_paramSetB_p_bitlen_str_param,
.r = &gost_R3410_2012_512_paramSetB_r_str_param,
.r_square = &gost_R3410_2012_512_paramSetB_r_square_str_param,
.mpinv = &gost_R3410_2012_512_paramSetB_mpinv_str_param,
.p_shift = &gost_R3410_2012_512_paramSetB_p_shift_str_param,
.p_normalized = &gost_R3410_2012_512_paramSetB_p_normalized_str_param,
.p_reciprocal = &gost_R3410_2012_512_paramSetB_p_reciprocal_str_param,
.a = &gost_R3410_2012_512_paramSetB_a_str_param,
.b = &gost_R3410_2012_512_paramSetB_b_str_param,
.curve_order = &gost_R3410_2012_512_paramSetB_curve_order_str_param,
.gx = &gost_R3410_2012_512_paramSetB_gx_str_param,
.gy = &gost_R3410_2012_512_paramSetB_gy_str_param,
.gz = &gost_R3410_2012_512_paramSetB_gz_str_param,
.gen_order = &gost_R3410_2012_512_paramSetB_gen_order_str_param,
.gen_order_bitlen = &gost_R3410_2012_512_paramSetB_gen_order_bitlen_str_param,
.cofactor = &gost_R3410_2012_512_paramSetB_cofactor_str_param,
.alpha_montgomery = &gost_R3410_2012_512_paramSetB_alpha_montgomery_str_param,
.gamma_montgomery = &gost_R3410_2012_512_paramSetB_gamma_montgomery_str_param,
.alpha_edwards = &gost_R3410_2012_512_paramSetB_alpha_edwards_str_param,
.oid = &gost_R3410_2012_512_paramSetB_oid_str_param,
.name = &gost_R3410_2012_512_paramSetB_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2012_512_PARAMSETB_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2012_512_PARAMSETB_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2012_512_PARAMSETB_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2012_512_PARAMSETB_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2012_512_PARAMSETB_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2012_512_PARAMSETB_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 20)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 20
#endif
#if (MAX_CURVE_NAME_LEN < 50)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 50
#endif
#endif /* __EC_PARAMS_GOST_R3410_2012_512_PARAMSETB_H__ */
#endif /* WITH_CURVE_GOST_R3410_2012_512_PARAMSETB */

View file

@ -0,0 +1,359 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_GOST_R3410_2012_512_PARAMSETC
#ifndef __EC_PARAMS_GOST_R3410_2012_512_PARAMSETC_H__
#define __EC_PARAMS_GOST_R3410_2012_512_PARAMSETC_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 gost_R3410_2012_512_paramSetC_p[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc7,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p);
#define CURVE_GOST_R3410_2012_512_PARAMSETC_P_BITLEN 512
static const u8 gost_R3410_2012_512_paramSetC_p_bitlen[] = {
0x02, 0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 gost_R3410_2012_512_paramSetC_r[] = {
0x02, 0x39,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_r);
static const u8 gost_R3410_2012_512_paramSetC_r_square[] = {
0x04, 0xf0, 0xb1,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_r_square);
static const u8 gost_R3410_2012_512_paramSetC_mpinv[] = {
0x58, 0xa1, 0xf7, 0xe6, 0xce, 0x0f, 0x4c, 0x09,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_mpinv);
static const u8 gost_R3410_2012_512_paramSetC_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_shift);
static const u8 gost_R3410_2012_512_paramSetC_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc7,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_normalized);
static const u8 gost_R3410_2012_512_paramSetC_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 gost_R3410_2012_512_paramSetC_r[] = {
0x02, 0x39,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_r);
static const u8 gost_R3410_2012_512_paramSetC_r_square[] = {
0x04, 0xf0, 0xb1,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_r_square);
static const u8 gost_R3410_2012_512_paramSetC_mpinv[] = {
0xce, 0x0f, 0x4c, 0x09,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_mpinv);
static const u8 gost_R3410_2012_512_paramSetC_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_shift);
static const u8 gost_R3410_2012_512_paramSetC_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc7,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_normalized);
static const u8 gost_R3410_2012_512_paramSetC_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 gost_R3410_2012_512_paramSetC_r[] = {
0x02, 0x39,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_r);
static const u8 gost_R3410_2012_512_paramSetC_r_square[] = {
0x04, 0xf0, 0xb1,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_r_square);
static const u8 gost_R3410_2012_512_paramSetC_mpinv[] = {
0x4c, 0x09,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_mpinv);
static const u8 gost_R3410_2012_512_paramSetC_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_shift);
static const u8 gost_R3410_2012_512_paramSetC_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc7,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_normalized);
static const u8 gost_R3410_2012_512_paramSetC_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 gost_R3410_2012_512_paramSetC_a[] = {
0xdc, 0x92, 0x03, 0xe5, 0x14, 0xa7, 0x21, 0x87,
0x54, 0x85, 0xa5, 0x29, 0xd2, 0xc7, 0x22, 0xfb,
0x18, 0x7b, 0xc8, 0x98, 0x0e, 0xb8, 0x66, 0x64,
0x4d, 0xe4, 0x1c, 0x68, 0xe1, 0x43, 0x06, 0x45,
0x46, 0xe8, 0x61, 0xc0, 0xe2, 0xc9, 0xed, 0xd9,
0x2a, 0xde, 0x71, 0xf4, 0x6f, 0xcf, 0x50, 0xff,
0x2a, 0xd9, 0x7f, 0x95, 0x1f, 0xda, 0x9f, 0x2a,
0x2e, 0xb6, 0x54, 0x6f, 0x39, 0x68, 0x9b, 0xd3,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_a);
static const u8 gost_R3410_2012_512_paramSetC_b[] = {
0xb4, 0xc4, 0xee, 0x28, 0xce, 0xbc, 0x6c, 0x2c,
0x8a, 0xc1, 0x29, 0x52, 0xcf, 0x37, 0xf1, 0x6a,
0xc7, 0xef, 0xb6, 0xa9, 0xf6, 0x9f, 0x4b, 0x57,
0xff, 0xda, 0x2e, 0x4f, 0x0d, 0xe5, 0xad, 0xe0,
0x38, 0xcb, 0xc2, 0xff, 0xf7, 0x19, 0xd2, 0xc1,
0x8d, 0xe0, 0x28, 0x4b, 0x8b, 0xfe, 0xf3, 0xb5,
0x2b, 0x8c, 0xc7, 0xa5, 0xf5, 0xbf, 0x0a, 0x3c,
0x8d, 0x23, 0x19, 0xa5, 0x31, 0x25, 0x57, 0xe1,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_b);
#define CURVE_GOST_R3410_2012_512_PARAMSETC_CURVE_ORDER_BITLEN 512
static const u8 gost_R3410_2012_512_paramSetC_curve_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x26, 0x33, 0x6e, 0x91, 0x94, 0x1a, 0xac, 0x01,
0x30, 0xce, 0xa7, 0xfd, 0x45, 0x1d, 0x40, 0xb3,
0x23, 0xb6, 0xa7, 0x9e, 0x9d, 0xa6, 0x84, 0x9a,
0x51, 0x88, 0xf3, 0xbd, 0x1f, 0xc0, 0x8f, 0xb4,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_curve_order);
static const u8 gost_R3410_2012_512_paramSetC_gx[] = {
0xe2, 0xe3, 0x1e, 0xdf, 0xc2, 0x3d, 0xe7, 0xbd,
0xeb, 0xe2, 0x41, 0xce, 0x59, 0x3e, 0xf5, 0xde,
0x22, 0x95, 0xb7, 0xa9, 0xcb, 0xae, 0xf0, 0x21,
0xd3, 0x85, 0xf7, 0x07, 0x4c, 0xea, 0x04, 0x3a,
0xa2, 0x72, 0x72, 0xa7, 0xae, 0x60, 0x2b, 0xf2,
0xa7, 0xb9, 0x03, 0x3d, 0xb9, 0xed, 0x36, 0x10,
0xc6, 0xfb, 0x85, 0x48, 0x7e, 0xae, 0x97, 0xaa,
0xc5, 0xbc, 0x79, 0x28, 0xc1, 0x95, 0x01, 0x48,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_gx);
static const u8 gost_R3410_2012_512_paramSetC_gy[] = {
0xf5, 0xce, 0x40, 0xd9, 0x5b, 0x5e, 0xb8, 0x99,
0xab, 0xbc, 0xcf, 0xf5, 0x91, 0x1c, 0xb8, 0x57,
0x79, 0x39, 0x80, 0x4d, 0x65, 0x27, 0x37, 0x8b,
0x8c, 0x10, 0x8c, 0x3d, 0x20, 0x90, 0xff, 0x9b,
0xe1, 0x8e, 0x2d, 0x33, 0xe3, 0x02, 0x1e, 0xd2,
0xef, 0x32, 0xd8, 0x58, 0x22, 0x42, 0x3b, 0x63,
0x04, 0xf7, 0x26, 0xaa, 0x85, 0x4b, 0xae, 0x07,
0xd0, 0x39, 0x6e, 0x9a, 0x9a, 0xdd, 0xc4, 0x0f,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_gy);
static const u8 gost_R3410_2012_512_paramSetC_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_gz);
static const u8 gost_R3410_2012_512_paramSetC_gen_order[] = {
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xc9, 0x8c, 0xdb, 0xa4, 0x65, 0x06, 0xab, 0x00,
0x4c, 0x33, 0xa9, 0xff, 0x51, 0x47, 0x50, 0x2c,
0xc8, 0xed, 0xa9, 0xe7, 0xa7, 0x69, 0xa1, 0x26,
0x94, 0x62, 0x3c, 0xef, 0x47, 0xf0, 0x23, 0xed,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_gen_order);
#define CURVE_GOST_R3410_2012_512_PARAMSETC_Q_BITLEN 510
static const u8 gost_R3410_2012_512_paramSetC_gen_order_bitlen[] = {
0x01, 0xfe,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_gen_order_bitlen);
static const u8 gost_R3410_2012_512_paramSetC_cofactor[] = {
0x04,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_cofactor);
static const u8 gost_R3410_2012_512_paramSetC_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_512_paramSetC_alpha_montgomery, 0);
static const u8 gost_R3410_2012_512_paramSetC_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_512_paramSetC_gamma_montgomery, 0);
static const u8 gost_R3410_2012_512_paramSetC_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_512_paramSetC_alpha_edwards, 0);
static const u8 gost_R3410_2012_512_paramSetC_name[] = "GOST_R3410_2012_512_PARAMSETC";
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_name);
static const u8 gost_R3410_2012_512_paramSetC_oid[] = "1.2.643.7.1.2.1.2.3";
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_oid);
static const ec_str_params gost_R3410_2012_512_paramSetC_str_params = {
.p = &gost_R3410_2012_512_paramSetC_p_str_param,
.p_bitlen = &gost_R3410_2012_512_paramSetC_p_bitlen_str_param,
.r = &gost_R3410_2012_512_paramSetC_r_str_param,
.r_square = &gost_R3410_2012_512_paramSetC_r_square_str_param,
.mpinv = &gost_R3410_2012_512_paramSetC_mpinv_str_param,
.p_shift = &gost_R3410_2012_512_paramSetC_p_shift_str_param,
.p_normalized = &gost_R3410_2012_512_paramSetC_p_normalized_str_param,
.p_reciprocal = &gost_R3410_2012_512_paramSetC_p_reciprocal_str_param,
.a = &gost_R3410_2012_512_paramSetC_a_str_param,
.b = &gost_R3410_2012_512_paramSetC_b_str_param,
.curve_order = &gost_R3410_2012_512_paramSetC_curve_order_str_param,
.gx = &gost_R3410_2012_512_paramSetC_gx_str_param,
.gy = &gost_R3410_2012_512_paramSetC_gy_str_param,
.gz = &gost_R3410_2012_512_paramSetC_gz_str_param,
.gen_order = &gost_R3410_2012_512_paramSetC_gen_order_str_param,
.gen_order_bitlen = &gost_R3410_2012_512_paramSetC_gen_order_bitlen_str_param,
.cofactor = &gost_R3410_2012_512_paramSetC_cofactor_str_param,
.alpha_montgomery = &gost_R3410_2012_512_paramSetC_alpha_montgomery_str_param,
.gamma_montgomery = &gost_R3410_2012_512_paramSetC_gamma_montgomery_str_param,
.alpha_edwards = &gost_R3410_2012_512_paramSetC_alpha_edwards_str_param,
.oid = &gost_R3410_2012_512_paramSetC_oid_str_param,
.name = &gost_R3410_2012_512_paramSetC_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2012_512_PARAMSETC_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2012_512_PARAMSETC_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2012_512_PARAMSETC_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2012_512_PARAMSETC_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2012_512_PARAMSETC_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2012_512_PARAMSETC_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 20)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 20
#endif
#if (MAX_CURVE_NAME_LEN < 50)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 50
#endif
#endif /* __EC_PARAMS_GOST_R3410_2012_512_PARAMSETC_H__ */
#endif /* WITH_CURVE_GOST_R3410_2012_512_PARAMSETC */

View file

@ -0,0 +1,401 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_GOST_R3410_2012_512_PARAMSETTEST
#ifndef __EC_PARAMS_GOST_R3410_2012_512_PARAMSETTEST_H__
#define __EC_PARAMS_GOST_R3410_2012_512_PARAMSETTEST_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 gost_R3410_2012_512_paramSetTest_p[] = {
0x45, 0x31, 0xac, 0xd1, 0xfe, 0x00, 0x23, 0xc7,
0x55, 0x0d, 0x26, 0x7b, 0x6b, 0x2f, 0xee, 0x80,
0x92, 0x2b, 0x14, 0xb2, 0xff, 0xb9, 0x0f, 0x04,
0xd4, 0xeb, 0x7c, 0x09, 0xb5, 0xd2, 0xd1, 0x5d,
0xf1, 0xd8, 0x52, 0x74, 0x1a, 0xf4, 0x70, 0x4a,
0x04, 0x58, 0x04, 0x7e, 0x80, 0xe4, 0x54, 0x6d,
0x35, 0xb8, 0x33, 0x6f, 0xac, 0x22, 0x4d, 0xd8,
0x16, 0x64, 0xbb, 0xf5, 0x28, 0xbe, 0x63, 0x73,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_p);
#define CURVE_GOST_R3410_2012_512_PARAMSETTEST_P_BITLEN 511
static const u8 gost_R3410_2012_512_paramSetTest_p_bitlen[] = {
0x01, 0xff,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 gost_R3410_2012_512_paramSetTest_r[] = {
0x30, 0x6a, 0xf9, 0x8a, 0x05, 0xff, 0x94, 0xaa,
0x00, 0xd8, 0x8c, 0x8d, 0xbe, 0x70, 0x34, 0x7e,
0x49, 0x7e, 0xc1, 0xe7, 0x00, 0xd4, 0xd2, 0xf1,
0x81, 0x3d, 0x8b, 0xe2, 0xde, 0x87, 0x8b, 0xe6,
0x2a, 0x77, 0x08, 0xa3, 0xaf, 0x22, 0xaf, 0x21,
0xf2, 0xf7, 0xf2, 0x84, 0x7d, 0x53, 0x02, 0xb8,
0x5e, 0xd7, 0x65, 0xb0, 0xfb, 0x99, 0x16, 0x77,
0xbc, 0xd1, 0xcc, 0x20, 0x85, 0xc4, 0xd5, 0xa7,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_r);
static const u8 gost_R3410_2012_512_paramSetTest_r_square[] = {
0x1d, 0x88, 0x7d, 0xcd, 0x9c, 0xd1, 0x9c, 0x10,
0x01, 0xfd, 0xe9, 0xca, 0x99, 0xde, 0x08, 0x52,
0xfc, 0xd9, 0x83, 0xcf, 0xb7, 0xc6, 0x63, 0xd9,
0xca, 0x0b, 0xc8, 0xaf, 0x77, 0xc8, 0x69, 0x0a,
0x08, 0x15, 0xb9, 0xeb, 0x1e, 0x7d, 0xd3, 0x00,
0xe4, 0x17, 0xd5, 0x8d, 0x20, 0x0c, 0x2a, 0xa0,
0x4b, 0x90, 0x7a, 0x71, 0xe6, 0x47, 0xee, 0x63,
0x00, 0x1c, 0x10, 0xbc, 0x2d, 0x00, 0x5b, 0x65,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_r_square);
static const u8 gost_R3410_2012_512_paramSetTest_mpinv[] = {
0xd6, 0x41, 0x2f, 0xf7, 0xc2, 0x9b, 0x86, 0x45,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_mpinv);
static const u8 gost_R3410_2012_512_paramSetTest_p_shift[] = {
0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_p_shift);
static const u8 gost_R3410_2012_512_paramSetTest_p_normalized[] = {
0x8a, 0x63, 0x59, 0xa3, 0xfc, 0x00, 0x47, 0x8e,
0xaa, 0x1a, 0x4c, 0xf6, 0xd6, 0x5f, 0xdd, 0x01,
0x24, 0x56, 0x29, 0x65, 0xff, 0x72, 0x1e, 0x09,
0xa9, 0xd6, 0xf8, 0x13, 0x6b, 0xa5, 0xa2, 0xbb,
0xe3, 0xb0, 0xa4, 0xe8, 0x35, 0xe8, 0xe0, 0x94,
0x08, 0xb0, 0x08, 0xfd, 0x01, 0xc8, 0xa8, 0xda,
0x6b, 0x70, 0x66, 0xdf, 0x58, 0x44, 0x9b, 0xb0,
0x2c, 0xc9, 0x77, 0xea, 0x51, 0x7c, 0xc6, 0xe6,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_p_normalized);
static const u8 gost_R3410_2012_512_paramSetTest_p_reciprocal[] = {
0xd9, 0x91, 0x18, 0x3c, 0xe8, 0xbf, 0x25, 0x61,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 gost_R3410_2012_512_paramSetTest_r[] = {
0x30, 0x6a, 0xf9, 0x8a, 0x05, 0xff, 0x94, 0xaa,
0x00, 0xd8, 0x8c, 0x8d, 0xbe, 0x70, 0x34, 0x7e,
0x49, 0x7e, 0xc1, 0xe7, 0x00, 0xd4, 0xd2, 0xf1,
0x81, 0x3d, 0x8b, 0xe2, 0xde, 0x87, 0x8b, 0xe6,
0x2a, 0x77, 0x08, 0xa3, 0xaf, 0x22, 0xaf, 0x21,
0xf2, 0xf7, 0xf2, 0x84, 0x7d, 0x53, 0x02, 0xb8,
0x5e, 0xd7, 0x65, 0xb0, 0xfb, 0x99, 0x16, 0x77,
0xbc, 0xd1, 0xcc, 0x20, 0x85, 0xc4, 0xd5, 0xa7,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_r);
static const u8 gost_R3410_2012_512_paramSetTest_r_square[] = {
0x1d, 0x88, 0x7d, 0xcd, 0x9c, 0xd1, 0x9c, 0x10,
0x01, 0xfd, 0xe9, 0xca, 0x99, 0xde, 0x08, 0x52,
0xfc, 0xd9, 0x83, 0xcf, 0xb7, 0xc6, 0x63, 0xd9,
0xca, 0x0b, 0xc8, 0xaf, 0x77, 0xc8, 0x69, 0x0a,
0x08, 0x15, 0xb9, 0xeb, 0x1e, 0x7d, 0xd3, 0x00,
0xe4, 0x17, 0xd5, 0x8d, 0x20, 0x0c, 0x2a, 0xa0,
0x4b, 0x90, 0x7a, 0x71, 0xe6, 0x47, 0xee, 0x63,
0x00, 0x1c, 0x10, 0xbc, 0x2d, 0x00, 0x5b, 0x65,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_r_square);
static const u8 gost_R3410_2012_512_paramSetTest_mpinv[] = {
0xc2, 0x9b, 0x86, 0x45,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_mpinv);
static const u8 gost_R3410_2012_512_paramSetTest_p_shift[] = {
0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_p_shift);
static const u8 gost_R3410_2012_512_paramSetTest_p_normalized[] = {
0x8a, 0x63, 0x59, 0xa3, 0xfc, 0x00, 0x47, 0x8e,
0xaa, 0x1a, 0x4c, 0xf6, 0xd6, 0x5f, 0xdd, 0x01,
0x24, 0x56, 0x29, 0x65, 0xff, 0x72, 0x1e, 0x09,
0xa9, 0xd6, 0xf8, 0x13, 0x6b, 0xa5, 0xa2, 0xbb,
0xe3, 0xb0, 0xa4, 0xe8, 0x35, 0xe8, 0xe0, 0x94,
0x08, 0xb0, 0x08, 0xfd, 0x01, 0xc8, 0xa8, 0xda,
0x6b, 0x70, 0x66, 0xdf, 0x58, 0x44, 0x9b, 0xb0,
0x2c, 0xc9, 0x77, 0xea, 0x51, 0x7c, 0xc6, 0xe6,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_p_normalized);
static const u8 gost_R3410_2012_512_paramSetTest_p_reciprocal[] = {
0xd9, 0x91, 0x18, 0x3c,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 gost_R3410_2012_512_paramSetTest_r[] = {
0x30, 0x6a, 0xf9, 0x8a, 0x05, 0xff, 0x94, 0xaa,
0x00, 0xd8, 0x8c, 0x8d, 0xbe, 0x70, 0x34, 0x7e,
0x49, 0x7e, 0xc1, 0xe7, 0x00, 0xd4, 0xd2, 0xf1,
0x81, 0x3d, 0x8b, 0xe2, 0xde, 0x87, 0x8b, 0xe6,
0x2a, 0x77, 0x08, 0xa3, 0xaf, 0x22, 0xaf, 0x21,
0xf2, 0xf7, 0xf2, 0x84, 0x7d, 0x53, 0x02, 0xb8,
0x5e, 0xd7, 0x65, 0xb0, 0xfb, 0x99, 0x16, 0x77,
0xbc, 0xd1, 0xcc, 0x20, 0x85, 0xc4, 0xd5, 0xa7,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_r);
static const u8 gost_R3410_2012_512_paramSetTest_r_square[] = {
0x1d, 0x88, 0x7d, 0xcd, 0x9c, 0xd1, 0x9c, 0x10,
0x01, 0xfd, 0xe9, 0xca, 0x99, 0xde, 0x08, 0x52,
0xfc, 0xd9, 0x83, 0xcf, 0xb7, 0xc6, 0x63, 0xd9,
0xca, 0x0b, 0xc8, 0xaf, 0x77, 0xc8, 0x69, 0x0a,
0x08, 0x15, 0xb9, 0xeb, 0x1e, 0x7d, 0xd3, 0x00,
0xe4, 0x17, 0xd5, 0x8d, 0x20, 0x0c, 0x2a, 0xa0,
0x4b, 0x90, 0x7a, 0x71, 0xe6, 0x47, 0xee, 0x63,
0x00, 0x1c, 0x10, 0xbc, 0x2d, 0x00, 0x5b, 0x65,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_r_square);
static const u8 gost_R3410_2012_512_paramSetTest_mpinv[] = {
0x86, 0x45,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_mpinv);
static const u8 gost_R3410_2012_512_paramSetTest_p_shift[] = {
0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_p_shift);
static const u8 gost_R3410_2012_512_paramSetTest_p_normalized[] = {
0x8a, 0x63, 0x59, 0xa3, 0xfc, 0x00, 0x47, 0x8e,
0xaa, 0x1a, 0x4c, 0xf6, 0xd6, 0x5f, 0xdd, 0x01,
0x24, 0x56, 0x29, 0x65, 0xff, 0x72, 0x1e, 0x09,
0xa9, 0xd6, 0xf8, 0x13, 0x6b, 0xa5, 0xa2, 0xbb,
0xe3, 0xb0, 0xa4, 0xe8, 0x35, 0xe8, 0xe0, 0x94,
0x08, 0xb0, 0x08, 0xfd, 0x01, 0xc8, 0xa8, 0xda,
0x6b, 0x70, 0x66, 0xdf, 0x58, 0x44, 0x9b, 0xb0,
0x2c, 0xc9, 0x77, 0xea, 0x51, 0x7c, 0xc6, 0xe6,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_p_normalized);
static const u8 gost_R3410_2012_512_paramSetTest_p_reciprocal[] = {
0xd9, 0x91,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 gost_R3410_2012_512_paramSetTest_a[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_a);
static const u8 gost_R3410_2012_512_paramSetTest_b[] = {
0x1c, 0xff, 0x08, 0x06, 0xa3, 0x11, 0x16, 0xda,
0x29, 0xd8, 0xcf, 0xa5, 0x4e, 0x57, 0xeb, 0x74,
0x8b, 0xc5, 0xf3, 0x77, 0xe4, 0x94, 0x00, 0xfd,
0xd7, 0x88, 0xb6, 0x49, 0xec, 0xa1, 0xac, 0x43,
0x61, 0x83, 0x40, 0x13, 0xb2, 0xad, 0x73, 0x22,
0x48, 0x0a, 0x89, 0xca, 0x58, 0xe0, 0xcf, 0x74,
0xbc, 0x9e, 0x54, 0x0c, 0x2a, 0xdd, 0x68, 0x97,
0xfa, 0xd0, 0xa3, 0x08, 0x4f, 0x30, 0x2a, 0xdc,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_b);
#define CURVE_GOST_R3410_2012_512_PARAMSETTEST_CURVE_ORDER_BITLEN 511
static const u8 gost_R3410_2012_512_paramSetTest_curve_order[] = {
0x45, 0x31, 0xac, 0xd1, 0xfe, 0x00, 0x23, 0xc7,
0x55, 0x0d, 0x26, 0x7b, 0x6b, 0x2f, 0xee, 0x80,
0x92, 0x2b, 0x14, 0xb2, 0xff, 0xb9, 0x0f, 0x04,
0xd4, 0xeb, 0x7c, 0x09, 0xb5, 0xd2, 0xd1, 0x5d,
0xa8, 0x2f, 0x2d, 0x7e, 0xcb, 0x1d, 0xba, 0xc7,
0x19, 0x90, 0x5c, 0x5e, 0xec, 0xc4, 0x23, 0xf1,
0xd8, 0x6e, 0x25, 0xed, 0xbe, 0x23, 0xc5, 0x95,
0xd6, 0x44, 0xaa, 0xf1, 0x87, 0xe6, 0xe6, 0xdf,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_curve_order);
static const u8 gost_R3410_2012_512_paramSetTest_gx[] = {
0x24, 0xd1, 0x9c, 0xc6, 0x45, 0x72, 0xee, 0x30,
0xf3, 0x96, 0xbf, 0x6e, 0xbb, 0xfd, 0x7a, 0x6c,
0x52, 0x13, 0xb3, 0xb3, 0xd7, 0x05, 0x7c, 0xc8,
0x25, 0xf9, 0x10, 0x93, 0xa6, 0x8c, 0xd7, 0x62,
0xfd, 0x60, 0x61, 0x12, 0x62, 0xcd, 0x83, 0x8d,
0xc6, 0xb6, 0x0a, 0xa7, 0xee, 0xe8, 0x04, 0xe2,
0x8b, 0xc8, 0x49, 0x97, 0x7f, 0xac, 0x33, 0xb4,
0xb5, 0x30, 0xf1, 0xb1, 0x20, 0x24, 0x8a, 0x9a,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_gx);
static const u8 gost_R3410_2012_512_paramSetTest_gy[] = {
0x2b, 0xb3, 0x12, 0xa4, 0x3b, 0xd2, 0xce, 0x6e,
0x0d, 0x02, 0x06, 0x13, 0xc8, 0x57, 0xac, 0xdd,
0xcf, 0xbf, 0x06, 0x1e, 0x91, 0xe5, 0xf2, 0xc3,
0xf3, 0x24, 0x47, 0xc2, 0x59, 0xf3, 0x9b, 0x2c,
0x83, 0xab, 0x15, 0x6d, 0x77, 0xf1, 0x49, 0x6b,
0xf7, 0xeb, 0x33, 0x51, 0xe1, 0xee, 0x4e, 0x43,
0xdc, 0x1a, 0x18, 0xb9, 0x1b, 0x24, 0x64, 0x0b,
0x6d, 0xbb, 0x92, 0xcb, 0x1a, 0xdd, 0x37, 0x1e,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_gy);
static const u8 gost_R3410_2012_512_paramSetTest_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_gz);
static const u8 gost_R3410_2012_512_paramSetTest_gen_order[] = {
0x45, 0x31, 0xac, 0xd1, 0xfe, 0x00, 0x23, 0xc7,
0x55, 0x0d, 0x26, 0x7b, 0x6b, 0x2f, 0xee, 0x80,
0x92, 0x2b, 0x14, 0xb2, 0xff, 0xb9, 0x0f, 0x04,
0xd4, 0xeb, 0x7c, 0x09, 0xb5, 0xd2, 0xd1, 0x5d,
0xa8, 0x2f, 0x2d, 0x7e, 0xcb, 0x1d, 0xba, 0xc7,
0x19, 0x90, 0x5c, 0x5e, 0xec, 0xc4, 0x23, 0xf1,
0xd8, 0x6e, 0x25, 0xed, 0xbe, 0x23, 0xc5, 0x95,
0xd6, 0x44, 0xaa, 0xf1, 0x87, 0xe6, 0xe6, 0xdf,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_gen_order);
#define CURVE_GOST_R3410_2012_512_PARAMSETTEST_Q_BITLEN 511
static const u8 gost_R3410_2012_512_paramSetTest_gen_order_bitlen[] = {
0x01, 0xff,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_gen_order_bitlen);
static const u8 gost_R3410_2012_512_paramSetTest_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_cofactor);
static const u8 gost_R3410_2012_512_paramSetTest_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_512_paramSetTest_alpha_montgomery, 0);
static const u8 gost_R3410_2012_512_paramSetTest_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_512_paramSetTest_gamma_montgomery, 0);
static const u8 gost_R3410_2012_512_paramSetTest_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_512_paramSetTest_alpha_edwards, 0);
static const u8 gost_R3410_2012_512_paramSetTest_name[] = "GOST_R3410_2012_512_PARAMSETTEST";
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_name);
static const u8 gost_R3410_2012_512_paramSetTest_oid[] = "1.2.643.7.1.2.1.2.0";
TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetTest_oid);
static const ec_str_params gost_R3410_2012_512_paramSetTest_str_params = {
.p = &gost_R3410_2012_512_paramSetTest_p_str_param,
.p_bitlen = &gost_R3410_2012_512_paramSetTest_p_bitlen_str_param,
.r = &gost_R3410_2012_512_paramSetTest_r_str_param,
.r_square = &gost_R3410_2012_512_paramSetTest_r_square_str_param,
.mpinv = &gost_R3410_2012_512_paramSetTest_mpinv_str_param,
.p_shift = &gost_R3410_2012_512_paramSetTest_p_shift_str_param,
.p_normalized = &gost_R3410_2012_512_paramSetTest_p_normalized_str_param,
.p_reciprocal = &gost_R3410_2012_512_paramSetTest_p_reciprocal_str_param,
.a = &gost_R3410_2012_512_paramSetTest_a_str_param,
.b = &gost_R3410_2012_512_paramSetTest_b_str_param,
.curve_order = &gost_R3410_2012_512_paramSetTest_curve_order_str_param,
.gx = &gost_R3410_2012_512_paramSetTest_gx_str_param,
.gy = &gost_R3410_2012_512_paramSetTest_gy_str_param,
.gz = &gost_R3410_2012_512_paramSetTest_gz_str_param,
.gen_order = &gost_R3410_2012_512_paramSetTest_gen_order_str_param,
.gen_order_bitlen = &gost_R3410_2012_512_paramSetTest_gen_order_bitlen_str_param,
.cofactor = &gost_R3410_2012_512_paramSetTest_cofactor_str_param,
.alpha_montgomery = &gost_R3410_2012_512_paramSetTest_alpha_montgomery_str_param,
.gamma_montgomery = &gost_R3410_2012_512_paramSetTest_gamma_montgomery_str_param,
.alpha_edwards = &gost_R3410_2012_512_paramSetTest_alpha_edwards_str_param,
.oid = &gost_R3410_2012_512_paramSetTest_oid_str_param,
.name = &gost_R3410_2012_512_paramSetTest_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2012_512_PARAMSETTEST_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2012_512_PARAMSETTEST_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2012_512_PARAMSETTEST_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2012_512_PARAMSETTEST_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2012_512_PARAMSETTEST_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2012_512_PARAMSETTEST_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 20)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 20
#endif
#if (MAX_CURVE_NAME_LEN < 53)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 53
#endif
#endif /* __EC_PARAMS_GOST_R3410_2012_512_PARAMSETTEST_H__ */
#endif /* WITH_CURVE_GOST_R3410_2012_512_PARAMSETTEST */

View file

@ -0,0 +1,307 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_SECP192K1
#ifndef __EC_PARAMS_SECP192K1_H__
#define __EC_PARAMS_SECP192K1_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 secp192k1_p[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xee, 0x37,
};
TO_EC_STR_PARAM(secp192k1_p);
#define CURVE_SECP192K1_P_BITLEN 192
static const u8 secp192k1_p_bitlen[] = {
0xc0,
};
TO_EC_STR_PARAM(secp192k1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 secp192k1_r[] = {
0x01, 0x00, 0x00, 0x11, 0xc9,
};
TO_EC_STR_PARAM(secp192k1_r);
static const u8 secp192k1_r_square[] = {
0x01, 0x00, 0x00, 0x23, 0x92, 0x01, 0x3c, 0x4f,
0xd1,
};
TO_EC_STR_PARAM(secp192k1_r_square);
static const u8 secp192k1_mpinv[] = {
0xf2, 0x7a, 0xe5, 0x5b, 0x74, 0x46, 0xd8, 0x79,
};
TO_EC_STR_PARAM(secp192k1_mpinv);
static const u8 secp192k1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(secp192k1_p_shift);
static const u8 secp192k1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xee, 0x37,
};
TO_EC_STR_PARAM(secp192k1_p_normalized);
static const u8 secp192k1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(secp192k1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 secp192k1_r[] = {
0x01, 0x00, 0x00, 0x11, 0xc9,
};
TO_EC_STR_PARAM(secp192k1_r);
static const u8 secp192k1_r_square[] = {
0x01, 0x00, 0x00, 0x23, 0x92, 0x01, 0x3c, 0x4f,
0xd1,
};
TO_EC_STR_PARAM(secp192k1_r_square);
static const u8 secp192k1_mpinv[] = {
0x74, 0x46, 0xd8, 0x79,
};
TO_EC_STR_PARAM(secp192k1_mpinv);
static const u8 secp192k1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(secp192k1_p_shift);
static const u8 secp192k1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xee, 0x37,
};
TO_EC_STR_PARAM(secp192k1_p_normalized);
static const u8 secp192k1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(secp192k1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 secp192k1_r[] = {
0x01, 0x00, 0x00, 0x11, 0xc9,
};
TO_EC_STR_PARAM(secp192k1_r);
static const u8 secp192k1_r_square[] = {
0x01, 0x00, 0x00, 0x23, 0x92, 0x01, 0x3c, 0x4f,
0xd1,
};
TO_EC_STR_PARAM(secp192k1_r_square);
static const u8 secp192k1_mpinv[] = {
0xd8, 0x79,
};
TO_EC_STR_PARAM(secp192k1_mpinv);
static const u8 secp192k1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(secp192k1_p_shift);
static const u8 secp192k1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xee, 0x37,
};
TO_EC_STR_PARAM(secp192k1_p_normalized);
static const u8 secp192k1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(secp192k1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 secp192k1_a[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
TO_EC_STR_PARAM(secp192k1_a);
static const u8 secp192k1_b[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
};
TO_EC_STR_PARAM(secp192k1_b);
#define CURVE_SECP192K1_CURVE_ORDER_BITLEN 192
static const u8 secp192k1_curve_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0x26, 0xf2, 0xfc, 0x17,
0x0f, 0x69, 0x46, 0x6a, 0x74, 0xde, 0xfd, 0x8d,
};
TO_EC_STR_PARAM(secp192k1_curve_order);
static const u8 secp192k1_gx[] = {
0xdb, 0x4f, 0xf1, 0x0e, 0xc0, 0x57, 0xe9, 0xae,
0x26, 0xb0, 0x7d, 0x02, 0x80, 0xb7, 0xf4, 0x34,
0x1d, 0xa5, 0xd1, 0xb1, 0xea, 0xe0, 0x6c, 0x7d,
};
TO_EC_STR_PARAM(secp192k1_gx);
static const u8 secp192k1_gy[] = {
0x9b, 0x2f, 0x2f, 0x6d, 0x9c, 0x56, 0x28, 0xa7,
0x84, 0x41, 0x63, 0xd0, 0x15, 0xbe, 0x86, 0x34,
0x40, 0x82, 0xaa, 0x88, 0xd9, 0x5e, 0x2f, 0x9d,
};
TO_EC_STR_PARAM(secp192k1_gy);
static const u8 secp192k1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(secp192k1_gz);
static const u8 secp192k1_gen_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0x26, 0xf2, 0xfc, 0x17,
0x0f, 0x69, 0x46, 0x6a, 0x74, 0xde, 0xfd, 0x8d,
};
TO_EC_STR_PARAM(secp192k1_gen_order);
#define CURVE_SECP192K1_Q_BITLEN 192
static const u8 secp192k1_gen_order_bitlen[] = {
0xc0,
};
TO_EC_STR_PARAM(secp192k1_gen_order_bitlen);
static const u8 secp192k1_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(secp192k1_cofactor);
static const u8 secp192k1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp192k1_alpha_montgomery, 0);
static const u8 secp192k1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp192k1_gamma_montgomery, 0);
static const u8 secp192k1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp192k1_alpha_edwards, 0);
static const u8 secp192k1_name[] = "SECP192K1";
TO_EC_STR_PARAM(secp192k1_name);
static const u8 secp192k1_oid[] = "1.3.132.0.31";
TO_EC_STR_PARAM(secp192k1_oid);
static const ec_str_params secp192k1_str_params = {
.p = &secp192k1_p_str_param,
.p_bitlen = &secp192k1_p_bitlen_str_param,
.r = &secp192k1_r_str_param,
.r_square = &secp192k1_r_square_str_param,
.mpinv = &secp192k1_mpinv_str_param,
.p_shift = &secp192k1_p_shift_str_param,
.p_normalized = &secp192k1_p_normalized_str_param,
.p_reciprocal = &secp192k1_p_reciprocal_str_param,
.a = &secp192k1_a_str_param,
.b = &secp192k1_b_str_param,
.curve_order = &secp192k1_curve_order_str_param,
.gx = &secp192k1_gx_str_param,
.gy = &secp192k1_gy_str_param,
.gz = &secp192k1_gz_str_param,
.gen_order = &secp192k1_gen_order_str_param,
.gen_order_bitlen = &secp192k1_gen_order_bitlen_str_param,
.cofactor = &secp192k1_cofactor_str_param,
.alpha_montgomery = &secp192k1_alpha_montgomery_str_param,
.gamma_montgomery = &secp192k1_gamma_montgomery_str_param,
.alpha_edwards = &secp192k1_alpha_edwards_str_param,
.oid = &secp192k1_oid_str_param,
.name = &secp192k1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_SECP192K1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_SECP192K1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_SECP192K1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_SECP192K1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_SECP192K1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_SECP192K1_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 23)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 23
#endif
#endif /* __EC_PARAMS_SECP192K1_H__ */
#endif /* WITH_CURVE_SECP192K1 */

View file

@ -0,0 +1,312 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_SECP192R1
#ifndef __EC_PARAMS_SECP192R1_H__
#define __EC_PARAMS_SECP192R1_H__
#include "ec_params_external.h"
static const u8 secp192r1_p[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
TO_EC_STR_PARAM(secp192r1_p);
#define CURVE_SECP192R1_P_BITLEN 192
static const u8 secp192r1_p_bitlen[] = { 0xc0 };
TO_EC_STR_PARAM(secp192r1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 secp192r1_r[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01
};
TO_EC_STR_PARAM(secp192r1_r);
static const u8 secp192r1_r_square[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01
};
TO_EC_STR_PARAM(secp192r1_r_square);
static const u8 secp192r1_mpinv[] = {
0x01
};
TO_EC_STR_PARAM(secp192r1_mpinv);
static const u8 secp192r1_p_shift[] = {
0x00
};
TO_EC_STR_PARAM(secp192r1_p_shift);
static const u8 secp192r1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
TO_EC_STR_PARAM(secp192r1_p_normalized);
static const u8 secp192r1_p_reciprocal[] = {
0x00
};
TO_EC_STR_PARAM(secp192r1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 secp192r1_r[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01
};
TO_EC_STR_PARAM(secp192r1_r);
static const u8 secp192r1_r_square[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01
};
TO_EC_STR_PARAM(secp192r1_r_square);
static const u8 secp192r1_mpinv[] = {
0x01
};
TO_EC_STR_PARAM(secp192r1_mpinv);
static const u8 secp192r1_p_shift[] = {
0x00
};
TO_EC_STR_PARAM(secp192r1_p_shift);
static const u8 secp192r1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
TO_EC_STR_PARAM(secp192r1_p_normalized);
static const u8 secp192r1_p_reciprocal[] = {
0x00
};
TO_EC_STR_PARAM(secp192r1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 secp192r1_r[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01
};
TO_EC_STR_PARAM(secp192r1_r);
static const u8 secp192r1_r_square[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01
};
TO_EC_STR_PARAM(secp192r1_r_square);
static const u8 secp192r1_mpinv[] = {
0x01
};
TO_EC_STR_PARAM(secp192r1_mpinv);
static const u8 secp192r1_p_shift[] = {
0x00
};
TO_EC_STR_PARAM(secp192r1_p_shift);
static const u8 secp192r1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
TO_EC_STR_PARAM(secp192r1_p_normalized);
static const u8 secp192r1_p_reciprocal[] = {
0x00
};
TO_EC_STR_PARAM(secp192r1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 secp192r1_a[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc
};
TO_EC_STR_PARAM(secp192r1_a);
static const u8 secp192r1_b[] = {
0x64, 0x21, 0x05, 0x19, 0xe5, 0x9c, 0x80, 0xe7,
0x0f, 0xa7, 0xe9, 0xab, 0x72, 0x24, 0x30, 0x49,
0xfe, 0xb8, 0xde, 0xec, 0xc1, 0x46, 0xb9, 0xb1
};
TO_EC_STR_PARAM(secp192r1_b);
#define CURVE_SECP192R1_CURVE_ORDER_BITLEN 192
static const u8 secp192r1_curve_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x99, 0xde, 0xf8, 0x36,
0x14, 0x6b, 0xc9, 0xb1, 0xb4, 0xd2, 0x28, 0x31
};
TO_EC_STR_PARAM(secp192r1_curve_order);
static const u8 secp192r1_gx[] = {
0x18, 0x8d, 0xa8, 0x0e, 0xb0, 0x30, 0x90, 0xf6,
0x7c, 0xbf, 0x20, 0xeb, 0x43, 0xa1, 0x88, 0x00,
0xf4, 0xff, 0x0a, 0xfd, 0x82, 0xff, 0x10, 0x12
};
TO_EC_STR_PARAM(secp192r1_gx);
static const u8 secp192r1_gy[] = {
0x07, 0x19, 0x2b, 0x95, 0xff, 0xc8, 0xda, 0x78,
0x63, 0x10, 0x11, 0xed, 0x6b, 0x24, 0xcd, 0xd5,
0x73, 0xf9, 0x77, 0xa1, 0x1e, 0x79, 0x48, 0x11
};
TO_EC_STR_PARAM(secp192r1_gy);
static const u8 secp192r1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
};
TO_EC_STR_PARAM(secp192r1_gz);
static const u8 secp192r1_gen_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x99, 0xde, 0xf8, 0x36,
0x14, 0x6b, 0xc9, 0xb1, 0xb4, 0xd2, 0x28, 0x31
};
TO_EC_STR_PARAM(secp192r1_gen_order);
#define CURVE_SECP192R1_Q_BITLEN 192
static const u8 secp192r1_gen_order_bitlen[] = {
0xc0
};
TO_EC_STR_PARAM(secp192r1_gen_order_bitlen);
static const u8 secp192r1_cofactor[] = {
0x01
};
TO_EC_STR_PARAM(secp192r1_cofactor);
static const u8 secp192r1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp192r1_alpha_montgomery, 0);
static const u8 secp192r1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp192r1_gamma_montgomery, 0);
static const u8 secp192r1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp192r1_alpha_edwards, 0);
static const u8 secp192r1_name[] = "SECP192R1";
TO_EC_STR_PARAM(secp192r1_name);
static const u8 secp192r1_oid[] = "1.2.840.10045.3.1.1";
TO_EC_STR_PARAM(secp192r1_oid);
static const ec_str_params secp192r1_str_params = {
.p = &secp192r1_p_str_param,
.p_bitlen = &secp192r1_p_bitlen_str_param,
.r = &secp192r1_r_str_param,
.r_square = &secp192r1_r_square_str_param,
.mpinv = &secp192r1_mpinv_str_param,
.p_shift = &secp192r1_p_shift_str_param,
.p_normalized = &secp192r1_p_normalized_str_param,
.p_reciprocal = &secp192r1_p_reciprocal_str_param,
.a = &secp192r1_a_str_param,
.b = &secp192r1_b_str_param,
.curve_order = &secp192r1_curve_order_str_param,
.gx = &secp192r1_gx_str_param,
.gy = &secp192r1_gy_str_param,
.gz = &secp192r1_gz_str_param,
.gen_order = &secp192r1_gen_order_str_param,
.gen_order_bitlen = &secp192r1_gen_order_bitlen_str_param,
.cofactor = &secp192r1_cofactor_str_param,
.alpha_montgomery = &secp192r1_alpha_montgomery_str_param,
.gamma_montgomery = &secp192r1_gamma_montgomery_str_param,
.alpha_edwards = &secp192r1_alpha_edwards_str_param,
.oid = &secp192r1_oid_str_param,
.name = &secp192r1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_SECP192R1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_SECP192R1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_SECP192R1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_SECP192R1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_SECP192R1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_SECP192R1_CURVE_ORDER_BITLEN
#endif
#endif /* __EC_PARAMS_SECP192R1_H__ */
#endif /* WITH_CURVE_SECP192R1 */

View file

@ -0,0 +1,320 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_SECP224K1
#ifndef __EC_PARAMS_SECP224K1_H__
#define __EC_PARAMS_SECP224K1_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 secp224k1_p[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xe5, 0x6d,
};
TO_EC_STR_PARAM(secp224k1_p);
#define CURVE_SECP224K1_P_BITLEN 224
static const u8 secp224k1_p_bitlen[] = {
0xe0,
};
TO_EC_STR_PARAM(secp224k1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 secp224k1_r[] = {
0x01, 0x00, 0x00, 0x1a, 0x93, 0x00, 0x00, 0x00,
0x00,
};
TO_EC_STR_PARAM(secp224k1_r);
static const u8 secp224k1_r_square[] = {
0x01, 0x00, 0x00, 0x35, 0x26, 0x02, 0xc2, 0x30,
0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
};
TO_EC_STR_PARAM(secp224k1_r_square);
static const u8 secp224k1_mpinv[] = {
0x5a, 0x92, 0xa0, 0x0a, 0x19, 0x8d, 0x13, 0x9b,
};
TO_EC_STR_PARAM(secp224k1_mpinv);
static const u8 secp224k1_p_shift[] = {
0x20,
};
TO_EC_STR_PARAM(secp224k1_p_shift);
static const u8 secp224k1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xe5, 0x6d, 0x00, 0x00, 0x00, 0x00,
};
TO_EC_STR_PARAM(secp224k1_p_normalized);
static const u8 secp224k1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(secp224k1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 secp224k1_r[] = {
0x01, 0x00, 0x00, 0x1a, 0x93,
};
TO_EC_STR_PARAM(secp224k1_r);
static const u8 secp224k1_r_square[] = {
0x01, 0x00, 0x00, 0x35, 0x26, 0x02, 0xc2, 0x30,
0x69,
};
TO_EC_STR_PARAM(secp224k1_r_square);
static const u8 secp224k1_mpinv[] = {
0x19, 0x8d, 0x13, 0x9b,
};
TO_EC_STR_PARAM(secp224k1_mpinv);
static const u8 secp224k1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(secp224k1_p_shift);
static const u8 secp224k1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xe5, 0x6d,
};
TO_EC_STR_PARAM(secp224k1_p_normalized);
static const u8 secp224k1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(secp224k1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 secp224k1_r[] = {
0x01, 0x00, 0x00, 0x1a, 0x93,
};
TO_EC_STR_PARAM(secp224k1_r);
static const u8 secp224k1_r_square[] = {
0x01, 0x00, 0x00, 0x35, 0x26, 0x02, 0xc2, 0x30,
0x69,
};
TO_EC_STR_PARAM(secp224k1_r_square);
static const u8 secp224k1_mpinv[] = {
0x13, 0x9b,
};
TO_EC_STR_PARAM(secp224k1_mpinv);
static const u8 secp224k1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(secp224k1_p_shift);
static const u8 secp224k1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xe5, 0x6d,
};
TO_EC_STR_PARAM(secp224k1_p_normalized);
static const u8 secp224k1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(secp224k1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 secp224k1_a[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
TO_EC_STR_PARAM(secp224k1_a);
static const u8 secp224k1_b[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x05,
};
TO_EC_STR_PARAM(secp224k1_b);
#define CURVE_SECP224K1_CURVE_ORDER_BITLEN 225
static const u8 secp224k1_curve_order[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xdc,
0xe8, 0xd2, 0xec, 0x61, 0x84, 0xca, 0xf0, 0xa9,
0x71, 0x76, 0x9f, 0xb1, 0xf7,
};
TO_EC_STR_PARAM(secp224k1_curve_order);
static const u8 secp224k1_gx[] = {
0xa1, 0x45, 0x5b, 0x33, 0x4d, 0xf0, 0x99, 0xdf,
0x30, 0xfc, 0x28, 0xa1, 0x69, 0xa4, 0x67, 0xe9,
0xe4, 0x70, 0x75, 0xa9, 0x0f, 0x7e, 0x65, 0x0e,
0xb6, 0xb7, 0xa4, 0x5c,
};
TO_EC_STR_PARAM(secp224k1_gx);
static const u8 secp224k1_gy[] = {
0x7e, 0x08, 0x9f, 0xed, 0x7f, 0xba, 0x34, 0x42,
0x82, 0xca, 0xfb, 0xd6, 0xf7, 0xe3, 0x19, 0xf7,
0xc0, 0xb0, 0xbd, 0x59, 0xe2, 0xca, 0x4b, 0xdb,
0x55, 0x6d, 0x61, 0xa5,
};
TO_EC_STR_PARAM(secp224k1_gy);
static const u8 secp224k1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(secp224k1_gz);
static const u8 secp224k1_gen_order[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xdc,
0xe8, 0xd2, 0xec, 0x61, 0x84, 0xca, 0xf0, 0xa9,
0x71, 0x76, 0x9f, 0xb1, 0xf7,
};
TO_EC_STR_PARAM(secp224k1_gen_order);
#define CURVE_SECP224K1_Q_BITLEN 225
static const u8 secp224k1_gen_order_bitlen[] = {
0xe1,
};
TO_EC_STR_PARAM(secp224k1_gen_order_bitlen);
static const u8 secp224k1_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(secp224k1_cofactor);
static const u8 secp224k1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp224k1_alpha_montgomery, 0);
static const u8 secp224k1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp224k1_gamma_montgomery, 0);
static const u8 secp224k1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp224k1_alpha_edwards, 0);
static const u8 secp224k1_name[] = "SECP224K1";
TO_EC_STR_PARAM(secp224k1_name);
static const u8 secp224k1_oid[] = "1.3.132.0.32";
TO_EC_STR_PARAM(secp224k1_oid);
static const ec_str_params secp224k1_str_params = {
.p = &secp224k1_p_str_param,
.p_bitlen = &secp224k1_p_bitlen_str_param,
.r = &secp224k1_r_str_param,
.r_square = &secp224k1_r_square_str_param,
.mpinv = &secp224k1_mpinv_str_param,
.p_shift = &secp224k1_p_shift_str_param,
.p_normalized = &secp224k1_p_normalized_str_param,
.p_reciprocal = &secp224k1_p_reciprocal_str_param,
.a = &secp224k1_a_str_param,
.b = &secp224k1_b_str_param,
.curve_order = &secp224k1_curve_order_str_param,
.gx = &secp224k1_gx_str_param,
.gy = &secp224k1_gy_str_param,
.gz = &secp224k1_gz_str_param,
.gen_order = &secp224k1_gen_order_str_param,
.gen_order_bitlen = &secp224k1_gen_order_bitlen_str_param,
.cofactor = &secp224k1_cofactor_str_param,
.alpha_montgomery = &secp224k1_alpha_montgomery_str_param,
.gamma_montgomery = &secp224k1_gamma_montgomery_str_param,
.alpha_edwards = &secp224k1_alpha_edwards_str_param,
.oid = &secp224k1_oid_str_param,
.name = &secp224k1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_SECP224K1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_SECP224K1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_SECP224K1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_SECP224K1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_SECP224K1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_SECP224K1_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 23)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 23
#endif
#endif /* __EC_PARAMS_SECP224K1_H__ */
#endif /* WITH_CURVE_SECP224K1 */

View file

@ -0,0 +1,279 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_SECP224R1
#ifndef __EC_PARAMS_SECP224R1_H__
#define __EC_PARAMS_SECP224R1_H__
#include "ec_params_external.h"
static const u8 secp224r1_p[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01
};
TO_EC_STR_PARAM(secp224r1_p);
#define CURVE_SECP224R1_P_BITLEN 224
static const u8 secp224r1_p_bitlen[] = { 0xE0 };
TO_EC_STR_PARAM(secp224r1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 secp224r1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
};
static const u8 secp224r1_p_shift[] = {
0x20
};
static const u8 secp224r1_r[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
};
static const u8 secp224r1_r_square[] = {
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01
};
static const u8 secp224r1_mpinv[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 secp224r1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01
};
static const u8 secp224r1_p_shift[] = {
0x00
};
static const u8 secp224r1_r[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff
};
static const u8 secp224r1_r_square[] = {
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01
};
static const u8 secp224r1_mpinv[] = {
0xff, 0xff, 0xff, 0xff
};
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 secp224r1_p_normalized[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01
};
static const u8 secp224r1_p_shift[] = {
0x00
};
static const u8 secp224r1_r[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff
};
static const u8 secp224r1_r_square[] = {
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01
};
static const u8 secp224r1_mpinv[] = {
0xff, 0xff
};
#else /* unknown word size */
#error "Unsupported word size"
#endif
TO_EC_STR_PARAM(secp224r1_r);
TO_EC_STR_PARAM(secp224r1_r_square);
TO_EC_STR_PARAM(secp224r1_p_normalized);
TO_EC_STR_PARAM(secp224r1_mpinv);
TO_EC_STR_PARAM(secp224r1_p_shift);
static const u8 secp224r1_p_reciprocal[] = {
0x00
};
TO_EC_STR_PARAM(secp224r1_p_reciprocal);
static const u8 secp224r1_a[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFE
};
TO_EC_STR_PARAM(secp224r1_a);
static const u8 secp224r1_b[] = {
0xB4, 0x05, 0x0A, 0x85, 0x0C, 0x04, 0xB3, 0xAB,
0xF5, 0x41, 0x32, 0x56, 0x50, 0x44, 0xB0, 0xB7,
0xD7, 0xBF, 0xD8, 0xBA, 0x27, 0x0B, 0x39, 0x43,
0x23, 0x55, 0xFF, 0xB4
};
TO_EC_STR_PARAM(secp224r1_b);
#define CURVE_SECP224R1_CURVE_ORDER_BITLEN 224
static const u8 secp224r1_curve_order[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x16, 0xA2,
0xE0, 0xB8, 0xF0, 0x3E, 0x13, 0xDD, 0x29, 0x45,
0x5C, 0x5C, 0x2A, 0x3D
};
TO_EC_STR_PARAM(secp224r1_curve_order);
static const u8 secp224r1_gx[] = {
0xB7, 0x0E, 0x0C, 0xBD, 0x6B, 0xB4, 0xBF, 0x7F,
0x32, 0x13, 0x90, 0xB9, 0x4A, 0x03, 0xC1, 0xD3,
0x56, 0xC2, 0x11, 0x22, 0x34, 0x32, 0x80, 0xD6,
0x11, 0x5C, 0x1D, 0x21
};
TO_EC_STR_PARAM(secp224r1_gx);
static const u8 secp224r1_gy[] = {
0xBD, 0x37, 0x63, 0x88, 0xB5, 0xF7, 0x23, 0xFB,
0x4C, 0x22, 0xDF, 0xE6, 0xCD, 0x43, 0x75, 0xA0,
0x5A, 0x07, 0x47, 0x64, 0x44, 0xD5, 0x81, 0x99,
0x85, 0x00, 0x7E, 0x34
};
TO_EC_STR_PARAM(secp224r1_gy);
static const u8 secp224r1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01
};
TO_EC_STR_PARAM(secp224r1_gz);
static const u8 secp224r1_gen_order[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x16, 0xA2,
0xE0, 0xB8, 0xF0, 0x3E, 0x13, 0xDD, 0x29, 0x45,
0x5C, 0x5C, 0x2A, 0x3D
};
TO_EC_STR_PARAM(secp224r1_gen_order);
#define CURVE_SECP224R1_Q_BITLEN 224
static const u8 secp224r1_gen_order_bitlen[] = { 0xE0 };
TO_EC_STR_PARAM(secp224r1_gen_order_bitlen);
static const u8 secp224r1_cofactor[] = { 0x01 };
TO_EC_STR_PARAM(secp224r1_cofactor);
static const u8 secp224r1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp224r1_alpha_montgomery, 0);
static const u8 secp224r1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp224r1_gamma_montgomery, 0);
static const u8 secp224r1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp224r1_alpha_edwards, 0);
static const u8 secp224r1_oid[] = "1.3.132.0.33";
TO_EC_STR_PARAM(secp224r1_oid);
static const u8 secp224r1_name[] = "SECP224R1";
TO_EC_STR_PARAM(secp224r1_name);
static const ec_str_params secp224r1_str_params = {
.p = &secp224r1_p_str_param,
.p_bitlen = &secp224r1_p_bitlen_str_param,
.r = &secp224r1_r_str_param,
.r_square = &secp224r1_r_square_str_param,
.mpinv = &secp224r1_mpinv_str_param,
.p_shift = &secp224r1_p_shift_str_param,
.p_normalized = &secp224r1_p_normalized_str_param,
.p_reciprocal = &secp224r1_p_reciprocal_str_param,
.a = &secp224r1_a_str_param,
.b = &secp224r1_b_str_param,
.curve_order = &secp224r1_curve_order_str_param,
.gx = &secp224r1_gx_str_param,
.gy = &secp224r1_gy_str_param,
.gz = &secp224r1_gz_str_param,
.gen_order = &secp224r1_gen_order_str_param,
.gen_order_bitlen = &secp224r1_gen_order_bitlen_str_param,
.cofactor = &secp224r1_cofactor_str_param,
.alpha_montgomery = &secp224r1_alpha_montgomery_str_param,
.gamma_montgomery = &secp224r1_gamma_montgomery_str_param,
.alpha_edwards = &secp224r1_alpha_edwards_str_param,
.oid = &secp224r1_oid_str_param,
.name = &secp224r1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#if (CURVES_MAX_P_BIT_LEN < CURVE_SECP224R1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_SECP224R1_P_BITLEN
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_SECP224R1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_SECP224R1_Q_BITLEN
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_SECP224R1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_SECP224R1_CURVE_ORDER_BITLEN
#endif
#endif /* __EC_PARAMS_SECP224R1_H__ */
#endif /* WITH_CURVE_SECP224R1 */

View file

@ -0,0 +1,318 @@
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_SECP256K1
#ifndef __EC_PARAMS_SECP256K1_H__
#define __EC_PARAMS_SECP256K1_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 secp256k1_p[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f,
};
TO_EC_STR_PARAM(secp256k1_p);
#define CURVE_SECP256K1_P_BITLEN 256
static const u8 secp256k1_p_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(secp256k1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 secp256k1_r[] = {
0x01, 0x00, 0x00, 0x03, 0xd1,
};
TO_EC_STR_PARAM(secp256k1_r);
static const u8 secp256k1_r_square[] = {
0x01, 0x00, 0x00, 0x07, 0xa2, 0x00, 0x0e, 0x90,
0xa1,
};
TO_EC_STR_PARAM(secp256k1_r_square);
static const u8 secp256k1_mpinv[] = {
0xd8, 0x38, 0x09, 0x1d, 0xd2, 0x25, 0x35, 0x31,
};
TO_EC_STR_PARAM(secp256k1_mpinv);
static const u8 secp256k1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(secp256k1_p_shift);
static const u8 secp256k1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f,
};
TO_EC_STR_PARAM(secp256k1_p_normalized);
static const u8 secp256k1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(secp256k1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 secp256k1_r[] = {
0x01, 0x00, 0x00, 0x03, 0xd1,
};
TO_EC_STR_PARAM(secp256k1_r);
static const u8 secp256k1_r_square[] = {
0x01, 0x00, 0x00, 0x07, 0xa2, 0x00, 0x0e, 0x90,
0xa1,
};
TO_EC_STR_PARAM(secp256k1_r_square);
static const u8 secp256k1_mpinv[] = {
0xd2, 0x25, 0x35, 0x31,
};
TO_EC_STR_PARAM(secp256k1_mpinv);
static const u8 secp256k1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(secp256k1_p_shift);
static const u8 secp256k1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f,
};
TO_EC_STR_PARAM(secp256k1_p_normalized);
static const u8 secp256k1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(secp256k1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 secp256k1_r[] = {
0x01, 0x00, 0x00, 0x03, 0xd1,
};
TO_EC_STR_PARAM(secp256k1_r);
static const u8 secp256k1_r_square[] = {
0x01, 0x00, 0x00, 0x07, 0xa2, 0x00, 0x0e, 0x90,
0xa1,
};
TO_EC_STR_PARAM(secp256k1_r_square);
static const u8 secp256k1_mpinv[] = {
0x35, 0x31,
};
TO_EC_STR_PARAM(secp256k1_mpinv);
static const u8 secp256k1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(secp256k1_p_shift);
static const u8 secp256k1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f,
};
TO_EC_STR_PARAM(secp256k1_p_normalized);
static const u8 secp256k1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(secp256k1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 secp256k1_a[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
TO_EC_STR_PARAM(secp256k1_a);
static const u8 secp256k1_b[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
};
TO_EC_STR_PARAM(secp256k1_b);
#define CURVE_SECP256K1_CURVE_ORDER_BITLEN 256
static const u8 secp256k1_curve_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41,
};
TO_EC_STR_PARAM(secp256k1_curve_order);
static const u8 secp256k1_gx[] = {
0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac,
0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07,
0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9,
0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98,
};
TO_EC_STR_PARAM(secp256k1_gx);
static const u8 secp256k1_gy[] = {
0x48, 0x3a, 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65,
0x5d, 0xa4, 0xfb, 0xfc, 0x0e, 0x11, 0x08, 0xa8,
0xfd, 0x17, 0xb4, 0x48, 0xa6, 0x85, 0x54, 0x19,
0x9c, 0x47, 0xd0, 0x8f, 0xfb, 0x10, 0xd4, 0xb8,
};
TO_EC_STR_PARAM(secp256k1_gy);
static const u8 secp256k1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(secp256k1_gz);
static const u8 secp256k1_gen_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41,
};
TO_EC_STR_PARAM(secp256k1_gen_order);
#define CURVE_SECP256K1_Q_BITLEN 256
static const u8 secp256k1_gen_order_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(secp256k1_gen_order_bitlen);
static const u8 secp256k1_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(secp256k1_cofactor);
static const u8 secp256k1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp256k1_alpha_montgomery, 0);
static const u8 secp256k1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp256k1_gamma_montgomery, 0);
static const u8 secp256k1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp256k1_alpha_edwards, 0);
static const u8 secp256k1_name[] = "SECP256K1";
TO_EC_STR_PARAM(secp256k1_name);
static const u8 secp256k1_oid[] = "1.3.132.0.10";
TO_EC_STR_PARAM(secp256k1_oid);
static const ec_str_params secp256k1_str_params = {
.p = &secp256k1_p_str_param,
.p_bitlen = &secp256k1_p_bitlen_str_param,
.r = &secp256k1_r_str_param,
.r_square = &secp256k1_r_square_str_param,
.mpinv = &secp256k1_mpinv_str_param,
.p_shift = &secp256k1_p_shift_str_param,
.p_normalized = &secp256k1_p_normalized_str_param,
.p_reciprocal = &secp256k1_p_reciprocal_str_param,
.a = &secp256k1_a_str_param,
.b = &secp256k1_b_str_param,
.curve_order = &secp256k1_curve_order_str_param,
.gx = &secp256k1_gx_str_param,
.gy = &secp256k1_gy_str_param,
.gz = &secp256k1_gz_str_param,
.gen_order = &secp256k1_gen_order_str_param,
.gen_order_bitlen = &secp256k1_gen_order_bitlen_str_param,
.cofactor = &secp256k1_cofactor_str_param,
.alpha_montgomery = &secp256k1_alpha_montgomery_str_param,
.gamma_montgomery = &secp256k1_gamma_montgomery_str_param,
.alpha_edwards = &secp256k1_alpha_edwards_str_param,
.oid = &secp256k1_oid_str_param,
.name = &secp256k1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_SECP256K1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_SECP256K1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_SECP256K1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_SECP256K1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_SECP256K1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_SECP256K1_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 23)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 23
#endif
#endif /* __EC_PARAMS_SECP256K1_H__ */
#endif /* WITH_CURVE_SECP256K1 */

View file

@ -0,0 +1,227 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_SECP256R1
#ifndef __EC_PARAMS_SECP256R1_H__
#define __EC_PARAMS_SECP256R1_H__
#include "ec_params_external.h"
static const u8 secp256r1_p[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};
TO_EC_STR_PARAM(secp256r1_p);
#define CURVE_SECP256R1_P_BITLEN 256
static const u8 secp256r1_p_bitlen[] = { 0x01, 0x00 };
TO_EC_STR_PARAM(secp256r1_p_bitlen);
static const u8 secp256r1_r[] = {
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
};
TO_EC_STR_PARAM(secp256r1_r);
static const u8 secp256r1_r_square[] = {
0x00, 0x00, 0x00, 0x04, 0xff, 0xff, 0xff, 0xfd,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xff, 0xfb, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03
};
TO_EC_STR_PARAM(secp256r1_r_square);
static const u8 secp256r1_mpinv[] = { 0x00, 0x00, 0x00, 0x01 };
TO_EC_STR_PARAM(secp256r1_mpinv);
static const u8 secp256r1_p_shift[] = {
0x00
};
TO_EC_STR_PARAM(secp256r1_p_shift);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 secp256r1_p_reciprocal[] = {
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
};
#elif (WORD_BYTES == 4) || (WORD_BYTES == 2) /* 32 and 16-bit words */
static const u8 secp256r1_p_reciprocal[] = {
0x00
};
#else /* unknown word size */
#error "Unsupported word size"
#endif
TO_EC_STR_PARAM(secp256r1_p_reciprocal);
static const u8 secp256r1_a[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC
};
TO_EC_STR_PARAM(secp256r1_a);
static const u8 secp256r1_b[] = {
0x5A, 0xC6, 0x35, 0xD8, 0xAA, 0x3A, 0x93, 0xE7,
0xB3, 0xEB, 0xBD, 0x55, 0x76, 0x98, 0x86, 0xBC,
0x65, 0x1D, 0x06, 0xB0, 0xCC, 0x53, 0xB0, 0xF6,
0x3B, 0xCE, 0x3C, 0x3E, 0x27, 0xD2, 0x60, 0x4B
};
TO_EC_STR_PARAM(secp256r1_b);
#define CURVE_SECP256R1_CURVE_ORDER_BITLEN 256
static const u8 secp256r1_curve_order[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17, 0x9E, 0x84,
0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51
};
TO_EC_STR_PARAM(secp256r1_curve_order);
static const u8 secp256r1_gx[] = {
0x6B, 0x17, 0xD1, 0xF2, 0xE1, 0x2C, 0x42, 0x47,
0xF8, 0xBC, 0xE6, 0xE5, 0x63, 0xA4, 0x40, 0xF2,
0x77, 0x03, 0x7D, 0x81, 0x2D, 0xEB, 0x33, 0xA0,
0xF4, 0xA1, 0x39, 0x45, 0xD8, 0x98, 0xC2, 0x96
};
TO_EC_STR_PARAM(secp256r1_gx);
static const u8 secp256r1_gy[] = {
0x4F, 0xE3, 0x42, 0xE2, 0xFE, 0x1A, 0x7F, 0x9B,
0x8E, 0xE7, 0xEB, 0x4A, 0x7C, 0x0F, 0x9E, 0x16,
0x2B, 0xCE, 0x33, 0x57, 0x6B, 0x31, 0x5E, 0xCE,
0xCB, 0xB6, 0x40, 0x68, 0x37, 0xBF, 0x51, 0xF5
};
TO_EC_STR_PARAM(secp256r1_gy);
static const u8 secp256r1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
};
TO_EC_STR_PARAM(secp256r1_gz);
static const u8 secp256r1_gen_order[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17, 0x9E, 0x84,
0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51
};
TO_EC_STR_PARAM(secp256r1_gen_order);
#define CURVE_SECP256R1_Q_BITLEN 256
static const u8 secp256r1_gen_order_bitlen[] = { 0x01, 0x00 };
TO_EC_STR_PARAM(secp256r1_gen_order_bitlen);
static const u8 secp256r1_cofactor[] = { 0x01 };
TO_EC_STR_PARAM(secp256r1_cofactor);
static const u8 secp256r1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp256r1_alpha_montgomery, 0);
static const u8 secp256r1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp256r1_gamma_montgomery, 0);
static const u8 secp256r1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp256r1_alpha_edwards, 0);
static const u8 secp256r1_oid[] = "1.2.840.10045.3.1.7";
TO_EC_STR_PARAM(secp256r1_oid);
static const u8 secp256r1_name[] = "SECP256R1";
TO_EC_STR_PARAM(secp256r1_name);
static const ec_str_params secp256r1_str_params = {
.p = &secp256r1_p_str_param,
.p_bitlen = &secp256r1_p_bitlen_str_param,
.r = &secp256r1_r_str_param,
.r_square = &secp256r1_r_square_str_param,
.mpinv = &secp256r1_mpinv_str_param,
.p_shift = &secp256r1_p_shift_str_param,
.p_normalized = &secp256r1_p_str_param,
.p_reciprocal = &secp256r1_p_reciprocal_str_param,
.a = &secp256r1_a_str_param,
.b = &secp256r1_b_str_param,
.curve_order = &secp256r1_curve_order_str_param,
.gx = &secp256r1_gx_str_param,
.gy = &secp256r1_gy_str_param,
.gz = &secp256r1_gz_str_param,
.gen_order = &secp256r1_gen_order_str_param,
.gen_order_bitlen = &secp256r1_gen_order_bitlen_str_param,
.cofactor = &secp256r1_cofactor_str_param,
.alpha_montgomery = &secp256r1_alpha_montgomery_str_param,
.gamma_montgomery = &secp256r1_gamma_montgomery_str_param,
.alpha_edwards = &secp256r1_alpha_edwards_str_param,
.oid = &secp256r1_oid_str_param,
.name = &secp256r1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_SECP256R1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_SECP256R1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_SECP256R1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_SECP256R1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_SECP256R1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_SECP256R1_CURVE_ORDER_BITLEN
#endif
#endif /* __EC_PARAMS_SECP256R1_H__ */
#endif /* WITH_CURVE_SECP256R1 */

View file

@ -0,0 +1,250 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_SECP384R1
#ifndef __EC_PARAMS_SECP384R1_H__
#define __EC_PARAMS_SECP384R1_H__
#include "ec_params_external.h"
static const u8 secp384r1_p[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF
};
TO_EC_STR_PARAM(secp384r1_p);
#define CURVE_SECP384R1_P_BITLEN 384
static const u8 secp384r1_p_bitlen[] = { 0x01, 0x80 };
TO_EC_STR_PARAM(secp384r1_p_bitlen);
static const u8 secp384r1_r[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01
};
TO_EC_STR_PARAM(secp384r1_r);
static const u8 secp384r1_r_square[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x01
};
TO_EC_STR_PARAM(secp384r1_r_square);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 secp384r1_mpinv[] = {
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01
};
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 secp384r1_mpinv[] = {
0x00, 0x00, 0x00, 0x01
};
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 secp384r1_mpinv[] = {
0x00, 0x01
};
#else /* unknown word size */
#error "Unsupported word size"
#endif
TO_EC_STR_PARAM(secp384r1_mpinv);
static const u8 secp384r1_p_shift[] = {
0x00
};
TO_EC_STR_PARAM(secp384r1_p_shift);
static const u8 secp384r1_p_reciprocal[] = {
0x00
};
TO_EC_STR_PARAM(secp384r1_p_reciprocal);
static const u8 secp384r1_a[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFC,
};
TO_EC_STR_PARAM(secp384r1_a);
static const u8 secp384r1_b[] = {
0xB3, 0x31, 0x2F, 0xA7, 0xE2, 0x3E, 0xE7, 0xE4,
0x98, 0x8E, 0x05, 0x6B, 0xE3, 0xF8, 0x2D, 0x19,
0x18, 0x1D, 0x9C, 0x6E, 0xFE, 0x81, 0x41, 0x12,
0x03, 0x14, 0x08, 0x8F, 0x50, 0x13, 0x87, 0x5A,
0xC6, 0x56, 0x39, 0x8D, 0x8A, 0x2E, 0xD1, 0x9D,
0x2A, 0x85, 0xC8, 0xED, 0xD3, 0xEC, 0x2A, 0xEF
};
TO_EC_STR_PARAM(secp384r1_b);
#define CURVE_SECP384R1_CURVE_ORDER_BITLEN 384
static const u8 secp384r1_curve_order[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xC7, 0x63, 0x4D, 0x81, 0xF4, 0x37, 0x2D, 0xDF,
0x58, 0x1A, 0x0D, 0xB2, 0x48, 0xB0, 0xA7, 0x7A,
0xEC, 0xEC, 0x19, 0x6A, 0xCC, 0xC5, 0x29, 0x73
};
TO_EC_STR_PARAM(secp384r1_curve_order);
static const u8 secp384r1_gx[] = {
0xAA, 0x87, 0xCA, 0x22, 0xBE, 0x8B, 0x05, 0x37,
0x8E, 0xB1, 0xC7, 0x1E, 0xF3, 0x20, 0xAD, 0x74,
0x6E, 0x1D, 0x3B, 0x62, 0x8B, 0xA7, 0x9B, 0x98,
0x59, 0xF7, 0x41, 0xE0, 0x82, 0x54, 0x2A, 0x38,
0x55, 0x02, 0xF2, 0x5D, 0xBF, 0x55, 0x29, 0x6C,
0x3A, 0x54, 0x5E, 0x38, 0x72, 0x76, 0x0A, 0xB7
};
TO_EC_STR_PARAM(secp384r1_gx);
static const u8 secp384r1_gy[] = {
0x36, 0x17, 0xDE, 0x4A, 0x96, 0x26, 0x2C, 0x6F,
0x5D, 0x9E, 0x98, 0xBF, 0x92, 0x92, 0xDC, 0x29,
0xF8, 0xF4, 0x1D, 0xBD, 0x28, 0x9A, 0x14, 0x7C,
0xE9, 0xDA, 0x31, 0x13, 0xB5, 0xF0, 0xB8, 0xC0,
0x0A, 0x60, 0xB1, 0xCE, 0x1D, 0x7E, 0x81, 0x9D,
0x7A, 0x43, 0x1D, 0x7C, 0x90, 0xEA, 0x0E, 0x5F
};
TO_EC_STR_PARAM(secp384r1_gy);
static const u8 secp384r1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
};
TO_EC_STR_PARAM(secp384r1_gz);
static const u8 secp384r1_gen_order[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xC7, 0x63, 0x4D, 0x81, 0xF4, 0x37, 0x2D, 0xDF,
0x58, 0x1A, 0x0D, 0xB2, 0x48, 0xB0, 0xA7, 0x7A,
0xEC, 0xEC, 0x19, 0x6A, 0xCC, 0xC5, 0x29, 0x73
};
TO_EC_STR_PARAM(secp384r1_gen_order);
#define CURVE_SECP384R1_Q_BITLEN 384
static const u8 secp384r1_gen_order_bitlen[] = { 0x01, 0x80 };
TO_EC_STR_PARAM(secp384r1_gen_order_bitlen);
static const u8 secp384r1_cofactor[] = { 0x01 };
TO_EC_STR_PARAM(secp384r1_cofactor);
static const u8 secp384r1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp384r1_alpha_montgomery, 0);
static const u8 secp384r1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp384r1_gamma_montgomery, 0);
static const u8 secp384r1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp384r1_alpha_edwards, 0);
static const u8 secp384r1_oid[] = "1.3.132.0.34";
TO_EC_STR_PARAM(secp384r1_oid);
static const u8 secp384r1_name[] = "SECP384R1";
TO_EC_STR_PARAM(secp384r1_name);
static const ec_str_params secp384r1_str_params = {
.p = &secp384r1_p_str_param,
.p_bitlen = &secp384r1_p_bitlen_str_param,
.r = &secp384r1_r_str_param,
.r_square = &secp384r1_r_square_str_param,
.mpinv = &secp384r1_mpinv_str_param,
.p_shift = &secp384r1_p_shift_str_param,
.p_normalized = &secp384r1_p_str_param,
.p_reciprocal = &secp384r1_p_reciprocal_str_param,
.a = &secp384r1_a_str_param,
.b = &secp384r1_b_str_param,
.curve_order = &secp384r1_curve_order_str_param,
.gx = &secp384r1_gx_str_param,
.gy = &secp384r1_gy_str_param,
.gz = &secp384r1_gz_str_param,
.gen_order = &secp384r1_gen_order_str_param,
.gen_order_bitlen = &secp384r1_gen_order_bitlen_str_param,
.cofactor = &secp384r1_cofactor_str_param,
.alpha_montgomery = &secp384r1_alpha_montgomery_str_param,
.gamma_montgomery = &secp384r1_gamma_montgomery_str_param,
.alpha_edwards = &secp384r1_alpha_edwards_str_param,
.oid = &secp384r1_oid_str_param,
.name = &secp384r1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_SECP384R1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_SECP384R1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_SECP384R1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_SECP384R1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_SECP384R1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_SECP384R1_CURVE_ORDER_BITLEN
#endif
#endif /* __EC_PARAMS_SECP384R1_H__ */
#endif /* WITH_CURVE_SECP384R1 */

View file

@ -0,0 +1,327 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_SECP521R1
#ifndef __EC_PARAMS_SECP521R1_H__
#define __EC_PARAMS_SECP521R1_H__
#include "ec_params_external.h"
static const u8 secp521r1_p[] = {
0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF
};
TO_EC_STR_PARAM(secp521r1_p);
#define CURVE_SECP521R1_P_BITLEN 521
static const u8 secp521r1_p_bitlen[] = { 0x02, 0x09 };
TO_EC_STR_PARAM(secp521r1_p_bitlen);
/*
* Note: our multiprecision Montgomery mutiplication algorithm
* fp_mul_redc1() expects R and R^2 used for prior redcification
* to be power of B, the base in which we currently work, i.e.
* the defined number of bits for our words. For primes which
* have a common bitsize such as 256 and 512, which are a multiple
* of 64, 32 and 16, the value of r and r^2 are alway same, no
* matter the value of WORD_BYTES (i.e. no matter the base we
* currently use). But for secp521r1, p being 521 bit long, r is
* 2^576 mod p for 64 bits words, 2^544 mod p for 32 bits words
* and 528 for 16 bit words. Hence the following specific
* definitions for r and r^2 depending on words bitsize.
*/
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 secp521r1_r[] = {
0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const u8 secp521r1_r_square[] = {
0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 secp521r1_r[] = { 0x80, 0x00, 0x00 };
static const u8 secp521r1_r_square[] = {
0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00
};
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 secp521r1_r[] = { 0x80 };
static const u8 secp521r1_r_square[] = { 0x40, 0x00 };
#else /* unknown word size */
#error "Unsupported word size"
#endif
TO_EC_STR_PARAM(secp521r1_r);
TO_EC_STR_PARAM(secp521r1_r_square);
static const u8 secp521r1_mpinv[] = { 0x01 };
TO_EC_STR_PARAM(secp521r1_mpinv);
#if (WORD_BYTES == 8)
static const u8 secp521r1_p_shift[] = {
0x37
};
static const u8 secp521r1_p_normalized[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
#elif (WORD_BYTES == 4)
static const u8 secp521r1_p_shift[] = {
0x17
};
static const u8 secp521r1_p_normalized[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0x80, 0x00, 0x00
};
#elif (WORD_BYTES == 2)
static const u8 secp521r1_p_shift[] = {
0x7
};
static const u8 secp521r1_p_normalized[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0x80
};
#else
#error "Unsupported word size"
#endif
TO_EC_STR_PARAM(secp521r1_p_shift);
TO_EC_STR_PARAM(secp521r1_p_normalized);
static const u8 secp521r1_p_reciprocal[] = {
0x00
};
TO_EC_STR_PARAM(secp521r1_p_reciprocal);
static const u8 secp521r1_a[] = {
0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFC
};
TO_EC_STR_PARAM(secp521r1_a);
static const u8 secp521r1_b[] = {
0x00, 0x51, 0x95, 0x3E, 0xB9, 0x61, 0x8E, 0x1C,
0x9A, 0x1F, 0x92, 0x9A, 0x21, 0xA0, 0xB6, 0x85,
0x40, 0xEE, 0xA2, 0xDA, 0x72, 0x5B, 0x99, 0xB3,
0x15, 0xF3, 0xB8, 0xB4, 0x89, 0x91, 0x8E, 0xF1,
0x09, 0xE1, 0x56, 0x19, 0x39, 0x51, 0xEC, 0x7E,
0x93, 0x7B, 0x16, 0x52, 0xC0, 0xBD, 0x3B, 0xB1,
0xBF, 0x07, 0x35, 0x73, 0xDF, 0x88, 0x3D, 0x2C,
0x34, 0xF1, 0xEF, 0x45, 0x1F, 0xD4, 0x6B, 0x50,
0x3F, 0x00
};
TO_EC_STR_PARAM(secp521r1_b);
#define CURVE_SECP521R1_CURVE_ORDER_BITLEN 521
static const u8 secp521r1_curve_order[] = {
0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFA, 0x51, 0x86, 0x87, 0x83, 0xBF, 0x2F,
0x96, 0x6B, 0x7F, 0xCC, 0x01, 0x48, 0xF7, 0x09,
0xA5, 0xD0, 0x3B, 0xB5, 0xC9, 0xB8, 0x89, 0x9C,
0x47, 0xAE, 0xBB, 0x6F, 0xB7, 0x1E, 0x91, 0x38,
0x64, 0x09
};
TO_EC_STR_PARAM(secp521r1_curve_order);
static const u8 secp521r1_gx[] = {
0x00, 0xC6, 0x85, 0x8E, 0x06, 0xB7, 0x04, 0x04,
0xE9, 0xCD, 0x9E, 0x3E, 0xCB, 0x66, 0x23, 0x95,
0xB4, 0x42, 0x9C, 0x64, 0x81, 0x39, 0x05, 0x3F,
0xB5, 0x21, 0xF8, 0x28, 0xAF, 0x60, 0x6B, 0x4D,
0x3D, 0xBA, 0xA1, 0x4B, 0x5E, 0x77, 0xEF, 0xE7,
0x59, 0x28, 0xFE, 0x1D, 0xC1, 0x27, 0xA2, 0xFF,
0xA8, 0xDE, 0x33, 0x48, 0xB3, 0xC1, 0x85, 0x6A,
0x42, 0x9B, 0xF9, 0x7E, 0x7E, 0x31, 0xC2, 0xE5,
0xBD, 0x66,
};
TO_EC_STR_PARAM(secp521r1_gx);
static const u8 secp521r1_gy[] = {
0x01, 0x18, 0x39, 0x29, 0x6A, 0x78, 0x9A, 0x3B,
0xC0, 0x04, 0x5C, 0x8A, 0x5F, 0xB4, 0x2C, 0x7D,
0x1B, 0xD9, 0x98, 0xF5, 0x44, 0x49, 0x57, 0x9B,
0x44, 0x68, 0x17, 0xAF, 0xBD, 0x17, 0x27, 0x3E,
0x66, 0x2C, 0x97, 0xEE, 0x72, 0x99, 0x5E, 0xF4,
0x26, 0x40, 0xC5, 0x50, 0xB9, 0x01, 0x3F, 0xAD,
0x07, 0x61, 0x35, 0x3C, 0x70, 0x86, 0xA2, 0x72,
0xC2, 0x40, 0x88, 0xBE, 0x94, 0x76, 0x9F, 0xD1,
0x66, 0x50
};
TO_EC_STR_PARAM(secp521r1_gy);
static const u8 secp521r1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01
};
TO_EC_STR_PARAM(secp521r1_gz);
static const u8 secp521r1_gen_order[] = {
0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFA, 0x51, 0x86, 0x87, 0x83, 0xBF, 0x2F,
0x96, 0x6B, 0x7F, 0xCC, 0x01, 0x48, 0xF7, 0x09,
0xA5, 0xD0, 0x3B, 0xB5, 0xC9, 0xB8, 0x89, 0x9C,
0x47, 0xAE, 0xBB, 0x6F, 0xB7, 0x1E, 0x91, 0x38,
0x64, 0x09
};
TO_EC_STR_PARAM(secp521r1_gen_order);
#define CURVE_SECP521R1_Q_BITLEN 521
static const u8 secp521r1_gen_order_bitlen[] = { 0x02, 0x09 };
TO_EC_STR_PARAM(secp521r1_gen_order_bitlen);
static const u8 secp521r1_cofactor[] = { 0x01 };
TO_EC_STR_PARAM(secp521r1_cofactor);
static const u8 secp521r1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp521r1_alpha_montgomery, 0);
static const u8 secp521r1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp521r1_gamma_montgomery, 0);
static const u8 secp521r1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp521r1_alpha_edwards, 0);
static const u8 secp521r1_oid[] = "1.3.132.0.35";
TO_EC_STR_PARAM(secp521r1_oid);
static const u8 secp521r1_name[] = "SECP521R1";
TO_EC_STR_PARAM(secp521r1_name);
static const ec_str_params secp521r1_str_params = {
.p = &secp521r1_p_str_param,
.p_bitlen = &secp521r1_p_bitlen_str_param,
.r = &secp521r1_r_str_param,
.r_square = &secp521r1_r_square_str_param,
.mpinv = &secp521r1_mpinv_str_param,
.p_shift = &secp521r1_p_shift_str_param,
.p_normalized = &secp521r1_p_normalized_str_param,
.p_reciprocal = &secp521r1_p_reciprocal_str_param,
.a = &secp521r1_a_str_param,
.b = &secp521r1_b_str_param,
.curve_order = &secp521r1_curve_order_str_param,
.gx = &secp521r1_gx_str_param,
.gy = &secp521r1_gy_str_param,
.gz = &secp521r1_gz_str_param,
.gen_order = &secp521r1_gen_order_str_param,
.gen_order_bitlen = &secp521r1_gen_order_bitlen_str_param,
.cofactor = &secp521r1_cofactor_str_param,
.alpha_montgomery = &secp521r1_alpha_montgomery_str_param,
.gamma_montgomery = &secp521r1_gamma_montgomery_str_param,
.alpha_edwards = &secp521r1_alpha_edwards_str_param,
.oid = &secp521r1_oid_str_param,
.name = &secp521r1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_SECP521R1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_SECP521R1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_SECP521R1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_SECP521R1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_SECP521R1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_SECP521R1_CURVE_ORDER_BITLEN
#endif
#endif /* __EC_PARAMS_SECP521R1_H__ */
#endif /* WITH_CURVE_SECP521R1 */

View file

@ -0,0 +1,326 @@
/*
* Copyright (C) 2021 - This file is part of libecc project
*
* Authors:
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Ryad BENADJILA <ryadbenadjila@gmail.com>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_SM2P192TEST
#ifndef __EC_PARAMS_SM2P192TEST_H__
#define __EC_PARAMS_SM2P192TEST_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 sm2p192test_p[] = {
0xbd, 0xb6, 0xf4, 0xfe, 0x3e, 0x8b, 0x1d, 0x9e,
0x0d, 0xa8, 0xc0, 0xd4, 0x6f, 0x4c, 0x31, 0x8c,
0xef, 0xe4, 0xaf, 0xe3, 0xb6, 0xb8, 0x55, 0x1f,
};
TO_EC_STR_PARAM(sm2p192test_p);
#define CURVE_SM2P192TEST_P_BITLEN 192
static const u8 sm2p192test_p_bitlen[] = {
0xc0,
};
TO_EC_STR_PARAM(sm2p192test_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 sm2p192test_r[] = {
0x42, 0x49, 0x0b, 0x01, 0xc1, 0x74, 0xe2, 0x61,
0xf2, 0x57, 0x3f, 0x2b, 0x90, 0xb3, 0xce, 0x73,
0x10, 0x1b, 0x50, 0x1c, 0x49, 0x47, 0xaa, 0xe1,
};
TO_EC_STR_PARAM(sm2p192test_r);
static const u8 sm2p192test_r_square[] = {
0xa8, 0x9e, 0x36, 0x8f, 0xa3, 0xa3, 0x5f, 0x24,
0x9c, 0xeb, 0x34, 0x38, 0x97, 0x1b, 0x28, 0x1a,
0xab, 0xb1, 0xe2, 0x02, 0xf0, 0x63, 0x41, 0x2c,
};
TO_EC_STR_PARAM(sm2p192test_r_square);
static const u8 sm2p192test_mpinv[] = {
0xc9, 0x95, 0x02, 0xed, 0x2b, 0x73, 0x19, 0x21,
};
TO_EC_STR_PARAM(sm2p192test_mpinv);
static const u8 sm2p192test_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(sm2p192test_p_shift);
static const u8 sm2p192test_p_normalized[] = {
0xbd, 0xb6, 0xf4, 0xfe, 0x3e, 0x8b, 0x1d, 0x9e,
0x0d, 0xa8, 0xc0, 0xd4, 0x6f, 0x4c, 0x31, 0x8c,
0xef, 0xe4, 0xaf, 0xe3, 0xb6, 0xb8, 0x55, 0x1f,
};
TO_EC_STR_PARAM(sm2p192test_p_normalized);
static const u8 sm2p192test_p_reciprocal[] = {
0x59, 0x71, 0xf0, 0x4b, 0x2a, 0x1c, 0x05, 0xe0,
};
TO_EC_STR_PARAM(sm2p192test_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 sm2p192test_r[] = {
0x42, 0x49, 0x0b, 0x01, 0xc1, 0x74, 0xe2, 0x61,
0xf2, 0x57, 0x3f, 0x2b, 0x90, 0xb3, 0xce, 0x73,
0x10, 0x1b, 0x50, 0x1c, 0x49, 0x47, 0xaa, 0xe1,
};
TO_EC_STR_PARAM(sm2p192test_r);
static const u8 sm2p192test_r_square[] = {
0xa8, 0x9e, 0x36, 0x8f, 0xa3, 0xa3, 0x5f, 0x24,
0x9c, 0xeb, 0x34, 0x38, 0x97, 0x1b, 0x28, 0x1a,
0xab, 0xb1, 0xe2, 0x02, 0xf0, 0x63, 0x41, 0x2c,
};
TO_EC_STR_PARAM(sm2p192test_r_square);
static const u8 sm2p192test_mpinv[] = {
0x2b, 0x73, 0x19, 0x21,
};
TO_EC_STR_PARAM(sm2p192test_mpinv);
static const u8 sm2p192test_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(sm2p192test_p_shift);
static const u8 sm2p192test_p_normalized[] = {
0xbd, 0xb6, 0xf4, 0xfe, 0x3e, 0x8b, 0x1d, 0x9e,
0x0d, 0xa8, 0xc0, 0xd4, 0x6f, 0x4c, 0x31, 0x8c,
0xef, 0xe4, 0xaf, 0xe3, 0xb6, 0xb8, 0x55, 0x1f,
};
TO_EC_STR_PARAM(sm2p192test_p_normalized);
static const u8 sm2p192test_p_reciprocal[] = {
0x59, 0x71, 0xf0, 0x4b,
};
TO_EC_STR_PARAM(sm2p192test_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 sm2p192test_r[] = {
0x42, 0x49, 0x0b, 0x01, 0xc1, 0x74, 0xe2, 0x61,
0xf2, 0x57, 0x3f, 0x2b, 0x90, 0xb3, 0xce, 0x73,
0x10, 0x1b, 0x50, 0x1c, 0x49, 0x47, 0xaa, 0xe1,
};
TO_EC_STR_PARAM(sm2p192test_r);
static const u8 sm2p192test_r_square[] = {
0xa8, 0x9e, 0x36, 0x8f, 0xa3, 0xa3, 0x5f, 0x24,
0x9c, 0xeb, 0x34, 0x38, 0x97, 0x1b, 0x28, 0x1a,
0xab, 0xb1, 0xe2, 0x02, 0xf0, 0x63, 0x41, 0x2c,
};
TO_EC_STR_PARAM(sm2p192test_r_square);
static const u8 sm2p192test_mpinv[] = {
0x19, 0x21,
};
TO_EC_STR_PARAM(sm2p192test_mpinv);
static const u8 sm2p192test_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(sm2p192test_p_shift);
static const u8 sm2p192test_p_normalized[] = {
0xbd, 0xb6, 0xf4, 0xfe, 0x3e, 0x8b, 0x1d, 0x9e,
0x0d, 0xa8, 0xc0, 0xd4, 0x6f, 0x4c, 0x31, 0x8c,
0xef, 0xe4, 0xaf, 0xe3, 0xb6, 0xb8, 0x55, 0x1f,
};
TO_EC_STR_PARAM(sm2p192test_p_normalized);
static const u8 sm2p192test_p_reciprocal[] = {
0x59, 0x71,
};
TO_EC_STR_PARAM(sm2p192test_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 sm2p192test_a[] = {
0xbb, 0x8e, 0x5e, 0x8f, 0xbc, 0x11, 0x5e, 0x13,
0x9f, 0xe6, 0xa8, 0x14, 0xfe, 0x48, 0xaa, 0xa6,
0xf0, 0xad, 0xa1, 0xaa, 0x5d, 0xf9, 0x19, 0x85,
};
TO_EC_STR_PARAM(sm2p192test_a);
static const u8 sm2p192test_b[] = {
0x18, 0x54, 0xbe, 0xbd, 0xc3, 0x1b, 0x21, 0xb7,
0xae, 0xfc, 0x80, 0xab, 0x0e, 0xcd, 0x10, 0xd5,
0xb1, 0xb3, 0x30, 0x8e, 0x6d, 0xbf, 0x11, 0xc1,
};
TO_EC_STR_PARAM(sm2p192test_b);
#define CURVE_SM2P192TEST_CURVE_ORDER_BITLEN 192
static const u8 sm2p192test_curve_order[] = {
0xbd, 0xb6, 0xf4, 0xfe, 0x3e, 0x8b, 0x1d, 0x9e,
0x0d, 0xa8, 0xc0, 0xd4, 0x0f, 0xc9, 0x62, 0x19,
0x5d, 0xfa, 0xe7, 0x6f, 0x56, 0x56, 0x46, 0x77,
};
TO_EC_STR_PARAM(sm2p192test_curve_order);
static const u8 sm2p192test_gx[] = {
0x4a, 0xd5, 0xf7, 0x04, 0x8d, 0xe7, 0x09, 0xad,
0x51, 0x23, 0x6d, 0xe6, 0x5e, 0x4d, 0x4b, 0x48,
0x2c, 0x83, 0x6d, 0xc6, 0xe4, 0x10, 0x66, 0x40,
};
TO_EC_STR_PARAM(sm2p192test_gx);
static const u8 sm2p192test_gy[] = {
0x02, 0xbb, 0x3a, 0x02, 0xd4, 0xaa, 0xad, 0xac,
0xae, 0x24, 0x81, 0x7a, 0x4c, 0xa3, 0xa1, 0xb0,
0x14, 0xb5, 0x27, 0x04, 0x32, 0xdb, 0x27, 0xd2,
};
TO_EC_STR_PARAM(sm2p192test_gy);
static const u8 sm2p192test_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(sm2p192test_gz);
static const u8 sm2p192test_gen_order[] = {
0xbd, 0xb6, 0xf4, 0xfe, 0x3e, 0x8b, 0x1d, 0x9e,
0x0d, 0xa8, 0xc0, 0xd4, 0x0f, 0xc9, 0x62, 0x19,
0x5d, 0xfa, 0xe7, 0x6f, 0x56, 0x56, 0x46, 0x77,
};
TO_EC_STR_PARAM(sm2p192test_gen_order);
#define CURVE_SM2P192TEST_Q_BITLEN 192
static const u8 sm2p192test_gen_order_bitlen[] = {
0xc0,
};
TO_EC_STR_PARAM(sm2p192test_gen_order_bitlen);
static const u8 sm2p192test_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(sm2p192test_cofactor);
static const u8 sm2p192test_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(sm2p192test_alpha_montgomery, 0);
static const u8 sm2p192test_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(sm2p192test_gamma_montgomery, 0);
static const u8 sm2p192test_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(sm2p192test_alpha_edwards, 0);
static const u8 sm2p192test_name[] = "SM2P192TEST";
TO_EC_STR_PARAM(sm2p192test_name);
static const u8 sm2p192test_oid[] = "";
TO_EC_STR_PARAM(sm2p192test_oid);
static const ec_str_params sm2p192test_str_params = {
.p = &sm2p192test_p_str_param,
.p_bitlen = &sm2p192test_p_bitlen_str_param,
.r = &sm2p192test_r_str_param,
.r_square = &sm2p192test_r_square_str_param,
.mpinv = &sm2p192test_mpinv_str_param,
.p_shift = &sm2p192test_p_shift_str_param,
.p_normalized = &sm2p192test_p_normalized_str_param,
.p_reciprocal = &sm2p192test_p_reciprocal_str_param,
.a = &sm2p192test_a_str_param,
.b = &sm2p192test_b_str_param,
.curve_order = &sm2p192test_curve_order_str_param,
.gx = &sm2p192test_gx_str_param,
.gy = &sm2p192test_gy_str_param,
.gz = &sm2p192test_gz_str_param,
.gen_order = &sm2p192test_gen_order_str_param,
.gen_order_bitlen = &sm2p192test_gen_order_bitlen_str_param,
.cofactor = &sm2p192test_cofactor_str_param,
.alpha_montgomery = &sm2p192test_alpha_montgomery_str_param,
.gamma_montgomery = &sm2p192test_gamma_montgomery_str_param,
.alpha_edwards = &sm2p192test_alpha_edwards_str_param,
.oid = &sm2p192test_oid_str_param,
.name = &sm2p192test_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_SM2P192TEST_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_SM2P192TEST_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_SM2P192TEST_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_SM2P192TEST_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_SM2P192TEST_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_SM2P192TEST_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 12)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 12
#endif
#endif /* __EC_PARAMS_SM2P192TEST_H__ */
#endif /* WITH_CURVE_SM2P192TEST */

View file

@ -0,0 +1,349 @@
/*
* Copyright (C) 2021 - This file is part of libecc project
*
* Authors:
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Ryad BENADJILA <ryadbenadjila@gmail.com>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_SM2P256TEST
#ifndef __EC_PARAMS_SM2P256TEST_H__
#define __EC_PARAMS_SM2P256TEST_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 sm2p256test_p[] = {
0x85, 0x42, 0xd6, 0x9e, 0x4c, 0x04, 0x4f, 0x18,
0xe8, 0xb9, 0x24, 0x35, 0xbf, 0x6f, 0xf7, 0xde,
0x45, 0x72, 0x83, 0x91, 0x5c, 0x45, 0x51, 0x7d,
0x72, 0x2e, 0xdb, 0x8b, 0x08, 0xf1, 0xdf, 0xc3,
};
TO_EC_STR_PARAM(sm2p256test_p);
#define CURVE_SM2P256TEST_P_BITLEN 256
static const u8 sm2p256test_p_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(sm2p256test_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 sm2p256test_r[] = {
0x7a, 0xbd, 0x29, 0x61, 0xb3, 0xfb, 0xb0, 0xe7,
0x17, 0x46, 0xdb, 0xca, 0x40, 0x90, 0x08, 0x21,
0xba, 0x8d, 0x7c, 0x6e, 0xa3, 0xba, 0xae, 0x82,
0x8d, 0xd1, 0x24, 0x74, 0xf7, 0x0e, 0x20, 0x3d,
};
TO_EC_STR_PARAM(sm2p256test_r);
static const u8 sm2p256test_r_square[] = {
0x0a, 0xe5, 0x52, 0x29, 0x28, 0x3c, 0xd9, 0x6a,
0xee, 0x4d, 0x87, 0xda, 0x90, 0xd8, 0xc6, 0x6c,
0xeb, 0x37, 0x2d, 0xa8, 0x3f, 0xc9, 0xc6, 0x36,
0x3d, 0x57, 0x9c, 0x46, 0xf6, 0xde, 0x18, 0xf2,
};
TO_EC_STR_PARAM(sm2p256test_r_square);
static const u8 sm2p256test_mpinv[] = {
0xa2, 0xa0, 0x38, 0x0c, 0x50, 0xf7, 0x77, 0x15,
};
TO_EC_STR_PARAM(sm2p256test_mpinv);
static const u8 sm2p256test_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(sm2p256test_p_shift);
static const u8 sm2p256test_p_normalized[] = {
0x85, 0x42, 0xd6, 0x9e, 0x4c, 0x04, 0x4f, 0x18,
0xe8, 0xb9, 0x24, 0x35, 0xbf, 0x6f, 0xf7, 0xde,
0x45, 0x72, 0x83, 0x91, 0x5c, 0x45, 0x51, 0x7d,
0x72, 0x2e, 0xdb, 0x8b, 0x08, 0xf1, 0xdf, 0xc3,
};
TO_EC_STR_PARAM(sm2p256test_p_normalized);
static const u8 sm2p256test_p_reciprocal[] = {
0xeb, 0xc9, 0x56, 0x3c, 0x60, 0x57, 0x6b, 0xb9,
};
TO_EC_STR_PARAM(sm2p256test_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 sm2p256test_r[] = {
0x7a, 0xbd, 0x29, 0x61, 0xb3, 0xfb, 0xb0, 0xe7,
0x17, 0x46, 0xdb, 0xca, 0x40, 0x90, 0x08, 0x21,
0xba, 0x8d, 0x7c, 0x6e, 0xa3, 0xba, 0xae, 0x82,
0x8d, 0xd1, 0x24, 0x74, 0xf7, 0x0e, 0x20, 0x3d,
};
TO_EC_STR_PARAM(sm2p256test_r);
static const u8 sm2p256test_r_square[] = {
0x0a, 0xe5, 0x52, 0x29, 0x28, 0x3c, 0xd9, 0x6a,
0xee, 0x4d, 0x87, 0xda, 0x90, 0xd8, 0xc6, 0x6c,
0xeb, 0x37, 0x2d, 0xa8, 0x3f, 0xc9, 0xc6, 0x36,
0x3d, 0x57, 0x9c, 0x46, 0xf6, 0xde, 0x18, 0xf2,
};
TO_EC_STR_PARAM(sm2p256test_r_square);
static const u8 sm2p256test_mpinv[] = {
0x50, 0xf7, 0x77, 0x15,
};
TO_EC_STR_PARAM(sm2p256test_mpinv);
static const u8 sm2p256test_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(sm2p256test_p_shift);
static const u8 sm2p256test_p_normalized[] = {
0x85, 0x42, 0xd6, 0x9e, 0x4c, 0x04, 0x4f, 0x18,
0xe8, 0xb9, 0x24, 0x35, 0xbf, 0x6f, 0xf7, 0xde,
0x45, 0x72, 0x83, 0x91, 0x5c, 0x45, 0x51, 0x7d,
0x72, 0x2e, 0xdb, 0x8b, 0x08, 0xf1, 0xdf, 0xc3,
};
TO_EC_STR_PARAM(sm2p256test_p_normalized);
static const u8 sm2p256test_p_reciprocal[] = {
0xeb, 0xc9, 0x56, 0x3c,
};
TO_EC_STR_PARAM(sm2p256test_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 sm2p256test_r[] = {
0x7a, 0xbd, 0x29, 0x61, 0xb3, 0xfb, 0xb0, 0xe7,
0x17, 0x46, 0xdb, 0xca, 0x40, 0x90, 0x08, 0x21,
0xba, 0x8d, 0x7c, 0x6e, 0xa3, 0xba, 0xae, 0x82,
0x8d, 0xd1, 0x24, 0x74, 0xf7, 0x0e, 0x20, 0x3d,
};
TO_EC_STR_PARAM(sm2p256test_r);
static const u8 sm2p256test_r_square[] = {
0x0a, 0xe5, 0x52, 0x29, 0x28, 0x3c, 0xd9, 0x6a,
0xee, 0x4d, 0x87, 0xda, 0x90, 0xd8, 0xc6, 0x6c,
0xeb, 0x37, 0x2d, 0xa8, 0x3f, 0xc9, 0xc6, 0x36,
0x3d, 0x57, 0x9c, 0x46, 0xf6, 0xde, 0x18, 0xf2,
};
TO_EC_STR_PARAM(sm2p256test_r_square);
static const u8 sm2p256test_mpinv[] = {
0x77, 0x15,
};
TO_EC_STR_PARAM(sm2p256test_mpinv);
static const u8 sm2p256test_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(sm2p256test_p_shift);
static const u8 sm2p256test_p_normalized[] = {
0x85, 0x42, 0xd6, 0x9e, 0x4c, 0x04, 0x4f, 0x18,
0xe8, 0xb9, 0x24, 0x35, 0xbf, 0x6f, 0xf7, 0xde,
0x45, 0x72, 0x83, 0x91, 0x5c, 0x45, 0x51, 0x7d,
0x72, 0x2e, 0xdb, 0x8b, 0x08, 0xf1, 0xdf, 0xc3,
};
TO_EC_STR_PARAM(sm2p256test_p_normalized);
static const u8 sm2p256test_p_reciprocal[] = {
0xeb, 0xc9,
};
TO_EC_STR_PARAM(sm2p256test_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 sm2p256test_a[] = {
0x78, 0x79, 0x68, 0xb4, 0xfa, 0x32, 0xc3, 0xfd,
0x24, 0x17, 0x84, 0x2e, 0x73, 0xbb, 0xfe, 0xff,
0x2f, 0x3c, 0x84, 0x8b, 0x68, 0x31, 0xd7, 0xe0,
0xec, 0x65, 0x22, 0x8b, 0x39, 0x37, 0xe4, 0x98,
};
TO_EC_STR_PARAM(sm2p256test_a);
static const u8 sm2p256test_b[] = {
0x63, 0xe4, 0xc6, 0xd3, 0xb2, 0x3b, 0x0c, 0x84,
0x9c, 0xf8, 0x42, 0x41, 0x48, 0x4b, 0xfe, 0x48,
0xf6, 0x1d, 0x59, 0xa5, 0xb1, 0x6b, 0xa0, 0x6e,
0x6e, 0x12, 0xd1, 0xda, 0x27, 0xc5, 0x24, 0x9a,
};
TO_EC_STR_PARAM(sm2p256test_b);
#define CURVE_SM2P256TEST_CURVE_ORDER_BITLEN 256
static const u8 sm2p256test_order[] = {
0x85, 0x42, 0xd6, 0x9e, 0x4c, 0x04, 0x4f, 0x18,
0xe8, 0xb9, 0x24, 0x35, 0xbf, 0x6f, 0xf7, 0xdd,
0x29, 0x77, 0x20, 0x63, 0x04, 0x85, 0x62, 0x8d,
0x5a, 0xe7, 0x4e, 0xe7, 0xc3, 0x2e, 0x79, 0xb7,
};
TO_EC_STR_PARAM(sm2p256test_order);
static const u8 sm2p256test_gx[] = {
0x42, 0x1d, 0xeb, 0xd6, 0x1b, 0x62, 0xea, 0xb6,
0x74, 0x64, 0x34, 0xeb, 0xc3, 0xcc, 0x31, 0x5e,
0x32, 0x22, 0x0b, 0x3b, 0xad, 0xd5, 0x0b, 0xdc,
0x4c, 0x4e, 0x6c, 0x14, 0x7f, 0xed, 0xd4, 0x3d,
};
TO_EC_STR_PARAM(sm2p256test_gx);
static const u8 sm2p256test_gy[] = {
0x06, 0x80, 0x51, 0x2b, 0xcb, 0xb4, 0x2c, 0x07,
0xd4, 0x73, 0x49, 0xd2, 0x15, 0x3b, 0x70, 0xc4,
0xe5, 0xd7, 0xfd, 0xfc, 0xbf, 0xa3, 0x6e, 0xa1,
0xa8, 0x58, 0x41, 0xb9, 0xe4, 0x6e, 0x09, 0xa2,
};
TO_EC_STR_PARAM(sm2p256test_gy);
static const u8 sm2p256test_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(sm2p256test_gz);
static const u8 sm2p256test_gen_order[] = {
0x85, 0x42, 0xd6, 0x9e, 0x4c, 0x04, 0x4f, 0x18,
0xe8, 0xb9, 0x24, 0x35, 0xbf, 0x6f, 0xf7, 0xdd,
0x29, 0x77, 0x20, 0x63, 0x04, 0x85, 0x62, 0x8d,
0x5a, 0xe7, 0x4e, 0xe7, 0xc3, 0x2e, 0x79, 0xb7,
};
TO_EC_STR_PARAM(sm2p256test_gen_order);
#define CURVE_SM2P256TEST_Q_BITLEN 256
static const u8 sm2p256test_gen_order_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(sm2p256test_gen_order_bitlen);
static const u8 sm2p256test_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(sm2p256test_cofactor);
static const u8 sm2p256test_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(sm2p256test_alpha_montgomery, 0);
static const u8 sm2p256test_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(sm2p256test_gamma_montgomery, 0);
static const u8 sm2p256test_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(sm2p256test_alpha_edwards, 0);
static const u8 sm2p256test_name[] = "SM2P256TEST";
TO_EC_STR_PARAM(sm2p256test_name);
static const u8 sm2p256test_oid[] = "sm2-iso14888-test-curve";
TO_EC_STR_PARAM(sm2p256test_oid);
static const ec_str_params sm2p256test_str_params = {
.p = &sm2p256test_p_str_param,
.p_bitlen = &sm2p256test_p_bitlen_str_param,
.r = &sm2p256test_r_str_param,
.r_square = &sm2p256test_r_square_str_param,
.mpinv = &sm2p256test_mpinv_str_param,
.p_shift = &sm2p256test_p_shift_str_param,
.p_normalized = &sm2p256test_p_normalized_str_param,
.p_reciprocal = &sm2p256test_p_reciprocal_str_param,
.a = &sm2p256test_a_str_param,
.b = &sm2p256test_b_str_param,
.curve_order = &sm2p256test_order_str_param,
.gx = &sm2p256test_gx_str_param,
.gy = &sm2p256test_gy_str_param,
.gz = &sm2p256test_gz_str_param,
.gen_order = &sm2p256test_gen_order_str_param,
.gen_order_bitlen = &sm2p256test_gen_order_bitlen_str_param,
.cofactor = &sm2p256test_cofactor_str_param,
.alpha_montgomery = &sm2p256test_alpha_montgomery_str_param,
.gamma_montgomery = &sm2p256test_gamma_montgomery_str_param,
.alpha_edwards = &sm2p256test_alpha_edwards_str_param,
.oid = &sm2p256test_oid_str_param,
.name = &sm2p256test_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_SM2P256TEST_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_SM2P256TEST_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_SM2P256TEST_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_SM2P256TEST_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_SM2P256TEST_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_SM2P256TEST_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 24)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 24
#endif
#if (MAX_CURVE_NAME_LEN < 24)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 24
#endif
#endif /* __EC_PARAMS_SM2P256TEST_H__ */
#endif /* WITH_CURVE_SM2P256TEST */

View file

@ -0,0 +1,350 @@
/*
* Copyright (C) 2021 - This file is part of libecc project
*
* Authors:
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Ryad BENADJILA <ryadbenadjila@gmail.com>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_SM2P256V1
#ifndef __EC_PARAMS_SM2P256V1_H__
#define __EC_PARAMS_SM2P256V1_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 sm2p256v1_p[] = {
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
TO_EC_STR_PARAM(sm2p256v1_p);
#define CURVE_SM2P256V1_P_BITLEN 256
static const u8 sm2p256v1_p_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(sm2p256v1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 sm2p256v1_r[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(sm2p256v1_r);
static const u8 sm2p256v1_r_square[] = {
0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x02, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x03,
};
TO_EC_STR_PARAM(sm2p256v1_r_square);
static const u8 sm2p256v1_mpinv[] = {
0x01,
};
TO_EC_STR_PARAM(sm2p256v1_mpinv);
static const u8 sm2p256v1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(sm2p256v1_p_shift);
static const u8 sm2p256v1_p_normalized[] = {
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
TO_EC_STR_PARAM(sm2p256v1_p_normalized);
static const u8 sm2p256v1_p_reciprocal[] = {
0x01, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(sm2p256v1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 sm2p256v1_r[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(sm2p256v1_r);
static const u8 sm2p256v1_r_square[] = {
0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x02, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x03,
};
TO_EC_STR_PARAM(sm2p256v1_r_square);
static const u8 sm2p256v1_mpinv[] = {
0x01,
};
TO_EC_STR_PARAM(sm2p256v1_mpinv);
static const u8 sm2p256v1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(sm2p256v1_p_shift);
static const u8 sm2p256v1_p_normalized[] = {
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
TO_EC_STR_PARAM(sm2p256v1_p_normalized);
static const u8 sm2p256v1_p_reciprocal[] = {
0x01,
};
TO_EC_STR_PARAM(sm2p256v1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 sm2p256v1_r[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(sm2p256v1_r);
static const u8 sm2p256v1_r_square[] = {
0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x02, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x03,
};
TO_EC_STR_PARAM(sm2p256v1_r_square);
static const u8 sm2p256v1_mpinv[] = {
0x01,
};
TO_EC_STR_PARAM(sm2p256v1_mpinv);
static const u8 sm2p256v1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(sm2p256v1_p_shift);
static const u8 sm2p256v1_p_normalized[] = {
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
TO_EC_STR_PARAM(sm2p256v1_p_normalized);
static const u8 sm2p256v1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(sm2p256v1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 sm2p256v1_a[] = {
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc,
};
TO_EC_STR_PARAM(sm2p256v1_a);
static const u8 sm2p256v1_b[] = {
0x28, 0xe9, 0xfa, 0x9e, 0x9d, 0x9f, 0x5e, 0x34,
0x4d, 0x5a, 0x9e, 0x4b, 0xcf, 0x65, 0x09, 0xa7,
0xf3, 0x97, 0x89, 0xf5, 0x15, 0xab, 0x8f, 0x92,
0xdd, 0xbc, 0xbd, 0x41, 0x4d, 0x94, 0x0e, 0x93,
};
TO_EC_STR_PARAM(sm2p256v1_b);
#define CURVE_SM2P256V1_CURVE_ORDER_BITLEN 256
static const u8 sm2p256v1_curve_order[] = {
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x72, 0x03, 0xdf, 0x6b, 0x21, 0xc6, 0x05, 0x2b,
0x53, 0xbb, 0xf4, 0x09, 0x39, 0xd5, 0x41, 0x23,
};
TO_EC_STR_PARAM(sm2p256v1_curve_order);
static const u8 sm2p256v1_gx[] = {
0x32, 0xc4, 0xae, 0x2c, 0x1f, 0x19, 0x81, 0x19,
0x5f, 0x99, 0x04, 0x46, 0x6a, 0x39, 0xc9, 0x94,
0x8f, 0xe3, 0x0b, 0xbf, 0xf2, 0x66, 0x0b, 0xe1,
0x71, 0x5a, 0x45, 0x89, 0x33, 0x4c, 0x74, 0xc7,
};
TO_EC_STR_PARAM(sm2p256v1_gx);
static const u8 sm2p256v1_gy[] = {
0xbc, 0x37, 0x36, 0xa2, 0xf4, 0xf6, 0x77, 0x9c,
0x59, 0xbd, 0xce, 0xe3, 0x6b, 0x69, 0x21, 0x53,
0xd0, 0xa9, 0x87, 0x7c, 0xc6, 0x2a, 0x47, 0x40,
0x02, 0xdf, 0x32, 0xe5, 0x21, 0x39, 0xf0, 0xa0,
};
TO_EC_STR_PARAM(sm2p256v1_gy);
static const u8 sm2p256v1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(sm2p256v1_gz);
static const u8 sm2p256v1_gen_order[] = {
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x72, 0x03, 0xdf, 0x6b, 0x21, 0xc6, 0x05, 0x2b,
0x53, 0xbb, 0xf4, 0x09, 0x39, 0xd5, 0x41, 0x23,
};
TO_EC_STR_PARAM(sm2p256v1_gen_order);
#define CURVE_SM2P256V1_Q_BITLEN 256
static const u8 sm2p256v1_gen_order_bitlen[] = {
0x01, 0x00,
};
TO_EC_STR_PARAM(sm2p256v1_gen_order_bitlen);
static const u8 sm2p256v1_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(sm2p256v1_cofactor);
static const u8 sm2p256v1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(sm2p256v1_alpha_montgomery, 0);
static const u8 sm2p256v1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(sm2p256v1_gamma_montgomery, 0);
static const u8 sm2p256v1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(sm2p256v1_alpha_edwards, 0);
static const u8 sm2p256v1_name[] = "SM2P256V1";
TO_EC_STR_PARAM(sm2p256v1_name);
static const u8 sm2p256v1_oid[] = "1.2.156.10197.1.301";
TO_EC_STR_PARAM(sm2p256v1_oid);
static const ec_str_params sm2p256v1_str_params = {
.p = &sm2p256v1_p_str_param,
.p_bitlen = &sm2p256v1_p_bitlen_str_param,
.r = &sm2p256v1_r_str_param,
.r_square = &sm2p256v1_r_square_str_param,
.mpinv = &sm2p256v1_mpinv_str_param,
.p_shift = &sm2p256v1_p_shift_str_param,
.p_normalized = &sm2p256v1_p_normalized_str_param,
.p_reciprocal = &sm2p256v1_p_reciprocal_str_param,
.a = &sm2p256v1_a_str_param,
.b = &sm2p256v1_b_str_param,
.curve_order = &sm2p256v1_curve_order_str_param,
.gx = &sm2p256v1_gx_str_param,
.gy = &sm2p256v1_gy_str_param,
.gz = &sm2p256v1_gz_str_param,
.gen_order = &sm2p256v1_gen_order_str_param,
.gen_order_bitlen = &sm2p256v1_gen_order_bitlen_str_param,
.cofactor = &sm2p256v1_cofactor_str_param,
.alpha_montgomery = &sm2p256v1_alpha_montgomery_str_param,
.gamma_montgomery = &sm2p256v1_gamma_montgomery_str_param,
.alpha_edwards = &sm2p256v1_alpha_edwards_str_param,
.oid = &sm2p256v1_oid_str_param,
.name = &sm2p256v1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_SM2P256V1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_SM2P256V1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_SM2P256V1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_SM2P256V1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_SM2P256V1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_SM2P256V1_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 21)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 21
#endif
#if (MAX_CURVE_NAME_LEN < 10)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 10
#endif
#endif /* __EC_PARAMS_SM2P256V1_H__ */
#endif /* WITH_CURVE_SM2P256V1 */

View file

@ -0,0 +1,334 @@
/*
* Copyright (C) 2021 - This file is part of libecc project
*
* Authors:
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Ryad BENADJILA <ryadbenadjila@gmail.com>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_WEI25519
#ifndef __EC_PARAMS_WEI25519_H__
#define __EC_PARAMS_WEI25519_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 wei25519_p[] = {
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xed,
};
TO_EC_STR_PARAM(wei25519_p);
#define CURVE_WEI25519_P_BITLEN 255
static const u8 wei25519_p_bitlen[] = {
0xff,
};
TO_EC_STR_PARAM(wei25519_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 wei25519_r[] = {
0x26,
};
TO_EC_STR_PARAM(wei25519_r);
static const u8 wei25519_r_square[] = {
0x05, 0xa4,
};
TO_EC_STR_PARAM(wei25519_r_square);
static const u8 wei25519_mpinv[] = {
0x86, 0xbc, 0xa1, 0xaf, 0x28, 0x6b, 0xca, 0x1b,
};
TO_EC_STR_PARAM(wei25519_mpinv);
static const u8 wei25519_p_shift[] = {
0x01,
};
TO_EC_STR_PARAM(wei25519_p_shift);
static const u8 wei25519_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xda,
};
TO_EC_STR_PARAM(wei25519_p_normalized);
static const u8 wei25519_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(wei25519_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 wei25519_r[] = {
0x26,
};
TO_EC_STR_PARAM(wei25519_r);
static const u8 wei25519_r_square[] = {
0x05, 0xa4,
};
TO_EC_STR_PARAM(wei25519_r_square);
static const u8 wei25519_mpinv[] = {
0x28, 0x6b, 0xca, 0x1b,
};
TO_EC_STR_PARAM(wei25519_mpinv);
static const u8 wei25519_p_shift[] = {
0x01,
};
TO_EC_STR_PARAM(wei25519_p_shift);
static const u8 wei25519_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xda,
};
TO_EC_STR_PARAM(wei25519_p_normalized);
static const u8 wei25519_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(wei25519_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 wei25519_r[] = {
0x26,
};
TO_EC_STR_PARAM(wei25519_r);
static const u8 wei25519_r_square[] = {
0x05, 0xa4,
};
TO_EC_STR_PARAM(wei25519_r_square);
static const u8 wei25519_mpinv[] = {
0xca, 0x1b,
};
TO_EC_STR_PARAM(wei25519_mpinv);
static const u8 wei25519_p_shift[] = {
0x01,
};
TO_EC_STR_PARAM(wei25519_p_shift);
static const u8 wei25519_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xda,
};
TO_EC_STR_PARAM(wei25519_p_normalized);
static const u8 wei25519_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(wei25519_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 wei25519_a[] = {
0x2a, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0x98, 0x49, 0x14, 0xa1, 0x44,
};
TO_EC_STR_PARAM(wei25519_a);
static const u8 wei25519_b[] = {
0x7b, 0x42, 0x5e, 0xd0, 0x97, 0xb4, 0x25, 0xed,
0x09, 0x7b, 0x42, 0x5e, 0xd0, 0x97, 0xb4, 0x25,
0xed, 0x09, 0x7b, 0x42, 0x5e, 0xd0, 0x97, 0xb4,
0x26, 0x0b, 0x5e, 0x9c, 0x77, 0x10, 0xc8, 0x64,
};
TO_EC_STR_PARAM(wei25519_b);
#define CURVE_WEI25519_CURVE_ORDER_BITLEN 256
static const u8 wei25519_curve_order[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xa6, 0xf7, 0xce, 0xf5, 0x17, 0xbc, 0xe6, 0xb2,
0xc0, 0x93, 0x18, 0xd2, 0xe7, 0xae, 0x9f, 0x68,
};
TO_EC_STR_PARAM(wei25519_curve_order);
static const u8 wei25519_gx[] = {
0x2a, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xad, 0x24, 0x5a,
};
TO_EC_STR_PARAM(wei25519_gx);
static const u8 wei25519_gy[] = {
0x20, 0xae, 0x19, 0xa1, 0xb8, 0xa0, 0x86, 0xb4,
0xe0, 0x1e, 0xdd, 0x2c, 0x77, 0x48, 0xd1, 0x4c,
0x92, 0x3d, 0x4d, 0x7e, 0x6d, 0x7c, 0x61, 0xb2,
0x29, 0xe9, 0xc5, 0xa2, 0x7e, 0xce, 0xd3, 0xd9,
};
TO_EC_STR_PARAM(wei25519_gy);
static const u8 wei25519_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(wei25519_gz);
static const u8 wei25519_gen_order[] = {
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x14, 0xde, 0xf9, 0xde, 0xa2, 0xf7, 0x9c, 0xd6,
0x58, 0x12, 0x63, 0x1a, 0x5c, 0xf5, 0xd3, 0xed,
};
TO_EC_STR_PARAM(wei25519_gen_order);
#define CURVE_WEI25519_Q_BITLEN 253
static const u8 wei25519_gen_order_bitlen[] = {
0xfd,
};
TO_EC_STR_PARAM(wei25519_gen_order_bitlen);
static const u8 wei25519_cofactor[] = {
0x08,
};
TO_EC_STR_PARAM(wei25519_cofactor);
static const u8 wei25519_alpha_montgomery[] = {
0x2a, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xad, 0x24, 0x51,
};
TO_EC_STR_PARAM(wei25519_alpha_montgomery);
static const u8 wei25519_gamma_montgomery[] = {
0x01,
};
TO_EC_STR_PARAM(wei25519_gamma_montgomery);
static const u8 wei25519_alpha_edwards[] = {
0x70, 0xd9, 0x12, 0x0b, 0x9f, 0x5f, 0xf9, 0x44,
0x2d, 0x84, 0xf7, 0x23, 0xfc, 0x03, 0xb0, 0x81,
0x3a, 0x5e, 0x2c, 0x2e, 0xb4, 0x82, 0xe5, 0x7d,
0x33, 0x91, 0xfb, 0x55, 0x00, 0xba, 0x81, 0xe7
};
TO_EC_STR_PARAM(wei25519_alpha_edwards);
static const u8 wei25519_name[] = "WEI25519";
TO_EC_STR_PARAM(wei25519_name);
static const u8 wei25519_oid[] = "";
TO_EC_STR_PARAM(wei25519_oid);
static const ec_str_params wei25519_str_params = {
.p = &wei25519_p_str_param,
.p_bitlen = &wei25519_p_bitlen_str_param,
.r = &wei25519_r_str_param,
.r_square = &wei25519_r_square_str_param,
.mpinv = &wei25519_mpinv_str_param,
.p_shift = &wei25519_p_shift_str_param,
.p_normalized = &wei25519_p_normalized_str_param,
.p_reciprocal = &wei25519_p_reciprocal_str_param,
.a = &wei25519_a_str_param,
.b = &wei25519_b_str_param,
.curve_order = &wei25519_curve_order_str_param,
.gx = &wei25519_gx_str_param,
.gy = &wei25519_gy_str_param,
.gz = &wei25519_gz_str_param,
.gen_order = &wei25519_gen_order_str_param,
.gen_order_bitlen = &wei25519_gen_order_bitlen_str_param,
.cofactor = &wei25519_cofactor_str_param,
.alpha_montgomery = &wei25519_alpha_montgomery_str_param,
.gamma_montgomery = &wei25519_gamma_montgomery_str_param,
.alpha_edwards = &wei25519_alpha_edwards_str_param,
.oid = &wei25519_oid_str_param,
.name = &wei25519_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_WEI25519_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_WEI25519_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_WEI25519_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_WEI25519_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_WEI25519_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_WEI25519_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 22)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 22
#endif
#endif /* __EC_PARAMS_WEI25519_H__ */
#endif /* WITH_CURVE_WEI25519 */

View file

@ -0,0 +1,391 @@
/*
* Copyright (C) 2021 - This file is part of libecc project
*
* Authors:
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Ryad BENADJILA <ryadbenadjila@gmail.com>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_CURVE_WEI448
#ifndef __EC_PARAMS_WEI448_H__
#define __EC_PARAMS_WEI448_H__
#include <libecc/curves/known/ec_params_external.h>
static const u8 wei448_p[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
TO_EC_STR_PARAM(wei448_p);
#define CURVE_WEI448_P_BITLEN 448
static const u8 wei448_p_bitlen[] = {
0x01, 0xc0,
};
TO_EC_STR_PARAM(wei448_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 wei448_r[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(wei448_r);
static const u8 wei448_r_square[] = {
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02,
};
TO_EC_STR_PARAM(wei448_r_square);
static const u8 wei448_mpinv[] = {
0x01,
};
TO_EC_STR_PARAM(wei448_mpinv);
static const u8 wei448_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(wei448_p_shift);
static const u8 wei448_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
TO_EC_STR_PARAM(wei448_p_normalized);
static const u8 wei448_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(wei448_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 wei448_r[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(wei448_r);
static const u8 wei448_r_square[] = {
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02,
};
TO_EC_STR_PARAM(wei448_r_square);
static const u8 wei448_mpinv[] = {
0x01,
};
TO_EC_STR_PARAM(wei448_mpinv);
static const u8 wei448_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(wei448_p_shift);
static const u8 wei448_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
TO_EC_STR_PARAM(wei448_p_normalized);
static const u8 wei448_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(wei448_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 wei448_r[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(wei448_r);
static const u8 wei448_r_square[] = {
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02,
};
TO_EC_STR_PARAM(wei448_r_square);
static const u8 wei448_mpinv[] = {
0x01,
};
TO_EC_STR_PARAM(wei448_mpinv);
static const u8 wei448_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(wei448_p_shift);
static const u8 wei448_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
TO_EC_STR_PARAM(wei448_p_normalized);
static const u8 wei448_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(wei448_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 wei448_a[] = {
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xa9, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0x1a, 0x76, 0xd4, 0x1f,
};
TO_EC_STR_PARAM(wei448_a);
static const u8 wei448_b[] = {
0x5e, 0xd0, 0x97, 0xb4, 0x25, 0xed, 0x09, 0x7b,
0x42, 0x5e, 0xd0, 0x97, 0xb4, 0x25, 0xed, 0x09,
0x7b, 0x42, 0x5e, 0xd0, 0x97, 0xb4, 0x25, 0xed,
0x09, 0x7b, 0x42, 0x5e, 0x71, 0xc7, 0x1c, 0x71,
0xc7, 0x1c, 0x71, 0xc7, 0x1c, 0x71, 0xc7, 0x1c,
0x71, 0xc7, 0x1c, 0x71, 0xc7, 0x1c, 0x71, 0xc7,
0x1c, 0x72, 0xc8, 0x7b, 0x7c, 0xc6, 0x9f, 0x70,
};
TO_EC_STR_PARAM(wei448_b);
#define CURVE_WEI448_CURVE_ORDER_BITLEN 448
static const u8 wei448_curve_order[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfd, 0xf3, 0x28, 0x8f, 0xa7,
0x11, 0x3b, 0x6d, 0x26, 0xbb, 0x58, 0xda, 0x40,
0x85, 0xb3, 0x09, 0xca, 0x37, 0x16, 0x3d, 0x54,
0x8d, 0xe3, 0x0a, 0x4a, 0xad, 0x61, 0x13, 0xcc,
};
TO_EC_STR_PARAM(wei448_curve_order);
static const u8 wei448_gx[] = {
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x91,
};
TO_EC_STR_PARAM(wei448_gx);
static const u8 wei448_gy[] = {
0x7d, 0x23, 0x5d, 0x12, 0x95, 0xf5, 0xb1, 0xf6,
0x6c, 0x98, 0xab, 0x6e, 0x58, 0x32, 0x6f, 0xce,
0xcb, 0xae, 0x5d, 0x34, 0xf5, 0x55, 0x45, 0xd0,
0x60, 0xf7, 0x5d, 0xc2, 0x8d, 0xf3, 0xf6, 0xed,
0xb8, 0x02, 0x7e, 0x23, 0x46, 0x43, 0x0d, 0x21,
0x13, 0x12, 0xc4, 0xb1, 0x50, 0x67, 0x7a, 0xf7,
0x6f, 0xd7, 0x22, 0x3d, 0x45, 0x7b, 0x5b, 0x1a,
};
TO_EC_STR_PARAM(wei448_gy);
static const u8 wei448_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(wei448_gz);
static const u8 wei448_gen_order[] = {
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x7c, 0xca, 0x23, 0xe9,
0xc4, 0x4e, 0xdb, 0x49, 0xae, 0xd6, 0x36, 0x90,
0x21, 0x6c, 0xc2, 0x72, 0x8d, 0xc5, 0x8f, 0x55,
0x23, 0x78, 0xc2, 0x92, 0xab, 0x58, 0x44, 0xf3,
};
TO_EC_STR_PARAM(wei448_gen_order);
#define CURVE_WEI448_Q_BITLEN 446
static const u8 wei448_gen_order_bitlen[] = {
0x01, 0xbe,
};
TO_EC_STR_PARAM(wei448_gen_order_bitlen);
static const u8 wei448_cofactor[] = {
0x04,
};
TO_EC_STR_PARAM(wei448_cofactor);
static const u8 wei448_alpha_montgomery[] = {
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x8c,
};
TO_EC_STR_PARAM(wei448_alpha_montgomery);
static const u8 wei448_gamma_montgomery[] = {
0x01,
};
TO_EC_STR_PARAM(wei448_gamma_montgomery);
static const u8 wei448_alpha_edwards[] = {
0x45, 0xb2, 0xc5, 0xf7, 0xd6, 0x49, 0xee, 0xd0,
0x77, 0xed, 0x1a, 0xe4, 0x5f, 0x44, 0xd5, 0x41,
0x43, 0xe3, 0x4f, 0x71, 0x4b, 0x71, 0xaa, 0x96,
0xc9, 0x45, 0xaf, 0x01, 0x2d, 0x18, 0x29, 0x75,
0x07, 0x34, 0xcd, 0xe9, 0xfa, 0xdd, 0xbd, 0xa4,
0xc0, 0x66, 0xf7, 0xed, 0x54, 0x41, 0x9c, 0xa5,
0x2c, 0x85, 0xde, 0x1e, 0x8a, 0xae, 0x4e, 0x6c,
};
TO_EC_STR_PARAM(wei448_alpha_edwards);
static const u8 wei448_name[] = "WEI448";
TO_EC_STR_PARAM(wei448_name);
static const u8 wei448_oid[] = "";
TO_EC_STR_PARAM(wei448_oid);
static const ec_str_params wei448_str_params = {
.p = &wei448_p_str_param,
.p_bitlen = &wei448_p_bitlen_str_param,
.r = &wei448_r_str_param,
.r_square = &wei448_r_square_str_param,
.mpinv = &wei448_mpinv_str_param,
.p_shift = &wei448_p_shift_str_param,
.p_normalized = &wei448_p_normalized_str_param,
.p_reciprocal = &wei448_p_reciprocal_str_param,
.a = &wei448_a_str_param,
.b = &wei448_b_str_param,
.curve_order = &wei448_curve_order_str_param,
.gx = &wei448_gx_str_param,
.gy = &wei448_gy_str_param,
.gz = &wei448_gz_str_param,
.gen_order = &wei448_gen_order_str_param,
.gen_order_bitlen = &wei448_gen_order_bitlen_str_param,
.cofactor = &wei448_cofactor_str_param,
.alpha_montgomery = &wei448_alpha_montgomery_str_param,
.gamma_montgomery = &wei448_gamma_montgomery_str_param,
.alpha_edwards = &wei448_alpha_edwards_str_param,
.oid = &wei448_oid_str_param,
.name = &wei448_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_WEI448_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_WEI448_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_WEI448_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_WEI448_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_WEI448_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_WEI448_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 20)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 20
#endif
#endif /* __EC_PARAMS_WEI448_H__ */
#endif /* WITH_CURVE_WEI448 */

View file

@ -0,0 +1,88 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __PRJ_PT_H__
#define __PRJ_PT_H__
#include <libecc/nn/nn_mul_public.h>
#include <libecc/fp/fp.h>
#include <libecc/fp/fp_mul.h>
#include <libecc/fp/fp_mul_redc1.h>
#include <libecc/curves/ec_shortw.h>
#include <libecc/curves/aff_pt.h>
typedef struct {
fp X;
fp Y;
fp Z;
ec_shortw_crv_src_t crv;
word_t magic;
} prj_pt;
typedef prj_pt *prj_pt_t;
typedef const prj_pt *prj_pt_src_t;
typedef enum {
PUBLIC_PT = 0,
PRIVATE_PT = 1
} prj_pt_sensitivity;
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_check_initialized(prj_pt_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_init(prj_pt_t in, ec_shortw_crv_src_t curve);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_init_from_coords(prj_pt_t in,
ec_shortw_crv_src_t curve,
fp_src_t xcoord,
fp_src_t ycoord, fp_src_t zcoord);
void prj_pt_uninit(prj_pt_t in);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_zero(prj_pt_t out);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_iszero(prj_pt_src_t in, int *iszero);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_is_on_curve(prj_pt_src_t in, int *on_curve);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_copy(prj_pt_t out, prj_pt_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_to_aff(aff_pt_t out, prj_pt_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_unique(prj_pt_t out, prj_pt_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int ec_shortw_aff_to_prj(prj_pt_t out, aff_pt_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_cmp(prj_pt_src_t in1, prj_pt_src_t in2, int *cmp);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_eq_or_opp(prj_pt_src_t in1, prj_pt_src_t in2, int *eq_or_opp);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_neg(prj_pt_t out, prj_pt_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_add(prj_pt_t sum, prj_pt_src_t in1, prj_pt_src_t in2);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_dbl(prj_pt_t dbl, prj_pt_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_mul(prj_pt_t out, nn_src_t m, prj_pt_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_mul_blind(prj_pt_t out, nn_src_t m, prj_pt_src_t in);
/* XXX: WARNING: this function must only be used on public points! */
ATTRIBUTE_WARN_UNUSED_RET int _prj_pt_unprotected_mult(prj_pt_t out, nn_src_t cofactor, prj_pt_src_t public_in);
ATTRIBUTE_WARN_UNUSED_RET int check_prj_pt_order(prj_pt_src_t in_shortw, nn_src_t in_isorder, prj_pt_sensitivity s, int *check);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_import_from_buf(prj_pt_t pt,
const u8 *pt_buf,
u16 pt_buf_len, ec_shortw_crv_src_t crv);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_import_from_aff_buf(prj_pt_t pt,
const u8 *pt_buf,
u16 pt_buf_len, ec_shortw_crv_src_t crv);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_export_to_buf(prj_pt_src_t pt, u8 *pt_buf, u32 pt_buf_len);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_export_to_aff_buf(prj_pt_src_t pt, u8 *pt_buf, u32 pt_buf_len);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_edwards_to_prj_pt_shortw(aff_pt_edwards_src_t in_edwards,
ec_shortw_crv_src_t shortw_crv,
prj_pt_t out_shortw, fp_src_t alpha);
ATTRIBUTE_WARN_UNUSED_RET int aff_pt_montgomery_to_prj_pt_shortw(aff_pt_montgomery_src_t in_montgomery,
ec_shortw_crv_src_t shortw_crv,
prj_pt_t out_shortw);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_shortw_to_aff_pt_edwards(prj_pt_src_t in_shortw,
ec_edwards_crv_src_t edwards_crv,
aff_pt_edwards_t out_edwards,
fp_src_t alpha);
ATTRIBUTE_WARN_UNUSED_RET int prj_pt_shortw_to_aff_pt_montgomery(prj_pt_src_t in_shortw,
ec_montgomery_crv_src_t montgomery_crv,
aff_pt_montgomery_t out_montgomery);
#endif /* __PRJ_PT_H__ */

View file

@ -0,0 +1,63 @@
/*
* Copyright (C) 2021 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#include <libecc/lib_ecc_types.h>
#if defined(WITH_ECCCDH)
#ifndef __ECCCDH_H__
#define __ECCCDH_H__
#include <libecc/curves/curves.h>
#include <libecc/sig/ec_key.h>
#include <libecc/utils/utils.h>
/* Get the size of the shared secret associated to the curve parameters.
*
*/
ATTRIBUTE_WARN_UNUSED_RET int ecccdh_shared_secret_size(const ec_params *params, u8 *size);
/* Get the size of the serialized public key associated to the curve parameters.
*
*/
ATTRIBUTE_WARN_UNUSED_RET int ecccdh_serialized_pub_key_size(const ec_params *params, u8 *size);
/* Initialize ECCCDH public key from an initialized private key.
*
*/
ATTRIBUTE_WARN_UNUSED_RET int ecccdh_init_pub_key(ec_pub_key *out_pub, const ec_priv_key *in_priv);
/* Generate a key pair for ECCCDH given curve parameters as input.
*
*/
ATTRIBUTE_WARN_UNUSED_RET int ecccdh_gen_key_pair(ec_key_pair *kp, const ec_params *params);
/* Create a key pair from a serialized private key.
*
*/
ATTRIBUTE_WARN_UNUSED_RET int ecccdh_import_key_pair_from_priv_key_buf(ec_key_pair *kp, const ec_params *params, const u8 *priv_key_buf, u8 priv_key_buf_len);
/* Serialize our public key in a buffer.
*
*/
ATTRIBUTE_WARN_UNUSED_RET int ecccdh_serialize_pub_key(const ec_pub_key *our_pub_key, u8 *buff, u8 buff_len);
/* Derive the ECCCDH shared secret and store it in a buffer given the peer
* public key and our private key.
*
* The shared_secret_len length MUST be exactly equal to the expected shared secret size:
* the function fails otherwise.
*/
ATTRIBUTE_WARN_UNUSED_RET int ecccdh_derive_secret(const ec_priv_key *our_priv_key, const u8 *peer_pub_key, u8 peer_pub_key_len, u8 *shared_secret, u8 shared_secret_len);
#endif /* __ECCCDH_H__ */
#endif /* WITH_ECCCDH */

View file

@ -0,0 +1,21 @@
/*
* Copyright (C) 2021 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#include <libecc/lib_ecc_types.h>
#ifndef __ECDH_H__
#define __ECDH_H__
#include <libecc/ecdh/ecccdh.h>
#include <libecc/ecdh/x25519_448.h>
#endif /* __ECDH_H__ */

View file

@ -0,0 +1,62 @@
/*
* Copyright (C) 2021 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#include <libecc/lib_ecc_types.h>
#if defined(WITH_X25519) || defined(WITH_X448)
#ifndef __X25519_448_H__
#define __X25519_448_H__
#include <libecc/words/words.h>
/* Size of X25519 values */
#define X25519_SIZE 32
/* Size of X448 values */
#define X448_SIZE 56
#if defined(WITH_X25519)
/* The X25519 function as specified in RFC7748.
*
* NOTE: the user of this primitive should be warned and aware that is is not fully compliant with the
* RFC7748 description as u coordinates on the quadratic twist of the curve are rejected as well as non
* canonical u.
* See the explanations in the implementation of the function for more context and explanations.
*/
ATTRIBUTE_WARN_UNUSED_RET int x25519(const u8 k[X25519_SIZE], const u8 u[X25519_SIZE], u8 res[X25519_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int x25519_gen_priv_key(u8 priv_key[X25519_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int x25519_init_pub_key(const u8 priv_key[X25519_SIZE], u8 pub_key[X25519_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int x25519_derive_secret(const u8 priv_key[X25519_SIZE], const u8 peer_pub_key[X25519_SIZE], u8 shared_secret[X25519_SIZE]);
#endif
#if defined(WITH_X448)
/* The X448 function as specified in RFC7748.
*
* NOTE: the user of this primitive should be warned and aware that is is not fully compliant with the
* RFC7748 description as u coordinates on the quadratic twist of the curve are rejected as well as non
* canonical u.
* See the explanations in the implementation of the function for more context and explanations.
*/
ATTRIBUTE_WARN_UNUSED_RET int x448(const u8 k[X448_SIZE], const u8 u[X448_SIZE], u8 res[X448_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int x448_gen_priv_key(u8 priv_key[X448_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int x448_init_pub_key(const u8 priv_key[X448_SIZE], u8 pub_key[X448_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int x448_derive_secret(const u8 priv_key[X448_SIZE], const u8 peer_pub_key[X448_SIZE], u8 shared_secret[X448_SIZE]);
#endif
#endif /* __X25519_448_H__ */
#endif /* defined(WITH_X25519) || defined(WITH_X448) */

View file

@ -0,0 +1,34 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __PRINT_H__
#define __PRINT_H__
/* Explicitly include the inttypes here */
#ifdef WITH_STDLIB
/* We include inttypes.h for the PRI* macros */
#include <inttypes.h>
#endif
#if (__GNUC__ * 10 + __GNUC_MINOR__ >= 42)
#define LIBECC_FORMAT_FUNCTION(F,A) __attribute__((format(__printf__, F, A)))
#else
#define LIBECC_FORMAT_FUNCTION(F,A)
#endif
LIBECC_FORMAT_FUNCTION(1, 2)
void ext_printf(const char *format, ...);
#endif /* __PRINT_H__ */

View file

@ -0,0 +1,22 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __RAND_H__
#define __RAND_H__
#include <libecc/words/words.h>
ATTRIBUTE_WARN_UNUSED_RET int get_random(unsigned char *buf, u16 len);
#endif /* __RAND_H__ */

View file

@ -0,0 +1,23 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __TIME_H__
#define __TIME_H__
#include <libecc/words/words.h>
ATTRIBUTE_WARN_UNUSED_RET int get_ms_time(u64 *time);
#endif /* __TIME_H__ */

View file

@ -0,0 +1,98 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __FP_H__
#define __FP_H__
#include <libecc/nn/nn.h>
#include <libecc/nn/nn_div_public.h>
#include <libecc/nn/nn_modinv.h>
#include <libecc/nn/nn_mul_public.h>
#include <libecc/nn/nn_mul_redc1.h>
#include <libecc/fp/fp_config.h>
/*
* First, definition of our Fp context, containing all the elements
* needed to efficiently implement Fp operations.
*/
typedef struct {
/*
* Value of p (extended by one word to handle
* overflows in Fp). p_bitlen provides its
* length in bit.
*/
nn p;
bitcnt_t p_bitlen;
/* -p^-1 mod 2^(bitsizeof(word_t)) */
word_t mpinv;
/* 2^bitsizeof(p) mod p */
nn r;
/* 2^(2*bitsizeof(p)) mod p */
nn r_square;
/* clz(p) */
bitcnt_t p_shift;
/* p << p_shift */
nn p_normalized;
/* floor(B^3/(DMSW(p_normalized) + 1)) - B */
word_t p_reciprocal;
word_t magic;
} fp_ctx;
typedef fp_ctx *fp_ctx_t;
typedef const fp_ctx *fp_ctx_src_t;
ATTRIBUTE_WARN_UNUSED_RET int fp_ctx_check_initialized(fp_ctx_src_t ctx);
ATTRIBUTE_WARN_UNUSED_RET int fp_ctx_init(fp_ctx_t ctx, nn_src_t p, bitcnt_t p_bitlen,
nn_src_t r, nn_src_t r_square,
word_t mpinv,
bitcnt_t p_shift, nn_src_t p_normalized, word_t p_reciprocal);
ATTRIBUTE_WARN_UNUSED_RET int fp_ctx_init_from_p(fp_ctx_t ctx, nn_src_t p);
/*
* Then the definition of our Fp elements
*/
typedef struct {
nn fp_val;
fp_ctx_src_t ctx;
word_t magic;
} fp;
typedef fp *fp_t;
typedef const fp *fp_src_t;
ATTRIBUTE_WARN_UNUSED_RET int fp_check_initialized(fp_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int fp_init(fp_t A, fp_ctx_src_t fpctx);
ATTRIBUTE_WARN_UNUSED_RET int fp_init_from_buf(fp_t A, fp_ctx_src_t fpctx, const u8 *buf, u16 buflen);
void fp_uninit(fp_t A);
ATTRIBUTE_WARN_UNUSED_RET int fp_set_nn(fp_t out, nn_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int fp_zero(fp_t out);
ATTRIBUTE_WARN_UNUSED_RET int fp_one(fp_t out);
ATTRIBUTE_WARN_UNUSED_RET int fp_set_word_value(fp_t out, word_t val);
ATTRIBUTE_WARN_UNUSED_RET int fp_cmp(fp_src_t in1, fp_src_t in2, int *cmp);
ATTRIBUTE_WARN_UNUSED_RET int fp_iszero(fp_src_t in, int *iszero);
ATTRIBUTE_WARN_UNUSED_RET int fp_copy(fp_t out, fp_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int fp_tabselect(fp_t out, u8 idx, fp_src_t *tab, u8 tabsize);
ATTRIBUTE_WARN_UNUSED_RET int fp_eq_or_opp(fp_src_t in1, fp_src_t in2, int *eq_or_opp);
ATTRIBUTE_WARN_UNUSED_RET int fp_import_from_buf(fp_t out_fp, const u8 *buf, u16 buflen);
ATTRIBUTE_WARN_UNUSED_RET int fp_export_to_buf(u8 *buf, u16 buflen, fp_src_t in_fp);
#endif /* __FP_H__ */

View file

@ -0,0 +1,26 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __FP_ADD_H__
#define __FP_ADD_H__
#include <libecc/fp/fp.h>
ATTRIBUTE_WARN_UNUSED_RET int fp_add(fp_t out, fp_src_t in1, fp_src_t in2);
ATTRIBUTE_WARN_UNUSED_RET int fp_inc(fp_t out, fp_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int fp_sub(fp_t out, fp_src_t in1, fp_src_t in2);
ATTRIBUTE_WARN_UNUSED_RET int fp_dec(fp_t out, fp_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int fp_neg(fp_t out, fp_src_t in);
#endif /* __FP_ADD_H__ */

View file

@ -0,0 +1,25 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __FP_CONFIG_H__
#define __FP_CONFIG_H__
#include <libecc/nn/nn_config.h>
#ifndef FP_MAX_BIT_LEN
#define FP_MAX_BIT_LEN (NN_MAX_BIT_LEN - 1)
#endif
#endif /* __FP_CONFIG_H__ */

View file

@ -0,0 +1,30 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __FP_MONTGOMERY_H__
#define __FP_MONTGOMERY_H__
#include <libecc/fp/fp.h>
#include <libecc/fp/fp_add.h>
#include <libecc/fp/fp_mul.h>
#include <libecc/fp/fp_mul_redc1.h>
ATTRIBUTE_WARN_UNUSED_RET int fp_add_monty(fp_t out, fp_src_t in1, fp_src_t in2);
ATTRIBUTE_WARN_UNUSED_RET int fp_sub_monty(fp_t out, fp_src_t in1, fp_src_t in2);
ATTRIBUTE_WARN_UNUSED_RET int fp_mul_monty(fp_t out, fp_src_t in1, fp_src_t in2);
ATTRIBUTE_WARN_UNUSED_RET int fp_sqr_monty(fp_t out, fp_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int fp_div_monty(fp_t out, fp_src_t in1, fp_src_t in2);
#endif /* __FP_MONTGOMERY_H__ */

View file

@ -0,0 +1,26 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __FP_MUL_H__
#define __FP_MUL_H__
#include <libecc/fp/fp.h>
ATTRIBUTE_WARN_UNUSED_RET int fp_mul(fp_t out, fp_src_t in1, fp_src_t in2);
ATTRIBUTE_WARN_UNUSED_RET int fp_sqr(fp_t out, fp_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int fp_inv(fp_t out, fp_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int fp_inv_word(fp_t out, word_t w);
ATTRIBUTE_WARN_UNUSED_RET int fp_div(fp_t out, fp_src_t num, fp_src_t den);
#endif /* __FP_MUL_H__ */

View file

@ -0,0 +1,25 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __FP_MUL_REDC1_H__
#define __FP_MUL_REDC1_H__
#include <libecc/fp/fp.h>
ATTRIBUTE_WARN_UNUSED_RET int fp_mul_redc1(fp_t out, fp_src_t in1, fp_src_t in2);
ATTRIBUTE_WARN_UNUSED_RET int fp_sqr_redc1(fp_t out, fp_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int fp_redcify(fp_t out, fp_src_t in);
ATTRIBUTE_WARN_UNUSED_RET int fp_unredcify(fp_t out, fp_src_t in);
#endif /* __FP_MUL_REDC1_H__ */

View file

@ -0,0 +1,22 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __FP_POW_H__
#define __FP_POW_H__
#include <libecc/fp/fp.h>
ATTRIBUTE_WARN_UNUSED_RET int fp_pow(fp_t out, fp_src_t base, nn_src_t exp);
#endif /* __FP_POW_H__ */

View file

@ -0,0 +1,22 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __FP_RAND_H__
#define __FP_RAND_H__
#include <libecc/fp/fp.h>
ATTRIBUTE_WARN_UNUSED_RET int fp_get_random(fp_t out, fp_ctx_src_t ctx);
#endif /* __FP_RAND_H__ */

View file

@ -0,0 +1,25 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __FP_SQRT_H__
#define __FP_SQRT_H__
#include <libecc/fp/fp.h>
#include <libecc/fp/fp_add.h>
#include <libecc/fp/fp_mul.h>
#include <libecc/fp/fp_pow.h>
ATTRIBUTE_WARN_UNUSED_RET int fp_sqrt(fp_t sqrt1, fp_t sqrt2, fp_src_t n);
#endif /* __FP_SQRT_H__ */

View file

@ -0,0 +1,162 @@
/*
* Copyright (C) 2022 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __BASH_H__
#define __BASH_H__
#include <libecc/words/words.h>
/*
* This is an implementation of the BASH hash functions family (for sizes 224, 256, 384 and 512)
* following the standard STB 34.101.77-2020 (http://apmi.bsu.by/assets/files/std/bash-spec24.pdf).
* An english version of the specifications exist here: https://eprint.iacr.org/2016/587.pdf
*/
#define _BASH_ROTHI_(x, y) (((x) << (y)) | ((x) >> ((sizeof(u64) * 8) - (y))))
/* We handle the case where one of the shifts is more than 64-bit: in this
* case, behaviour is undefined as per ANSI C definition. In this case, we
* return the untouched input.
*/
#define BASH_ROTHI(x, y) ((((y) < (sizeof(u64) * 8)) && ((y) > 0)) ? (_BASH_ROTHI_(x, y)) : (x))
/*
* Round transformation of the state. Notations are the
* same as the ones used in:
* https://eprint.iacr.org/2016/587.pdf
*/
#define BASH_SLICES_X 3
#define BASH_SLICES_Y 8
#define BASH_ROT_ROUNDS 8
#define BASH_ROT_IDX 4
#define BASH_ROUNDS 24
#define BASH_L3_S3(W0, W1, W2, m1, n1, m2, n2) do { \
u64 T0, T1, T2; \
T0 = BASH_ROTHI(W0, m1); \
W0 = (W0 ^ W1 ^ W2); \
T1 = (W1 ^ BASH_ROTHI(W0, n1)); \
W1 = (T0 ^ T1); \
W2 = (W2 ^ BASH_ROTHI(W2, m2) ^ BASH_ROTHI(T1, n2)); \
T0 = (~(W2)); \
T1 = (W0 | W2); \
T2 = (W0 & W1); \
T0 = (T0 | W1); \
W1 = (W1 ^ T1); \
W2 = (W2 ^ T2); \
W0 = (W0 ^ T0); \
} while(0)
#define BASH_PERMUTE(S) do { \
u64 S_[BASH_SLICES_X * BASH_SLICES_Y]; \
IGNORE_RET_VAL(local_memcpy(S_, S, sizeof(S_))); \
S[ 0] = S_[15]; S[ 1] = S_[10]; S[ 2] = S_[ 9]; S[ 3] = S_[12]; \
S[ 4] = S_[11]; S[ 5] = S_[14]; S[ 6] = S_[13]; S[ 7] = S_[ 8]; \
S[ 8] = S_[17]; S[ 9] = S_[16]; S[10] = S_[19]; S[11] = S_[18]; \
S[12] = S_[21]; S[13] = S_[20]; S[14] = S_[23]; S[15] = S_[22]; \
S[16] = S_[ 6]; S[17] = S_[ 3]; S[18] = S_[ 0]; S[19] = S_[ 5]; \
S[20] = S_[ 2]; S[21] = S_[ 7]; S[22] = S_[ 4]; S[23] = S_[ 1]; \
} while(0)
static const u64 bash_rc[BASH_ROUNDS] =
{
0x3bf5080ac8ba94b1ULL,
0xc1d1659c1bbd92f6ULL,
0x60e8b2ce0ddec97bULL,
0xec5fb8fe790fbc13ULL,
0xaa043de6436706a7ULL,
0x8929ff6a5e535bfdULL,
0x98bf1e2c50c97550ULL,
0x4c5f8f162864baa8ULL,
0x262fc78b14325d54ULL,
0x1317e3c58a192eaaULL,
0x098bf1e2c50c9755ULL,
0xd8ee19681d669304ULL,
0x6c770cb40eb34982ULL,
0x363b865a0759a4c1ULL,
0xc73622b47c4c0aceULL,
0x639b115a3e260567ULL,
0xede6693460f3da1dULL,
0xaad8d5034f9935a0ULL,
0x556c6a81a7cc9ad0ULL,
0x2ab63540d3e64d68ULL,
0x155b1aa069f326b4ULL,
0x0aad8d5034f9935aULL,
0x0556c6a81a7cc9adULL,
0xde8082cd72debc78ULL,
};
static const u8 bash_rot[BASH_ROT_ROUNDS][BASH_ROT_IDX] =
{
{ 8, 53, 14, 1 },
{ 56, 51, 34, 7 },
{ 8, 37, 46, 49 },
{ 56, 3, 2, 23 },
{ 8, 21, 14, 33 },
{ 56, 19, 34, 39 },
{ 8, 5, 46, 17 },
{ 56, 35, 2, 55 },
};
/* Macro to handle endianness conversion */
#define SWAP64(A) do { \
A = ((A) << 56 | ((A) & 0xff00) << 40 | ((A) & 0xff0000) << 24 | \
((A) & 0xff000000) << 8 | ((A) >> 8 & 0xff000000) | \
((A) >> 24 & 0xff0000) | ((A) >> 40 & 0xff00) | (A) >> 56); \
} while(0)
/* The main Bash-f core as descibed in the specification. */
#define BASHF(S, end) do { \
unsigned int round, i; \
/* Swap endianness if necessary */ \
if(end == BASH_BIG){ \
for(i = 0; i < (BASH_SLICES_X * BASH_SLICES_Y); i++){ \
SWAP64(S[i]); \
} \
} \
for(round = 0; round < BASH_ROUNDS; round++){ \
unsigned int v; \
for(v = 0; v < 8; v++){ \
BASH_L3_S3(S[v], S[v+8], S[v+16], bash_rot[v][0], bash_rot[v][1], \
bash_rot[v][2], bash_rot[v][3]); \
} \
BASH_PERMUTE(S); \
S[23] ^= bash_rc[round]; \
} \
/* Swap back endianness if necessary */ \
if(end == BASH_BIG){ \
for(i = 0; i < (BASH_SLICES_X * BASH_SLICES_Y); i++){ \
SWAP64(S[i]); \
} \
} \
} while(0)
typedef enum {
BASH_LITTLE = 0,
BASH_BIG = 1,
} bash_endianness;
typedef struct bash_context_ {
u8 bash_digest_size;
u8 bash_block_size;
bash_endianness bash_endian;
/* Local counter */
u64 bash_total;
/* Bash state */
u64 bash_state[BASH_SLICES_X * BASH_SLICES_Y];
/* Initialization magic value */
u64 magic;
} bash_context;
ATTRIBUTE_WARN_UNUSED_RET int _bash_init(bash_context *ctx, uint8_t digest_size);
ATTRIBUTE_WARN_UNUSED_RET int _bash_update(bash_context *ctx, const uint8_t *buf, uint32_t buflen);
ATTRIBUTE_WARN_UNUSED_RET int _bash_finalize(bash_context *ctx, uint8_t *output);
#endif /* __BASH_H__ */

View file

@ -0,0 +1,64 @@
/*
* Copyright (C) 2022 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_HASH_BASH224
#ifndef __BASH224_H__
#define __BASH224_H__
#include <libecc/words/words.h>
#include <libecc/utils/utils.h>
#include <libecc/hash/bash.h>
#define BASH224_BLOCK_SIZE 136
#define BASH224_DIGEST_SIZE 28
#define BASH224_DIGEST_SIZE_BITS 224
/* Compute max hash digest and block sizes */
#ifndef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE 0
#endif
#if (MAX_DIGEST_SIZE < BASH224_DIGEST_SIZE)
#undef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE BASH224_DIGEST_SIZE
#endif
#ifndef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS 0
#endif
#if (MAX_DIGEST_SIZE_BITS < BASH224_DIGEST_SIZE_BITS)
#undef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS BASH224_DIGEST_SIZE_BITS
#endif
#ifndef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE 0
#endif
#if (MAX_BLOCK_SIZE < BASH224_BLOCK_SIZE)
#undef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE BASH224_BLOCK_SIZE
#endif
#define BASH224_HASH_MAGIC ((word_t)(0xaf3456ff1200ba5bULL))
#define BASH224_HASH_CHECK_INITIALIZED(A, ret, err) \
MUST_HAVE((((void *)(A)) != NULL) && ((A)->magic == BASH224_HASH_MAGIC), ret, err)
typedef bash_context bash224_context;
ATTRIBUTE_WARN_UNUSED_RET int bash224_init(bash224_context *ctx);
ATTRIBUTE_WARN_UNUSED_RET int bash224_update(bash224_context *ctx, const u8 *input, u32 ilen);
ATTRIBUTE_WARN_UNUSED_RET int bash224_final(bash224_context *ctx, u8 output[BASH224_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int bash224_scattered(const u8 **inputs, const u32 *ilens,
u8 output[BASH224_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int bash224(const u8 *input, u32 ilen, u8 output[BASH224_DIGEST_SIZE]);
#endif /* __BASH224_H__ */
#endif /* WITH_HASH_BASH224 */

View file

@ -0,0 +1,64 @@
/*
* Copyright (C) 2022 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_HASH_BASH256
#ifndef __BASH256_H__
#define __BASH256_H__
#include <libecc/words/words.h>
#include <libecc/utils/utils.h>
#include <libecc/hash/bash.h>
#define BASH256_BLOCK_SIZE 128
#define BASH256_DIGEST_SIZE 32
#define BASH256_DIGEST_SIZE_BITS 256
/* Compute max hash digest and block sizes */
#ifndef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE 0
#endif
#if (MAX_DIGEST_SIZE < BASH256_DIGEST_SIZE)
#undef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE BASH256_DIGEST_SIZE
#endif
#ifndef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS 0
#endif
#if (MAX_DIGEST_SIZE_BITS < BASH256_DIGEST_SIZE_BITS)
#undef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS BASH256_DIGEST_SIZE_BITS
#endif
#ifndef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE 0
#endif
#if (MAX_BLOCK_SIZE < BASH256_BLOCK_SIZE)
#undef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE BASH256_BLOCK_SIZE
#endif
#define BASH256_HASH_MAGIC ((word_t)(0x72839273873434aaULL))
#define BASH256_HASH_CHECK_INITIALIZED(A, ret, err) \
MUST_HAVE((((void *)(A)) != NULL) && ((A)->magic == BASH256_HASH_MAGIC), ret, err)
typedef bash_context bash256_context;
ATTRIBUTE_WARN_UNUSED_RET int bash256_init(bash256_context *ctx);
ATTRIBUTE_WARN_UNUSED_RET int bash256_update(bash256_context *ctx, const u8 *input, u32 ilen);
ATTRIBUTE_WARN_UNUSED_RET int bash256_final(bash256_context *ctx, u8 output[BASH256_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int bash256_scattered(const u8 **inputs, const u32 *ilens,
u8 output[BASH256_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int bash256(const u8 *input, u32 ilen, u8 output[BASH256_DIGEST_SIZE]);
#endif /* __BASH256_H__ */
#endif /* WITH_HASH_BASH256 */

View file

@ -0,0 +1,64 @@
/*
* Copyright (C) 2022 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_HASH_BASH384
#ifndef __BASH384_H__
#define __BASH384_H__
#include <libecc/words/words.h>
#include <libecc/utils/utils.h>
#include <libecc/hash/bash.h>
#define BASH384_BLOCK_SIZE 96
#define BASH384_DIGEST_SIZE 48
#define BASH384_DIGEST_SIZE_BITS 384
/* Compute max hash digest and block sizes */
#ifndef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE 0
#endif
#if (MAX_DIGEST_SIZE < BASH384_DIGEST_SIZE)
#undef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE BASH384_DIGEST_SIZE
#endif
#ifndef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS 0
#endif
#if (MAX_DIGEST_SIZE_BITS < BASH384_DIGEST_SIZE_BITS)
#undef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS BASH384_DIGEST_SIZE_BITS
#endif
#ifndef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE 0
#endif
#if (MAX_BLOCK_SIZE < BASH384_BLOCK_SIZE)
#undef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE BASH384_BLOCK_SIZE
#endif
#define BASH384_HASH_MAGIC ((word_t)(0x391af28773938752ULL))
#define BASH384_HASH_CHECK_INITIALIZED(A, ret, err) \
MUST_HAVE((((void *)(A)) != NULL) && ((A)->magic == BASH384_HASH_MAGIC), ret, err)
typedef bash_context bash384_context;
ATTRIBUTE_WARN_UNUSED_RET int bash384_init(bash384_context *ctx);
ATTRIBUTE_WARN_UNUSED_RET int bash384_update(bash384_context *ctx, const u8 *input, u32 ilen);
ATTRIBUTE_WARN_UNUSED_RET int bash384_final(bash384_context *ctx, u8 output[BASH384_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int bash384_scattered(const u8 **inputs, const u32 *ilens,
u8 output[BASH384_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int bash384(const u8 *input, u32 ilen, u8 output[BASH384_DIGEST_SIZE]);
#endif /* __BASH384_H__ */
#endif /* WITH_HASH_BASH384 */

View file

@ -0,0 +1,64 @@
/*
* Copyright (C) 2022 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_HASH_BASH512
#ifndef __BASH512_H__
#define __BASH512_H__
#include <libecc/words/words.h>
#include <libecc/utils/utils.h>
#include <libecc/hash/bash.h>
#define BASH512_BLOCK_SIZE 64
#define BASH512_DIGEST_SIZE 64
#define BASH512_DIGEST_SIZE_BITS 512
/* Compute max hash digest and block sizes */
#ifndef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE 0
#endif
#if (MAX_DIGEST_SIZE < BASH512_DIGEST_SIZE)
#undef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE BASH512_DIGEST_SIZE
#endif
#ifndef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS 0
#endif
#if (MAX_DIGEST_SIZE_BITS < BASH512_DIGEST_SIZE_BITS)
#undef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS BASH512_DIGEST_SIZE_BITS
#endif
#ifndef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE 0
#endif
#if (MAX_BLOCK_SIZE < BASH512_BLOCK_SIZE)
#undef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE BASH512_BLOCK_SIZE
#endif
#define BASH512_HASH_MAGIC ((word_t)(0xcd12faec63111283ULL))
#define BASH512_HASH_CHECK_INITIALIZED(A, ret, err) \
MUST_HAVE((((void *)(A)) != NULL) && ((A)->magic == BASH512_HASH_MAGIC), ret, err)
typedef bash_context bash512_context;
ATTRIBUTE_WARN_UNUSED_RET int bash512_init(bash512_context *ctx);
ATTRIBUTE_WARN_UNUSED_RET int bash512_update(bash512_context *ctx, const u8 *input, u32 ilen);
ATTRIBUTE_WARN_UNUSED_RET int bash512_final(bash512_context *ctx, u8 output[BASH512_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int bash512_scattered(const u8 **inputs, const u32 *ilens,
u8 output[BASH512_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int bash512(const u8 *input, u32 ilen, u8 output[BASH512_DIGEST_SIZE]);
#endif /* __BASH512_H__ */
#endif /* WITH_HASH_BASH512 */

View file

@ -0,0 +1,164 @@
/*
* Copyright (C) 2022 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_HASH_BELT_HASH
#ifndef __BELT_HASH_H__
#define __BELT_HASH_H__
#include <libecc/words/words.h>
#include <libecc/utils/utils.h>
/*
* 32-bit integer manipulation macros
*/
#ifndef GET_UINT32_LE
#define GET_UINT32_LE(n, b, i) \
do { \
(n) = ( ((u32) (b)[(i) + 3]) << 24 ) \
| ( ((u32) (b)[(i) + 2]) << 16 ) \
| ( ((u32) (b)[(i) + 1]) << 8 ) \
| ( ((u32) (b)[(i) ]) ); \
} while( 0 )
#endif
#ifndef PUT_UINT32_LE
#define PUT_UINT32_LE(n, b, i) \
do { \
(b)[(i) + 3] = (u8) ( (n) >> 24 ); \
(b)[(i) + 2] = (u8) ( (n) >> 16 ); \
(b)[(i) + 1] = (u8) ( (n) >> 8 ); \
(b)[(i) ] = (u8) ( (n) ); \
} while( 0 )
#endif
/*
* 64-bit integer manipulation macros
*/
#ifndef GET_UINT64_BE
#define GET_UINT64_BE(n,b,i) \
do { \
(n) = ( ((u64) (b)[(i) ]) << 56 ) \
| ( ((u64) (b)[(i) + 1]) << 48 ) \
| ( ((u64) (b)[(i) + 2]) << 40 ) \
| ( ((u64) (b)[(i) + 3]) << 32 ) \
| ( ((u64) (b)[(i) + 4]) << 24 ) \
| ( ((u64) (b)[(i) + 5]) << 16 ) \
| ( ((u64) (b)[(i) + 6]) << 8 ) \
| ( ((u64) (b)[(i) + 7]) ); \
} while( 0 )
#endif /* GET_UINT64_BE */
#ifndef PUT_UINT64_BE
#define PUT_UINT64_BE(n,b,i) \
do { \
(b)[(i) ] = (u8) ( (n) >> 56 ); \
(b)[(i) + 1] = (u8) ( (n) >> 48 ); \
(b)[(i) + 2] = (u8) ( (n) >> 40 ); \
(b)[(i) + 3] = (u8) ( (n) >> 32 ); \
(b)[(i) + 4] = (u8) ( (n) >> 24 ); \
(b)[(i) + 5] = (u8) ( (n) >> 16 ); \
(b)[(i) + 6] = (u8) ( (n) >> 8 ); \
(b)[(i) + 7] = (u8) ( (n) ); \
} while( 0 )
#endif /* PUT_UINT64_BE */
#ifndef GET_UINT64_LE
#define GET_UINT64_LE(n,b,i) \
do { \
(n) = ( ((u64) (b)[(i) + 7]) << 56 ) \
| ( ((u64) (b)[(i) + 6]) << 48 ) \
| ( ((u64) (b)[(i) + 5]) << 40 ) \
| ( ((u64) (b)[(i) + 4]) << 32 ) \
| ( ((u64) (b)[(i) + 3]) << 24 ) \
| ( ((u64) (b)[(i) + 2]) << 16 ) \
| ( ((u64) (b)[(i) + 1]) << 8 ) \
| ( ((u64) (b)[(i) ]) ); \
} while( 0 )
#endif /* GET_UINT64_LE */
#ifndef PUT_UINT64_LE
#define PUT_UINT64_LE(n,b,i) \
do { \
(b)[(i) + 7] = (u8) ( (n) >> 56 ); \
(b)[(i) + 6] = (u8) ( (n) >> 48 ); \
(b)[(i) + 5] = (u8) ( (n) >> 40 ); \
(b)[(i) + 4] = (u8) ( (n) >> 32 ); \
(b)[(i) + 3] = (u8) ( (n) >> 24 ); \
(b)[(i) + 2] = (u8) ( (n) >> 16 ); \
(b)[(i) + 1] = (u8) ( (n) >> 8 ); \
(b)[(i) ] = (u8) ( (n) ); \
} while( 0 )
#endif /* PUT_UINT64_LE */
#define BELT_HASH_BLOCK_SIZE 32
#define BELT_HASH_DIGEST_SIZE 32
#define BELT_HASH_DIGEST_SIZE_BITS 256
/* Compute max hash digest and block sizes */
#ifndef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE 0
#endif
#if (MAX_DIGEST_SIZE < BELT_HASH_DIGEST_SIZE)
#undef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE BELT_HASH_DIGEST_SIZE
#endif
#ifndef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS 0
#endif
#if (MAX_DIGEST_SIZE_BITS < BELT_HASH_DIGEST_SIZE_BITS)
#undef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS BELT_HASH_DIGEST_SIZE_BITS
#endif
#ifndef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE 0
#endif
#if (MAX_BLOCK_SIZE < BELT_HASH_BLOCK_SIZE)
#undef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE BELT_HASH_BLOCK_SIZE
#endif
#define BELT_HASH_HASH_MAGIC ((word_t)(0x3278323b37829187ULL))
#define BELT_HASH_HASH_CHECK_INITIALIZED(A, ret, err) \
MUST_HAVE((((void *)(A)) != NULL) && ((A)->magic == BELT_HASH_HASH_MAGIC), ret, err)
typedef struct {
/* Number of bytes processed */
u64 belt_hash_total;
/* Internal state */
u8 belt_hash_state[BELT_HASH_BLOCK_SIZE];
/* Internal encryption data */
u8 belt_hash_h[BELT_HASH_BLOCK_SIZE];
/* Internal buffer to handle updates in a block */
u8 belt_hash_buffer[BELT_HASH_BLOCK_SIZE];
/* Initialization magic value */
word_t magic;
} belt_hash_context;
#define BELT_BLOCK_LEN 16 /* The BELT encryption block length */
#define BELT_KEY_SCHED_LEN 32 /* The BELT key schedul length */
ATTRIBUTE_WARN_UNUSED_RET int belt_init(const u8 *k, u32 k_len, u8 ks[BELT_KEY_SCHED_LEN]);
void belt_encrypt(const u8 in[BELT_BLOCK_LEN], u8 out[BELT_BLOCK_LEN], const u8 ks[BELT_KEY_SCHED_LEN]);
void belt_decrypt(const u8 in[BELT_BLOCK_LEN], u8 out[BELT_BLOCK_LEN], const u8 ks[BELT_KEY_SCHED_LEN]);
ATTRIBUTE_WARN_UNUSED_RET int belt_hash_init(belt_hash_context *ctx);
ATTRIBUTE_WARN_UNUSED_RET int belt_hash_update(belt_hash_context *ctx, const u8 *input, u32 ilen);
ATTRIBUTE_WARN_UNUSED_RET int belt_hash_final(belt_hash_context *ctx, u8 output[BELT_HASH_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int belt_hash_scattered(const u8 **inputs, const u32 *ilens,
u8 output[BELT_HASH_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int belt_hash(const u8 *input, u32 ilen, u8 output[BELT_HASH_DIGEST_SIZE]);
#endif /* __BELT_HASH_H__ */
#endif /* WITH_HASH_BELT_HASH */

View file

@ -0,0 +1,554 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __HASH_ALGS_H__
#define __HASH_ALGS_H__
#include <libecc/lib_ecc_config.h>
#include <libecc/lib_ecc_types.h>
#include <libecc/words/words.h>
#include <libecc/hash/sha224.h>
#include <libecc/hash/sha256.h>
#include <libecc/hash/sha384.h>
#include <libecc/hash/sha512.h>
#include <libecc/hash/sha512-224.h>
#include <libecc/hash/sha512-256.h>
#include <libecc/hash/sha3-224.h>
#include <libecc/hash/sha3-256.h>
#include <libecc/hash/sha3-384.h>
#include <libecc/hash/sha3-512.h>
#include <libecc/hash/sm3.h>
#include <libecc/hash/shake256.h>
#include <libecc/hash/streebog256.h>
#include <libecc/hash/streebog512.h>
#include <libecc/hash/ripemd160.h>
#include <libecc/hash/belt-hash.h>
#include <libecc/hash/bash224.h>
#include <libecc/hash/bash256.h>
#include <libecc/hash/bash384.h>
#include <libecc/hash/bash512.h>
#include <libecc/utils/utils.h>
#if (MAX_DIGEST_SIZE == 0)
#error "It seems you disabled all hash algorithms in lib_ecc_config.h"
#endif
#if (MAX_BLOCK_SIZE == 0)
#error "It seems you disabled all hash algorithms in lib_ecc_config.h"
#endif
typedef union {
#ifdef SHA224_BLOCK_SIZE
sha224_context sha224;
#endif
#ifdef SHA256_BLOCK_SIZE
sha256_context sha256;
#endif
#ifdef SHA384_BLOCK_SIZE
sha384_context sha384;
#endif
#ifdef SHA512_BLOCK_SIZE
sha512_context sha512;
#endif
#ifdef SHA512_224_BLOCK_SIZE
sha512_224_context sha512_224;
#endif
#ifdef SHA512_256_BLOCK_SIZE
sha512_256_context sha512_256;
#endif
#ifdef SHA3_224_BLOCK_SIZE
sha3_224_context sha3_224;
#endif
#ifdef SHA3_256_BLOCK_SIZE
sha3_256_context sha3_256;
#endif
#ifdef SHA3_384_BLOCK_SIZE
sha3_384_context sha3_384;
#endif
#ifdef SHA3_512_BLOCK_SIZE
sha3_512_context sha3_512;
#endif
#ifdef SHAKE256_BLOCK_SIZE
shake256_context shake256;
#endif
#ifdef SM3_BLOCK_SIZE
sm3_context sm3;
#endif
#ifdef STREEBOG256_BLOCK_SIZE
streebog256_context streebog256;
#endif
#ifdef STREEBOG512_BLOCK_SIZE
streebog512_context streebog512;
#endif
#ifdef RIPEMD160_BLOCK_SIZE
ripemd160_context ripemd160;
#endif
#ifdef BELT_HASH_BLOCK_SIZE
belt_hash_context belt_hash;
#endif
#ifdef BASH224_HASH_BLOCK_SIZE
bash224_context bash224;
#endif
#ifdef BASH256_HASH_BLOCK_SIZE
bash256_context bash256;
#endif
#ifdef BASH384_HASH_BLOCK_SIZE
bash384_context bash384;
#endif
#ifdef BASH512_HASH_BLOCK_SIZE
bash512_context bash512;
#endif
} hash_context;
typedef int (*_hfunc_init) (hash_context * hctx);
typedef int (*_hfunc_update) (hash_context * hctx,
const unsigned char *chunk, u32 chunklen);
typedef int (*_hfunc_finalize) (hash_context * hctx, unsigned char *output);
typedef int (*_hfunc_scattered) (const unsigned char **inputs,
const u32 *ilens, unsigned char *output);
/*****************************************/
/* Trampolines to each specific function to
* handle typing of our generic union structure.
*/
#ifdef WITH_HASH_SHA224
ATTRIBUTE_WARN_UNUSED_RET int _sha224_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _sha224_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _sha224_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_SHA256
ATTRIBUTE_WARN_UNUSED_RET int _sha256_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _sha256_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _sha256_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_SHA384
ATTRIBUTE_WARN_UNUSED_RET int _sha384_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _sha384_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _sha384_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_SHA512
ATTRIBUTE_WARN_UNUSED_RET int _sha512_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _sha512_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _sha512_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_SHA512_224
ATTRIBUTE_WARN_UNUSED_RET int _sha512_224_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _sha512_224_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _sha512_224_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_SHA512_256
ATTRIBUTE_WARN_UNUSED_RET int _sha512_256_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _sha512_256_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _sha512_256_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_SHA3_224
ATTRIBUTE_WARN_UNUSED_RET int _sha3_224_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _sha3_224_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _sha3_224_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_SHA3_256
ATTRIBUTE_WARN_UNUSED_RET int _sha3_256_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _sha3_256_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _sha3_256_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_SHA3_384
ATTRIBUTE_WARN_UNUSED_RET int _sha3_384_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _sha3_384_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _sha3_384_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_SHA3_512
ATTRIBUTE_WARN_UNUSED_RET int _sha3_512_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _sha3_512_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _sha3_512_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_SM3
ATTRIBUTE_WARN_UNUSED_RET int _sm3_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _sm3_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _sm3_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_SHAKE256
ATTRIBUTE_WARN_UNUSED_RET int _shake256_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _shake256_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _shake256_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_STREEBOG256
ATTRIBUTE_WARN_UNUSED_RET int _streebog256_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _streebog256_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _streebog256_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_STREEBOG512
ATTRIBUTE_WARN_UNUSED_RET int _streebog512_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _streebog512_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _streebog512_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_RIPEMD160
ATTRIBUTE_WARN_UNUSED_RET int _ripemd160_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _ripemd160_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _ripemd160_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_BELT_HASH
ATTRIBUTE_WARN_UNUSED_RET int _belt_hash_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _belt_hash_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _belt_hash_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_BASH224
ATTRIBUTE_WARN_UNUSED_RET int _bash224_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _bash224_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _bash224_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_BASH256
ATTRIBUTE_WARN_UNUSED_RET int _bash256_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _bash256_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _bash256_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_BASH384
ATTRIBUTE_WARN_UNUSED_RET int _bash384_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _bash384_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _bash384_final(hash_context * hctx, unsigned char *output);
#endif
#ifdef WITH_HASH_BASH512
ATTRIBUTE_WARN_UNUSED_RET int _bash512_init(hash_context * hctx);
ATTRIBUTE_WARN_UNUSED_RET int _bash512_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen);
ATTRIBUTE_WARN_UNUSED_RET int _bash512_final(hash_context * hctx, unsigned char *output);
#endif
/*
* All the hash algorithms we support are abstracted using the following
* structure (and following map) which provides for each hash alg its
* digest size, its block size and the associated scattered function.
*/
typedef struct {
hash_alg_type type;
const char *name;
u8 digest_size;
u8 block_size;
ATTRIBUTE_WARN_UNUSED_RET _hfunc_init hfunc_init;
ATTRIBUTE_WARN_UNUSED_RET _hfunc_update hfunc_update;
ATTRIBUTE_WARN_UNUSED_RET _hfunc_finalize hfunc_finalize;
ATTRIBUTE_WARN_UNUSED_RET _hfunc_scattered hfunc_scattered;
} hash_mapping;
ATTRIBUTE_WARN_UNUSED_RET static inline int hash_mapping_sanity_check(const hash_mapping *hm)
{
int ret;
MUST_HAVE(((hm != NULL) && (hm->name != NULL) && (hm->hfunc_init != NULL) &&
(hm->hfunc_update != NULL) && (hm->hfunc_finalize != NULL) &&
(hm->hfunc_scattered != NULL)), ret, err);
ret = 0;
err:
return ret;
}
#define MAX_HASH_ALG_NAME_LEN 0
static const hash_mapping hash_maps[] = {
#ifdef WITH_HASH_SHA224
{.type = SHA224, /* SHA224 */
.name = "SHA224",
.digest_size = SHA224_DIGEST_SIZE,
.block_size = SHA224_BLOCK_SIZE,
.hfunc_init = _sha224_init,
.hfunc_update = _sha224_update,
.hfunc_finalize = _sha224_final,
.hfunc_scattered = sha224_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 7)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 7
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_SHA224 */
#ifdef WITH_HASH_SHA256
{.type = SHA256, /* SHA256 */
.name = "SHA256",
.digest_size = SHA256_DIGEST_SIZE,
.block_size = SHA256_BLOCK_SIZE,
.hfunc_init = _sha256_init,
.hfunc_update = _sha256_update,
.hfunc_finalize = _sha256_final,
.hfunc_scattered = sha256_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 7)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 7
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_SHA256 */
#ifdef WITH_HASH_SHA384
{.type = SHA384, /* SHA384 */
.name = "SHA384",
.digest_size = SHA384_DIGEST_SIZE,
.block_size = SHA384_BLOCK_SIZE,
.hfunc_init = _sha384_init,
.hfunc_update = _sha384_update,
.hfunc_finalize = _sha384_final,
.hfunc_scattered = sha384_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 7)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 7
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_SHA384 */
#ifdef WITH_HASH_SHA512
{.type = SHA512, /* SHA512 */
.name = "SHA512",
.digest_size = SHA512_DIGEST_SIZE,
.block_size = SHA512_BLOCK_SIZE,
.hfunc_init = _sha512_init,
.hfunc_update = _sha512_update,
.hfunc_finalize = _sha512_final,
.hfunc_scattered = sha512_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 7)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 7
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_SHA512 */
#ifdef WITH_HASH_SHA512_224
{.type = SHA512_224, /* SHA512_224 */
.name = "SHA512_224",
.digest_size = SHA512_224_DIGEST_SIZE,
.block_size = SHA512_224_BLOCK_SIZE,
.hfunc_init = _sha512_224_init,
.hfunc_update = _sha512_224_update,
.hfunc_finalize = _sha512_224_final,
.hfunc_scattered = sha512_224_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 7)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 7
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_SHA512_224 */
#ifdef WITH_HASH_SHA512_256
{.type = SHA512_256, /* SHA512_256 */
.name = "SHA512_256",
.digest_size = SHA512_256_DIGEST_SIZE,
.block_size = SHA512_256_BLOCK_SIZE,
.hfunc_init = _sha512_256_init,
.hfunc_update = _sha512_256_update,
.hfunc_finalize = _sha512_256_final,
.hfunc_scattered = sha512_256_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 7)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 7
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_SHA512_256 */
#ifdef WITH_HASH_SHA3_224
{.type = SHA3_224, /* SHA3_224 */
.name = "SHA3_224",
.digest_size = SHA3_224_DIGEST_SIZE,
.block_size = SHA3_224_BLOCK_SIZE,
.hfunc_init = _sha3_224_init,
.hfunc_update = _sha3_224_update,
.hfunc_finalize = _sha3_224_final,
.hfunc_scattered = sha3_224_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 9)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 9
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_SHA3_224 */
#ifdef WITH_HASH_SHA3_256
{.type = SHA3_256, /* SHA3_256 */
.name = "SHA3_256",
.digest_size = SHA3_256_DIGEST_SIZE,
.block_size = SHA3_256_BLOCK_SIZE,
.hfunc_init = _sha3_256_init,
.hfunc_update = _sha3_256_update,
.hfunc_finalize = _sha3_256_final,
.hfunc_scattered = sha3_256_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 9)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 9
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_SHA3_256 */
#ifdef WITH_HASH_SHA3_384
{.type = SHA3_384, /* SHA3_384 */
.name = "SHA3_384",
.digest_size = SHA3_384_DIGEST_SIZE,
.block_size = SHA3_384_BLOCK_SIZE,
.hfunc_init = _sha3_384_init,
.hfunc_update = _sha3_384_update,
.hfunc_finalize = _sha3_384_final,
.hfunc_scattered = sha3_384_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 9)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 9
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_SHA3_384 */
#ifdef WITH_HASH_SHA3_512
{.type = SHA3_512, /* SHA3_512 */
.name = "SHA3_512",
.digest_size = SHA3_512_DIGEST_SIZE,
.block_size = SHA3_512_BLOCK_SIZE,
.hfunc_init = _sha3_512_init,
.hfunc_update = _sha3_512_update,
.hfunc_finalize = _sha3_512_final,
.hfunc_scattered = sha3_512_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 9)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 9
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_SHA3_512 */
#ifdef WITH_HASH_SM3
{.type = SM3, /* SM3 */
.name = "SM3",
.digest_size = SM3_DIGEST_SIZE,
.block_size = SM3_BLOCK_SIZE,
.hfunc_init = _sm3_init,
.hfunc_update = _sm3_update,
.hfunc_finalize = _sm3_final,
.hfunc_scattered = sm3_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 4)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 4
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_SM3 */
#ifdef WITH_HASH_SHAKE256
{.type = SHAKE256, /* SHAKE256 */
.name = "SHAKE256",
.digest_size = SHAKE256_DIGEST_SIZE,
.block_size = SHAKE256_BLOCK_SIZE,
.hfunc_init = _shake256_init,
.hfunc_update = _shake256_update,
.hfunc_finalize = _shake256_final,
.hfunc_scattered = shake256_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 9)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 9
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_SHAKE256 */
#ifdef WITH_HASH_STREEBOG256
{.type = STREEBOG256, /* STREEBOG256 */
.name = "STREEBOG256",
.digest_size = STREEBOG256_DIGEST_SIZE,
.block_size = STREEBOG256_BLOCK_SIZE,
.hfunc_init = _streebog256_init,
.hfunc_update = _streebog256_update,
.hfunc_finalize = _streebog256_final,
.hfunc_scattered = streebog256_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 12)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 12
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_STREEBOG256 */
#ifdef WITH_HASH_STREEBOG512
{.type = STREEBOG512, /* STREEBOG512 */
.name = "STREEBOG512",
.digest_size = STREEBOG512_DIGEST_SIZE,
.block_size = STREEBOG512_BLOCK_SIZE,
.hfunc_init = _streebog512_init,
.hfunc_update = _streebog512_update,
.hfunc_finalize = _streebog512_final,
.hfunc_scattered = streebog512_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 12)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 12
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_STREEBOG512 */
#ifdef WITH_HASH_RIPEMD160
{.type = RIPEMD160, /* RIPEMD160 */
.name = "RIPEMD160",
.digest_size = RIPEMD160_DIGEST_SIZE,
.block_size = RIPEMD160_BLOCK_SIZE,
.hfunc_init = _ripemd160_init,
.hfunc_update = _ripemd160_update,
.hfunc_finalize = _ripemd160_final,
.hfunc_scattered = ripemd160_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 9)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 9
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_RIPEMD160 */
#ifdef WITH_HASH_BELT_HASH
{.type = BELT_HASH, /* BELT_HASH */
.name = "BELT_HASH",
.digest_size = BELT_HASH_DIGEST_SIZE,
.block_size = BELT_HASH_BLOCK_SIZE,
.hfunc_init = _belt_hash_init,
.hfunc_update = _belt_hash_update,
.hfunc_finalize = _belt_hash_final,
.hfunc_scattered = belt_hash_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 9)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 9
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_BELT_HASH */
#ifdef WITH_HASH_BASH224
{.type = BASH224, /* BASH224 */
.name = "BASH224",
.digest_size = BASH224_DIGEST_SIZE,
.block_size = BASH224_BLOCK_SIZE,
.hfunc_init = _bash224_init,
.hfunc_update = _bash224_update,
.hfunc_finalize = _bash224_final,
.hfunc_scattered = bash224_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 8)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 8
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_BASH224 */
#ifdef WITH_HASH_BASH256
{.type = BASH256, /* BASH256 */
.name = "BASH256",
.digest_size = BASH256_DIGEST_SIZE,
.block_size = BASH256_BLOCK_SIZE,
.hfunc_init = _bash256_init,
.hfunc_update = _bash256_update,
.hfunc_finalize = _bash256_final,
.hfunc_scattered = bash256_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 8)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 8
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_BASH256 */
#ifdef WITH_HASH_BASH384
{.type = BASH384, /* BASH384 */
.name = "BASH384",
.digest_size = BASH384_DIGEST_SIZE,
.block_size = BASH384_BLOCK_SIZE,
.hfunc_init = _bash384_init,
.hfunc_update = _bash384_update,
.hfunc_finalize = _bash384_final,
.hfunc_scattered = bash384_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 8)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 8
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_BASH384 */
#ifdef WITH_HASH_BASH512
{.type = BASH512, /* BASH512 */
.name = "BASH512",
.digest_size = BASH512_DIGEST_SIZE,
.block_size = BASH512_BLOCK_SIZE,
.hfunc_init = _bash512_init,
.hfunc_update = _bash512_update,
.hfunc_finalize = _bash512_final,
.hfunc_scattered = bash512_scattered},
#if (MAX_HASH_ALG_NAME_LEN < 8)
#undef MAX_HASH_ALG_NAME_LEN
#define MAX_HASH_ALG_NAME_LEN 8
#endif /* MAX_HASH_ALG_NAME_LEN */
#endif /* WITH_HASH_BASH512 */
{.type = UNKNOWN_HASH_ALG, /* Needs to be kept last */
.name = "UNKNOWN",
.digest_size = 0,
.block_size = 0,
.hfunc_init = NULL,
.hfunc_update = NULL,
.hfunc_finalize = NULL,
.hfunc_scattered = NULL},
};
ATTRIBUTE_WARN_UNUSED_RET int get_hash_by_name(const char *hash_name, const hash_mapping **hm);
ATTRIBUTE_WARN_UNUSED_RET int get_hash_by_type(hash_alg_type hash_type, const hash_mapping **hm);
ATTRIBUTE_WARN_UNUSED_RET int get_hash_sizes(hash_alg_type hash_type, u8 *digest_size, u8 *block_size);
ATTRIBUTE_WARN_UNUSED_RET int hash_mapping_callbacks_sanity_check(const hash_mapping *h);
#endif /* __HASH_ALGS_H__ */

View file

@ -0,0 +1,38 @@
#ifndef __HMAC_H__
#define __HMAC_H__
#include <libecc/lib_ecc_config.h>
#ifdef WITH_HMAC
#include <libecc/words/words.h>
#include <libecc/utils/utils.h>
#include <libecc/hash/hash_algs.h>
#define HMAC_MAGIC ((word_t)(0x9849020187612083ULL))
#define HMAC_CHECK_INITIALIZED(A, ret, err) \
MUST_HAVE((((void *)(A)) != NULL) && ((A)->magic == HMAC_MAGIC) && ((A)->hash != NULL), ret, err)
/* The HMAC structure is made of two hash contexts */
typedef struct {
/* The hash mapping associated with the hmac */
const hash_mapping *hash;
/* The two hash contexts (inner and outer) */
hash_context in_ctx;
hash_context out_ctx;
/* Initialization magic value */
word_t magic;
} hmac_context;
ATTRIBUTE_WARN_UNUSED_RET int hmac_init(hmac_context *ctx, const u8 *hmackey, u32 hmackey_len, hash_alg_type hash_type);
ATTRIBUTE_WARN_UNUSED_RET int hmac_update(hmac_context *ctx, const u8 *input, u32 ilen);
ATTRIBUTE_WARN_UNUSED_RET int hmac_finalize(hmac_context *ctx, u8 *output, u8 *outlen);
ATTRIBUTE_WARN_UNUSED_RET int hmac(const u8 *hmackey, u32 hmackey_len, hash_alg_type hash_type, const u8 *input, u32 ilen, u8 *output, u8 *outlen);
ATTRIBUTE_WARN_UNUSED_RET int hmac_scattered(const u8 *hmackey, u32 hmackey_len, hash_alg_type hash_type, const u8 **inputs, const u32 *ilens, u8 *output, u8 *outlen);
#endif /* WITH_HMAC */
#endif /* __HMAC_H__ */

View file

@ -0,0 +1,112 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __KECCAK_H__
#define __KECCAK_H__
#include <libecc/words/words.h>
#define _KECCAK_ROTL_(x, y) (((x) << (y)) | ((x) >> ((sizeof(u64) * 8) - (y))))
/* We handle the case where one of the shifts is more than 64-bit: in this
* case, behaviour is undefined as per ANSI C definition. In this case, we
* return the untouched input.
*/
#define KECCAK_ROTL(x, y) ((((y) < (sizeof(u64) * 8)) && ((y) > 0)) ? (_KECCAK_ROTL_(x, y)) : (x))
/*
* Round transformation of the state. Notations are the
* same as the ones used in:
* http://keccak.noekeon.org/specs_summary.html
*/
#define KECCAK_WORD_LOG 6
#define KECCAK_ROUNDS (12 + (2 * KECCAK_WORD_LOG))
#define KECCAK_SLICES 5
static const u64 keccak_rc[KECCAK_ROUNDS] =
{
0x0000000000000001ULL, 0x0000000000008082ULL,
0x800000000000808AULL, 0x8000000080008000ULL,
0x000000000000808BULL, 0x0000000080000001ULL,
0x8000000080008081ULL, 0x8000000000008009ULL,
0x000000000000008AULL, 0x0000000000000088ULL,
0x0000000080008009ULL, 0x000000008000000AULL,
0x000000008000808BULL, 0x800000000000008BULL,
0x8000000000008089ULL, 0x8000000000008003ULL,
0x8000000000008002ULL, 0x8000000000000080ULL,
0x000000000000800AULL, 0x800000008000000AULL,
0x8000000080008081ULL, 0x8000000000008080ULL,
0x0000000080000001ULL, 0x8000000080008008ULL
};
static const u8 keccak_rot[KECCAK_SLICES][KECCAK_SLICES] =
{
{ 0, 36, 3, 41, 18 },
{ 1, 44, 10, 45, 2 },
{ 62, 6, 43, 15, 61 },
{ 28, 55, 25, 21, 56 },
{ 27, 20, 39, 8, 14 },
};
/* Macro to handle endianness conversion */
#define SWAP64_Idx(a) ((sizeof(u64) * ((u8)(a) / sizeof(u64))) + (sizeof(u64) - 1 - ((u8)(a) % sizeof(u64))))
#define Idx_slices(x, y) ((x) + (KECCAK_SLICES * (y)))
#define Idx(A, x, y) ((A)[Idx_slices(x, y)])
#define KECCAKROUND(A, RC) do { \
int x, y; \
u64 tmp; \
/* Temporary B, C and D arrays */ \
u64 BCD[KECCAK_SLICES * KECCAK_SLICES]; \
/* Theta step */ \
for(x = 0; x < KECCAK_SLICES; x++){ \
Idx(BCD, x, 0) = Idx(A, x, 0) ^ Idx(A, x, 1) ^ Idx(A, x, 2) ^ \
Idx(A, x, 3) ^ Idx(A, x, 4); \
} \
for(x = 0; x < KECCAK_SLICES; x++){ \
tmp = Idx(BCD, (x + 4) % 5, 0) ^ \
KECCAK_ROTL(Idx(BCD, (x + 1) % 5, 0), 1); \
for(y = 0; y < KECCAK_SLICES; y++){ \
Idx(A, x, y) ^= tmp; \
} \
} \
/* Rho and Pi steps */ \
for(x = 0; x < KECCAK_SLICES; x++){ \
for(y = 0; y < KECCAK_SLICES; y++){ \
Idx(BCD, y, ((2*x)+(3*y)) % 5) = \
KECCAK_ROTL(Idx(A, x, y), keccak_rot[x][y]); \
} \
} \
/* Chi step */ \
for(x = 0; x < KECCAK_SLICES; x++){ \
for(y = 0; y < KECCAK_SLICES; y++){ \
Idx(A, x, y) = Idx(BCD, x, y) ^ \
(~Idx(BCD, (x+1) % 5, y) & Idx(BCD, (x+2)%5, y)); \
} \
} \
/* Iota step */ \
Idx(A, 0, 0) ^= (RC); \
} while(0)
#define KECCAKF(A) do { \
int round; \
for(round = 0; round < KECCAK_ROUNDS; round++){ \
KECCAKROUND(A, keccak_rc[round]); \
} \
} while(0)
#endif /* __KECCAK_H__ */

View file

@ -0,0 +1,73 @@
/*
* Copyright (C) 2021 - This file is part of libecc project
*
* Authors:
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Ryad BENADJILA <ryadbenadjila@gmail.com>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_HASH_RIPEMD160
#ifndef __RIPEMD160_H__
#define __RIPEMD160_H__
#include <libecc/words/words.h>
#include <libecc/utils/utils.h>
#define RIPEMD160_STATE_SIZE 5
#define RIPEMD160_BLOCK_SIZE 64
#define RIPEMD160_DIGEST_SIZE 20
#define RIPEMD160_DIGEST_SIZE_BITS 160
/* Compute max hash digest and block sizes */
#ifndef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE 0
#endif
#if (MAX_DIGEST_SIZE < RIPEMD160_DIGEST_SIZE)
#undef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE RIPEMD160_DIGEST_SIZE
#endif
#ifndef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS 0
#endif
#if (MAX_DIGEST_SIZE_BITS < RIPEMD160_DIGEST_SIZE_BITS)
#undef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS RIPEMD160_DIGEST_SIZE_BITS
#endif
#ifndef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE 0
#endif
#if (MAX_BLOCK_SIZE < RIPEMD160_BLOCK_SIZE)
#undef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE RIPEMD160_BLOCK_SIZE
#endif
#define RIPEMD160_HASH_MAGIC ((word_t)(0x7392018463926719ULL))
#define RIPEMD160_HASH_CHECK_INITIALIZED(A, ret, err) \
MUST_HAVE((((void *)(A)) != NULL) && ((A)->magic == RIPEMD160_HASH_MAGIC), ret, err)
typedef struct {
/* Number of bytes processed */
u64 ripemd160_total;
/* Internal state */
u32 ripemd160_state[RIPEMD160_STATE_SIZE];
/* Internal buffer to handle updates in a block */
u8 ripemd160_buffer[RIPEMD160_BLOCK_SIZE];
/* Initialization magic value */
word_t magic;
} ripemd160_context;
ATTRIBUTE_WARN_UNUSED_RET int ripemd160_init(ripemd160_context *ctx);
ATTRIBUTE_WARN_UNUSED_RET int ripemd160_update(ripemd160_context *ctx, const u8 *input, u32 ilen);
ATTRIBUTE_WARN_UNUSED_RET int ripemd160_final(ripemd160_context *ctx, u8 output[RIPEMD160_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int ripemd160_scattered(const u8 **inputs, const u32 *ilens,
u8 output[RIPEMD160_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int ripemd160(const u8 *input, u32 ilen, u8 output[RIPEMD160_DIGEST_SIZE]);
#endif /* __RIPEMD160_H__ */
#endif /* WITH_HASH_RIPEMD160 */

View file

@ -0,0 +1,219 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __SHA2_H__
#define __SHA2_H__
#include <libecc/words/words.h>
/* Useful primitives for handling 128-bit */
/* Add a 128-bit to a 64-bit element and store the result
* in the input
*/
#define ADD_UINT128_UINT64(low,high,toadd) do {\
(low) += (toadd);\
if((low) < (toadd)){\
(high)++;\
}\
} while(0)
/* Store a 128-bit element in big endian format */
#define PUT_UINT128_BE(low,high,b,i) do {\
PUT_UINT64_BE((high), (b), (i));\
PUT_UINT64_BE((low), (b), (i)+8);\
} while(0)
/* Multiply a 128-bit element by 8 and store it in big endian
* format
*/
#define PUT_MUL8_UINT128_BE(low,high,b,i) do {\
u64 reslow, reshigh;\
reslow = (low) << 3;\
reshigh = ((low) >> 61) ^ ((high) << 3);\
PUT_UINT128_BE(reslow,reshigh,(b),(i));\
} while(0)
/*
* 32-bit integer manipulation macros (big endian)
*/
#ifndef GET_UINT32_BE
#define GET_UINT32_BE(n, b, i) \
do { \
(n) = ( ((u32) (b)[(i) ]) << 24 ) \
| ( ((u32) (b)[(i) + 1]) << 16 ) \
| ( ((u32) (b)[(i) + 2]) << 8 ) \
| ( ((u32) (b)[(i) + 3]) ); \
} while( 0 )
#endif
#ifndef PUT_UINT32_BE
#define PUT_UINT32_BE(n, b, i) \
do { \
(b)[(i) ] = (u8) ( (n) >> 24 ); \
(b)[(i) + 1] = (u8) ( (n) >> 16 ); \
(b)[(i) + 2] = (u8) ( (n) >> 8 ); \
(b)[(i) + 3] = (u8) ( (n) ); \
} while( 0 )
#endif
/*
* 64-bit integer manipulation macros (big endian)
*/
#ifndef GET_UINT64_BE
#define GET_UINT64_BE(n,b,i) \
do { \
(n) = ( ((u64) (b)[(i) ]) << 56 ) \
| ( ((u64) (b)[(i) + 1]) << 48 ) \
| ( ((u64) (b)[(i) + 2]) << 40 ) \
| ( ((u64) (b)[(i) + 3]) << 32 ) \
| ( ((u64) (b)[(i) + 4]) << 24 ) \
| ( ((u64) (b)[(i) + 5]) << 16 ) \
| ( ((u64) (b)[(i) + 6]) << 8 ) \
| ( ((u64) (b)[(i) + 7]) ); \
} while( 0 )
#endif /* GET_UINT64_BE */
#ifndef PUT_UINT64_BE
#define PUT_UINT64_BE(n,b,i) \
do { \
(b)[(i) ] = (u8) ( (n) >> 56 ); \
(b)[(i) + 1] = (u8) ( (n) >> 48 ); \
(b)[(i) + 2] = (u8) ( (n) >> 40 ); \
(b)[(i) + 3] = (u8) ( (n) >> 32 ); \
(b)[(i) + 4] = (u8) ( (n) >> 24 ); \
(b)[(i) + 5] = (u8) ( (n) >> 16 ); \
(b)[(i) + 6] = (u8) ( (n) >> 8 ); \
(b)[(i) + 7] = (u8) ( (n) ); \
} while( 0 )
#endif /* PUT_UINT64_BE */
/* Useful macros for the SHA-2 core function */
#define CH(x, y, z) (((x) & (y)) ^ ((~(x)) & (z)))
#define MAJ(x, y, z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
#define UPDATEW(w, i, sha_type) ((w)[(i)] = SIGMA_MIN1_##sha_type((w)[(i)-2]) + (w)[(i)-7] + SIGMA_MIN0_##sha_type((w)[(i)-15]) + (w)[(i)-16])
#define SHA2CORE(a, b, c, d, e, f, g, h, w, k, sha_word_type, sha_type) do {\
sha_word_type t1, t2;\
t1 = (h) + SIGMA_MAJ1_##sha_type((e)) + CH((e), (f), (g)) + (k) + (w);\
t2 = SIGMA_MAJ0_##sha_type((a)) + MAJ((a), (b), (c));\
(h) = (g);\
(g) = (f);\
(f) = (e);\
(e) = (d) + t1;\
(d) = (c);\
(c) = (b);\
(b) = (a);\
(a) = t1 + t2;\
} while(0)
#if (defined(WITH_HASH_SHA224) || defined(WITH_HASH_SHA256))
/**********************************************/
/* SHA-224 and SHA-256 */
#define SHR_SHA256(x, n) (((u32)(x)) >> (n))
#define ROTR_SHA256(x, n) ((((u32)(x)) >> (n)) | (((u32)(x)) << (32-(n))))
#define SIGMA_MAJ0_SHA256(x) (ROTR_SHA256(x, 2) ^ ROTR_SHA256(x, 13) ^ ROTR_SHA256(x, 22))
#define SIGMA_MAJ1_SHA256(x) (ROTR_SHA256(x, 6) ^ ROTR_SHA256(x, 11) ^ ROTR_SHA256(x, 25))
#define SIGMA_MIN0_SHA256(x) (ROTR_SHA256(x, 7) ^ ROTR_SHA256(x, 18) ^ SHR_SHA256(x, 3))
#define SIGMA_MIN1_SHA256(x) (ROTR_SHA256(x, 17) ^ ROTR_SHA256(x, 19) ^ SHR_SHA256(x, 10))
#define SHA2CORE_SHA256(a, b, c, d, e, f, g, h, w, k) \
SHA2CORE(a, b, c, d, e, f, g, h, w, k, u32, SHA256)
#define UPDATEW_SHA256(w, i) UPDATEW(w, i, SHA256)
static const u32 K_SHA256[] = {
0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2,
};
/**********************************************/
#endif
#if (defined(WITH_HASH_SHA384) || defined(WITH_HASH_SHA512))
/**********************************************/
/* SHA-384 and SHA-512 */
#define SHR_SHA512(x, n) (((u64)(x)) >> (n))
#define ROTR_SHA512(x, n) ((((u64)(x)) >> (n)) | (((u64)(x)) << (64-(n))))
#define SIGMA_MAJ0_SHA512(x) (ROTR_SHA512(x, 28) ^ ROTR_SHA512(x, 34) ^ ROTR_SHA512(x, 39))
#define SIGMA_MAJ1_SHA512(x) (ROTR_SHA512(x, 14) ^ ROTR_SHA512(x, 18) ^ ROTR_SHA512(x, 41))
#define SIGMA_MIN0_SHA512(x) (ROTR_SHA512(x, 1) ^ ROTR_SHA512(x, 8) ^ SHR_SHA512(x, 7))
#define SIGMA_MIN1_SHA512(x) (ROTR_SHA512(x, 19) ^ ROTR_SHA512(x, 61) ^ SHR_SHA512(x, 6))
#define SHA2CORE_SHA512(a, b, c, d, e, f, g, h, w, k) \
SHA2CORE(a, b, c, d, e, f, g, h, w, k, u64, SHA512)
#define UPDATEW_SHA512(w, i) UPDATEW(w, i, SHA512)
static const u64 K_SHA512[] = {
(u64)(0x428A2F98D728AE22), (u64)(0x7137449123EF65CD),
(u64)(0xB5C0FBCFEC4D3B2F), (u64)(0xE9B5DBA58189DBBC),
(u64)(0x3956C25BF348B538), (u64)(0x59F111F1B605D019),
(u64)(0x923F82A4AF194F9B), (u64)(0xAB1C5ED5DA6D8118),
(u64)(0xD807AA98A3030242), (u64)(0x12835B0145706FBE),
(u64)(0x243185BE4EE4B28C), (u64)(0x550C7DC3D5FFB4E2),
(u64)(0x72BE5D74F27B896F), (u64)(0x80DEB1FE3B1696B1),
(u64)(0x9BDC06A725C71235), (u64)(0xC19BF174CF692694),
(u64)(0xE49B69C19EF14AD2), (u64)(0xEFBE4786384F25E3),
(u64)(0x0FC19DC68B8CD5B5), (u64)(0x240CA1CC77AC9C65),
(u64)(0x2DE92C6F592B0275), (u64)(0x4A7484AA6EA6E483),
(u64)(0x5CB0A9DCBD41FBD4), (u64)(0x76F988DA831153B5),
(u64)(0x983E5152EE66DFAB), (u64)(0xA831C66D2DB43210),
(u64)(0xB00327C898FB213F), (u64)(0xBF597FC7BEEF0EE4),
(u64)(0xC6E00BF33DA88FC2), (u64)(0xD5A79147930AA725),
(u64)(0x06CA6351E003826F), (u64)(0x142929670A0E6E70),
(u64)(0x27B70A8546D22FFC), (u64)(0x2E1B21385C26C926),
(u64)(0x4D2C6DFC5AC42AED), (u64)(0x53380D139D95B3DF),
(u64)(0x650A73548BAF63DE), (u64)(0x766A0ABB3C77B2A8),
(u64)(0x81C2C92E47EDAEE6), (u64)(0x92722C851482353B),
(u64)(0xA2BFE8A14CF10364), (u64)(0xA81A664BBC423001),
(u64)(0xC24B8B70D0F89791), (u64)(0xC76C51A30654BE30),
(u64)(0xD192E819D6EF5218), (u64)(0xD69906245565A910),
(u64)(0xF40E35855771202A), (u64)(0x106AA07032BBD1B8),
(u64)(0x19A4C116B8D2D0C8), (u64)(0x1E376C085141AB53),
(u64)(0x2748774CDF8EEB99), (u64)(0x34B0BCB5E19B48A8),
(u64)(0x391C0CB3C5C95A63), (u64)(0x4ED8AA4AE3418ACB),
(u64)(0x5B9CCA4F7763E373), (u64)(0x682E6FF3D6B2B8A3),
(u64)(0x748F82EE5DEFB2FC), (u64)(0x78A5636F43172F60),
(u64)(0x84C87814A1F0AB72), (u64)(0x8CC702081A6439EC),
(u64)(0x90BEFFFA23631E28), (u64)(0xA4506CEBDE82BDE9),
(u64)(0xBEF9A3F7B2C67915), (u64)(0xC67178F2E372532B),
(u64)(0xCA273ECEEA26619C), (u64)(0xD186B8C721C0C207),
(u64)(0xEADA7DD6CDE0EB1E), (u64)(0xF57D4F7FEE6ED178),
(u64)(0x06F067AA72176FBA), (u64)(0x0A637DC5A2C898A6),
(u64)(0x113F9804BEF90DAE), (u64)(0x1B710B35131C471B),
(u64)(0x28DB77F523047D84), (u64)(0x32CAAB7B40C72493),
(u64)(0x3C9EBE0A15C9BEBC), (u64)(0x431D67C49C100D4C),
(u64)(0x4CC5D4BECB3E42B6), (u64)(0x597F299CFC657E2A),
(u64)(0x5FCB6FAB3AD6FAEC), (u64)(0x6C44198C4A475817)
};
/**********************************************/
#endif
#endif /* __SHA2_H__ */

View file

@ -0,0 +1,79 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_HASH_SHA224
#ifndef __SHA224_H__
#define __SHA224_H__
#include <libecc/words/words.h>
#include <libecc/utils/utils.h>
#include <libecc/hash/sha2.h>
#define SHA224_STATE_SIZE 8
#define SHA224_BLOCK_SIZE 64
#define SHA224_DIGEST_SIZE 28
#define SHA224_DIGEST_SIZE_BITS 224
/* Compute max hash digest and block sizes */
#ifndef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE 0
#endif
#if (MAX_DIGEST_SIZE < SHA224_DIGEST_SIZE)
#undef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE SHA224_DIGEST_SIZE
#endif
#ifndef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS 0
#endif
#if (MAX_DIGEST_SIZE_BITS < SHA224_DIGEST_SIZE_BITS)
#undef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS SHA224_DIGEST_SIZE_BITS
#endif
#ifndef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE 0
#endif
#if (MAX_BLOCK_SIZE < SHA224_BLOCK_SIZE)
#undef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE SHA224_BLOCK_SIZE
#endif
#define SHA224_HASH_MAGIC ((word_t)(0x1120323b32342910ULL))
#define SHA224_HASH_CHECK_INITIALIZED(A, ret, err) \
MUST_HAVE((((void *)(A)) != NULL) && ((A)->magic == SHA224_HASH_MAGIC), ret, err)
typedef struct {
/* Number of bytes processed */
u64 sha224_total;
/* Internal state */
u32 sha224_state[SHA224_STATE_SIZE];
/* Internal buffer to handle updates in a block */
u8 sha224_buffer[SHA224_BLOCK_SIZE];
/* Initialization magic value */
word_t magic;
} sha224_context;
ATTRIBUTE_WARN_UNUSED_RET int sha224_init(sha224_context *ctx);
ATTRIBUTE_WARN_UNUSED_RET int sha224_update(sha224_context *ctx, const u8 *input, u32 ilen);
ATTRIBUTE_WARN_UNUSED_RET int sha224_final(sha224_context *ctx, u8 output[SHA224_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int sha224_scattered(const u8 **inputs, const u32 *ilens,
u8 output[SHA224_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int sha224(const u8 *input, u32 ilen, u8 output[SHA224_DIGEST_SIZE]);
#endif /* __SHA224_H__ */
#endif /* WITH_HASH_SHA224 */

View file

@ -0,0 +1,79 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_HASH_SHA256
#ifndef __SHA256_H__
#define __SHA256_H__
#include <libecc/words/words.h>
#include <libecc/utils/utils.h>
#include <libecc/hash/sha2.h>
#define SHA256_STATE_SIZE 8
#define SHA256_BLOCK_SIZE 64
#define SHA256_DIGEST_SIZE 32
#define SHA256_DIGEST_SIZE_BITS 256
/* Compute max hash digest and block sizes */
#ifndef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE 0
#endif
#if (MAX_DIGEST_SIZE < SHA256_DIGEST_SIZE)
#undef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE SHA256_DIGEST_SIZE
#endif
#ifndef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS 0
#endif
#if (MAX_DIGEST_SIZE_BITS < SHA256_DIGEST_SIZE_BITS)
#undef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS SHA256_DIGEST_SIZE_BITS
#endif
#ifndef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE 0
#endif
#if (MAX_BLOCK_SIZE < SHA256_BLOCK_SIZE)
#undef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE SHA256_BLOCK_SIZE
#endif
#define SHA256_HASH_MAGIC ((word_t)(0x11299a2b32098412ULL))
#define SHA256_HASH_CHECK_INITIALIZED(A, ret, err) \
MUST_HAVE((((void *)(A)) != NULL) && ((A)->magic == SHA256_HASH_MAGIC), ret, err)
typedef struct {
/* Number of bytes processed */
u64 sha256_total;
/* Internal state */
u32 sha256_state[SHA256_STATE_SIZE];
/* Internal buffer to handle updates in a block */
u8 sha256_buffer[SHA256_BLOCK_SIZE];
/* Initialization magic value */
word_t magic;
} sha256_context;
ATTRIBUTE_WARN_UNUSED_RET int sha256_init(sha256_context *ctx);
ATTRIBUTE_WARN_UNUSED_RET int sha256_update(sha256_context *ctx, const u8 *input, u32 ilen);
ATTRIBUTE_WARN_UNUSED_RET int sha256_final(sha256_context *ctx, u8 output[SHA256_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int sha256_scattered(const u8 **inputs, const u32 *ilens,
u8 output[SHA256_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int sha256(const u8 *input, u32 ilen, u8 output[SHA256_DIGEST_SIZE]);
#endif /* __SHA256_H__ */
#endif /* WITH_HASH_SHA256 */

View file

@ -0,0 +1,69 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_HASH_SHA3_224
#ifndef __SHA3_224_H__
#define __SHA3_224_H__
#include <libecc/words/words.h>
#include <libecc/utils/utils.h>
#include <libecc/hash/sha3.h>
#define SHA3_224_BLOCK_SIZE 144
#define SHA3_224_DIGEST_SIZE 28
#define SHA3_224_DIGEST_SIZE_BITS 224
/* Compute max hash digest and block sizes */
#ifndef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE 0
#endif
#if (MAX_DIGEST_SIZE < SHA3_224_DIGEST_SIZE)
#undef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE SHA3_224_DIGEST_SIZE
#endif
#ifndef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS 0
#endif
#if (MAX_DIGEST_SIZE_BITS < SHA3_224_DIGEST_SIZE_BITS)
#undef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS SHA3_224_DIGEST_SIZE_BITS
#endif
#ifndef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE 0
#endif
#if (MAX_BLOCK_SIZE < SHA3_224_BLOCK_SIZE)
#undef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE SHA3_224_BLOCK_SIZE
#endif
#define SHA3_224_HASH_MAGIC ((word_t)(0x1234563273932916ULL))
#define SHA3_224_HASH_CHECK_INITIALIZED(A, ret, err) \
MUST_HAVE((((void *)(A)) != NULL) && ((A)->magic == SHA3_224_HASH_MAGIC), ret, err)
typedef sha3_context sha3_224_context;
ATTRIBUTE_WARN_UNUSED_RET int sha3_224_init(sha3_224_context *ctx);
ATTRIBUTE_WARN_UNUSED_RET int sha3_224_update(sha3_224_context *ctx, const u8 *input, u32 ilen);
ATTRIBUTE_WARN_UNUSED_RET int sha3_224_final(sha3_224_context *ctx, u8 output[SHA3_224_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int sha3_224_scattered(const u8 **inputs, const u32 *ilens,
u8 output[SHA3_224_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int sha3_224(const u8 *input, u32 ilen, u8 output[SHA3_224_DIGEST_SIZE]);
#endif /* __SHA3_224_H__ */
#endif /* WITH_HASH_SHA3_224 */

View file

@ -0,0 +1,69 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_HASH_SHA3_256
#ifndef __SHA3_256_H__
#define __SHA3_256_H__
#include <libecc/words/words.h>
#include <libecc/utils/utils.h>
#include <libecc/hash/sha3.h>
#define SHA3_256_BLOCK_SIZE 136
#define SHA3_256_DIGEST_SIZE 32
#define SHA3_256_DIGEST_SIZE_BITS 256
/* Compute max hash digest and block sizes */
#ifndef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE 0
#endif
#if (MAX_DIGEST_SIZE < SHA3_256_DIGEST_SIZE)
#undef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE SHA3_256_DIGEST_SIZE
#endif
#ifndef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS 0
#endif
#if (MAX_DIGEST_SIZE_BITS < SHA3_256_DIGEST_SIZE_BITS)
#undef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS SHA3_256_DIGEST_SIZE_BITS
#endif
#ifndef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE 0
#endif
#if (MAX_BLOCK_SIZE < SHA3_256_BLOCK_SIZE)
#undef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE SHA3_256_BLOCK_SIZE
#endif
#define SHA3_256_HASH_MAGIC ((word_t)(0x3452987573933416ULL))
#define SHA3_256_HASH_CHECK_INITIALIZED(A, ret, err) \
MUST_HAVE((((void *)(A)) != NULL) && ((A)->magic == SHA3_256_HASH_MAGIC), ret, err)
typedef sha3_context sha3_256_context;
ATTRIBUTE_WARN_UNUSED_RET int sha3_256_init(sha3_256_context *ctx);
ATTRIBUTE_WARN_UNUSED_RET int sha3_256_update(sha3_256_context *ctx, const u8 *input, u32 ilen);
ATTRIBUTE_WARN_UNUSED_RET int sha3_256_final(sha3_256_context *ctx, u8 output[SHA3_256_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int sha3_256_scattered(const u8 **inputs, const u32 *ilens,
u8 output[SHA3_256_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int sha3_256(const u8 *input, u32 ilen, u8 output[SHA3_256_DIGEST_SIZE]);
#endif /* __SHA3_256_H__ */
#endif /* WITH_HASH_SHA3_256 */

View file

@ -0,0 +1,69 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_HASH_SHA3_384
#ifndef __SHA3_384_H__
#define __SHA3_384_H__
#include <libecc/words/words.h>
#include <libecc/utils/utils.h>
#include <libecc/hash/sha3.h>
#define SHA3_384_BLOCK_SIZE 104
#define SHA3_384_DIGEST_SIZE 48
#define SHA3_384_DIGEST_SIZE_BITS 384
/* Compute max hash digest and block sizes */
#ifndef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE 0
#endif
#if (MAX_DIGEST_SIZE < SHA3_384_DIGEST_SIZE)
#undef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE SHA3_384_DIGEST_SIZE
#endif
#ifndef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS 0
#endif
#if (MAX_DIGEST_SIZE_BITS < SHA3_384_DIGEST_SIZE_BITS)
#undef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS SHA3_384_DIGEST_SIZE_BITS
#endif
#ifndef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE 0
#endif
#if (MAX_BLOCK_SIZE < SHA3_384_BLOCK_SIZE)
#undef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE SHA3_384_BLOCK_SIZE
#endif
#define SHA3_384_HASH_MAGIC ((word_t)(0x2233223273935643ULL))
#define SHA3_384_HASH_CHECK_INITIALIZED(A, ret, err) \
MUST_HAVE((((void *)(A)) != NULL) && ((A)->magic == SHA3_384_HASH_MAGIC), ret, err)
typedef sha3_context sha3_384_context;
ATTRIBUTE_WARN_UNUSED_RET int sha3_384_init(sha3_384_context *ctx);
ATTRIBUTE_WARN_UNUSED_RET int sha3_384_update(sha3_384_context *ctx, const u8 *input, u32 ilen);
ATTRIBUTE_WARN_UNUSED_RET int sha3_384_final(sha3_384_context *ctx, u8 output[SHA3_384_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int sha3_384_scattered(const u8 **inputs, const u32 *ilens,
u8 output[SHA3_384_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int sha3_384(const u8 *input, u32 ilen, u8 output[SHA3_384_DIGEST_SIZE]);
#endif /* __SHA3_384_H__ */
#endif /* WITH_HASH_SHA3_384 */

View file

@ -0,0 +1,69 @@
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <ryadbenadjila@gmail.com>
* Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
* Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
*
* Contributors:
* Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
* Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include <libecc/lib_ecc_config.h>
#ifdef WITH_HASH_SHA3_512
#ifndef __SHA3_512_H__
#define __SHA3_512_H__
#include <libecc/words/words.h>
#include <libecc/utils/utils.h>
#include "sha3.h"
#define SHA3_512_BLOCK_SIZE 72
#define SHA3_512_DIGEST_SIZE 64
#define SHA3_512_DIGEST_SIZE_BITS 512
/* Compute max hash digest and block sizes */
#ifndef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE 0
#endif
#if (MAX_DIGEST_SIZE < SHA3_512_DIGEST_SIZE)
#undef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE SHA3_512_DIGEST_SIZE
#endif
#ifndef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS 0
#endif
#if (MAX_DIGEST_SIZE_BITS < SHA3_512_DIGEST_SIZE_BITS)
#undef MAX_DIGEST_SIZE_BITS
#define MAX_DIGEST_SIZE_BITS SHA3_512_DIGEST_SIZE_BITS
#endif
#ifndef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE 0
#endif
#if (MAX_BLOCK_SIZE < SHA3_512_BLOCK_SIZE)
#undef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE SHA3_512_BLOCK_SIZE
#endif
#define SHA3_512_HASH_MAGIC ((word_t)(0x9104729373982346ULL))
#define SHA3_512_HASH_CHECK_INITIALIZED(A, ret, err) \
MUST_HAVE((((void *)(A)) != NULL) && ((A)->magic == SHA3_512_HASH_MAGIC), ret, err)
typedef sha3_context sha3_512_context;
ATTRIBUTE_WARN_UNUSED_RET int sha3_512_init(sha3_512_context *ctx);
ATTRIBUTE_WARN_UNUSED_RET int sha3_512_update(sha3_512_context *ctx, const u8 *input, u32 ilen);
ATTRIBUTE_WARN_UNUSED_RET int sha3_512_final(sha3_512_context *ctx, u8 output[SHA3_512_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int sha3_512_scattered(const u8 **inputs, const u32 *ilens,
u8 output[SHA3_512_DIGEST_SIZE]);
ATTRIBUTE_WARN_UNUSED_RET int sha3_512(const u8 *input, u32 ilen, u8 output[SHA3_512_DIGEST_SIZE]);
#endif /* __SHA3_512_H__ */
#endif /* WITH_HASH_SHA3_512 */

Some files were not shown because too many files have changed in this diff Show more