Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS license removal for SIKE #240

Merged
merged 6 commits into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 37 additions & 49 deletions pq-crypto/EVP_kem.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
#include <stdint.h>
#include "sike_r3/sike_internal.h"

// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Name: pq_kem
//
// Description: Keeps track of pq algorithm specific
// constants which are length of public key, private key,
// cipher text, and shared secret. Also contains pointers
// to the specific algorithms required.
// -----------------------------------------------------------------------------
// Description: Keeps track of pq algorithm specific constants
// which are length of public key, private key, cipher text, and shared secret.
// Also contains pointers to the specific algorithms required.
// ----------------------------------------------------------------------------
typedef struct pq_kem {
// name of pq algorithm specific KEM
const char *name;
Expand All @@ -40,15 +39,14 @@ typedef struct pq_kem {



// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Name: pq_kem_params
//
// Description: Keeps track of the actual keys and
// secrets that are pq algorithm specific.
// They are public key, private key,
// cipher text, and shared secret. Also points
// to the algorithm specific pq_kem struct
// -----------------------------------------------------------------------------
// Description: Keeps track of the actual keys and secrets
// that are pq algorithm specific.
// They are public key, private key, cipher text, and shared secret.
// Also points to the algorithm specific pq_kem struct
// ----------------------------------------------------------------------------
typedef struct pq_kem_params {
pq_kem *kem;
unsigned char *public_key;
Expand All @@ -59,87 +57,77 @@ typedef struct pq_kem_params {

extern const struct pq_kem evp_sike_p434_r3;

// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Name: pq_kem_params_alloc
//
// Arguments: pointer to pq_kem and pq_kem_params.
// pq_kem_params allows access to the lengths and key pointer (output param)
// of public key, private key, cipher text,
// and shared secret.
// Description: Allocates the space needed for
// public key, private key, cipher text,
// and shared secret.
// of public key, private key, cipher text, and shared secret.
//
// Description: Allocates the space needed for public key,
// private key, cipher text, and shared secret.
//
// Return 1 on success, and 0 if it fails.
// -----------------------------------------------------------------------------
// ---------------------------------------------------------------------------
int pq_kem_params_alloc(pq_kem *kem, pq_kem_params *kem_params);

// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Name: pq_kem_params_free
//
// Arguments: pointer to pq_kem_params.
// pq_kem_params allows access to the lenghts and key pointer (output param)
// of public key, private key, cipher text,
// and shared secret.
// Description: Frees space of
// public key, private key, cipher text,
// pq_kem_params allows access to the lengths and key pointer (output param)
// of public key, private key, cipher text, and shared secret.
//
// Description: Frees space of public key, private key, cipher text,
// and shared secret.
//
// Return 1 on success, and 0 if it fails
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
int pq_kem_params_free(pq_kem_params *kem_params);

// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Name: EVP_kem_generate_keypair
//
// Description: Generates a public and private key
//
// Arguments: pq_kem_params
// The following fields of pq_kem_params are used for generate keypair:
// - unsigned char *public_key: pointer to output public key
// (already allocated array of bytes)
// - unsigned char *private_key: pointer to output secret key
// (already allocated array of bytes)
//
// Returns 1 on successfully generating key pair,
// returns 0 otherwise and on error
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
int EVP_kem_generate_keypair(pq_kem_params *kem_params);

// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Name: EVP_kem_enc
//
// Description: Uses public key to create cipher text and secrect key.
// Description: Uses public key to create cipher text and secret key.
//
// Arguments: pq_kem_params
// The following fields of pq_kem_params are used for encapsualte:
// The following fields of pq_kem_params are used for encapsulate:
// - unsigned char *cipher_text: pointer to output cipher text
// (already allocated array of bytes)
// - unsigned char *shared_secret: pointer to output shared secrect
// (already allocated array of bytes)
// - const unsigned char *public_key: pointer to input constant public key
// - unsigned char *shared_secret: pointer to output shared secret
// - unsigned char *public_key: pointer to input constant public key
//
// Returns 1 on successful encapsulation,
// return 0 otherwise and on error
// -----------------------------------------------------------------------------
// Returns 1 on successful encapsulation, return 0 otherwise and on error
// ----------------------------------------------------------------------------
int EVP_kem_encapsulate(pq_kem_params *kem_params);

// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Name: EVP_kem_dec
//
// Description: Generates shared secret for public key and cipher text
// Description: Generates shared secret using private key and cipher text
//
// Arguments: pq_kem_params
// The following fields of pq_kem_params are used for decapsulate:
// - unsigned char *shared_secret: pointer to output shared secret
// (already allocated array of bytes)
// - unsigned char *cipher_text: pointer to input cipher text
// (already allocated array of bytes)
// - const unsigned char *private_key: pointer to input constant private key
// - unsigned char *private_key: pointer to input constant private key
//
// Returns 1 on successful decapsulation,
// return 0 otherwise and on error
// -----------------------------------------------------------------------------
// Returns 1 on successful decapsulation, return 0 otherwise and on error
// ----------------------------------------------------------------------------
int EVP_kem_decapsulate(pq_kem_params *kem_params);

#endif // AWSLC_EVP_KEM_H
2 changes: 1 addition & 1 deletion pq-crypto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ see more info on the [NIST website](https://csrc.nist.gov/Projects/Post-Quantum-

## SIKE (Supersingular Isogeny Key Encapsulation)
The code in the pq-crypto/sike_r3 directory was moved from [S2N](https://github.com/aws/s2n-tls/tree/main/pq-crypto),
which imports code from [SIKE'S](https://sike.org/#nist-submission) repository.
which imports code from [SIKE's](https://github.com/microsoft/PQCrypto-SIDH) repository.
21 changes: 21 additions & 0 deletions pq-crypto/sike_r3/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Microsoft Corporation. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
5 changes: 3 additions & 2 deletions pq-crypto/sike_r3/sike_internal.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// -----------------------------------------------------------------------------
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Supersingular Isogeny Key Encapsulation Library
//
// Abstract: supersingular isogeny key encapsulation (SIKE) protocol
// -----------------------------------------------------------------------------

#ifndef PQ_CRYPTO_SIKE_INTERNAL_H
Expand Down
3 changes: 0 additions & 3 deletions pq-crypto/sike_r3/sikep434r3.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// -----------------------------------------------------------------------------
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Supersingular Isogeny Key Encapsulation Library
//
// Abstract: supersingular isogeny parameters and generation of functions for P434
Expand Down
3 changes: 0 additions & 3 deletions pq-crypto/sike_r3/sikep434r3.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// -----------------------------------------------------------------------------
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Supersingular Isogeny Key Encapsulation Library
//
// Abstract: supersingular isogeny parameters, generation of functions for P434;
Expand Down
3 changes: 0 additions & 3 deletions pq-crypto/sike_r3/sikep434r3_api.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// -----------------------------------------------------------------------------
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Supersingular Isogeny Key Encapsulation Library
//
// Abstract: API header file for P434
Expand Down
3 changes: 0 additions & 3 deletions pq-crypto/sike_r3/sikep434r3_ec_isogeny.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// -----------------------------------------------------------------------------
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Supersingular Isogeny Key Encapsulation Library
//
// Abstract: elliptic curve and isogeny functions
Expand Down
3 changes: 0 additions & 3 deletions pq-crypto/sike_r3/sikep434r3_ec_isogeny.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// -----------------------------------------------------------------------------
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Supersingular Isogeny Key Encapsulation Library
//
// Abstract: elliptic curve and isogeny functions
Expand Down
3 changes: 0 additions & 3 deletions pq-crypto/sike_r3/sikep434r3_fips202.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// -----------------------------------------------------------------------------
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// SHA3-derived function SHAKE
//
// Based on the public domain implementation in crypto_hash/keccakc512/simple/
Expand Down
3 changes: 0 additions & 3 deletions pq-crypto/sike_r3/sikep434r3_fips202.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// -----------------------------------------------------------------------------
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// SHA3-derived function SHAKE
//
// Based on the public domain implementation in crypto_hash/keccakc512/simple/
Expand Down
4 changes: 0 additions & 4 deletions pq-crypto/sike_r3/sikep434r3_fp.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// -----------------------------------------------------------------------------
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Supersingular Isogeny Key Encapsulation Library
//
// Abstract: modular arithmetic for P434
// Here the assembly implementations have been turned off
// -----------------------------------------------------------------------------

#include "sikep434r3.h"
Expand Down
3 changes: 0 additions & 3 deletions pq-crypto/sike_r3/sikep434r3_fp.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// -----------------------------------------------------------------------------
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Supersingular Isogeny Key Encapsulation Library
//
// Abstract: modular arithmetic for P434
Expand Down
3 changes: 0 additions & 3 deletions pq-crypto/sike_r3/sikep434r3_fpx.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// -----------------------------------------------------------------------------
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Supersingular Isogeny Key Encapsulation Library
//
// Abstract: core functions over GF(p) and GF(p^2)
Expand Down
3 changes: 0 additions & 3 deletions pq-crypto/sike_r3/sikep434r3_fpx.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// -----------------------------------------------------------------------------
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Supersingular Isogeny Key Encapsulation Library
//
// Abstract: core functions over GF(p) and GF(p^2)
Expand Down
5 changes: 0 additions & 5 deletions pq-crypto/sike_r3/sikep434r3_kem.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// -----------------------------------------------------------------------------
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Supersingular Isogeny Key Encapsulation Library
//
// Abstract: supersingular isogeny key encapsulation (SIKE) protocol
// NOTE: Currently the use of constant time functions to copy and compare has been
// replaced with memcpy and memcmp as a work around.
// -----------------------------------------------------------------------------

#include <string.h>
Expand Down
3 changes: 0 additions & 3 deletions pq-crypto/sike_r3/sikep434r3_sidh.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// -----------------------------------------------------------------------------
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Supersingular Isogeny Key Encapsulation Library
//
// Abstract: ephemeral supersingular isogeny Diffie-Hellman key exchange (SIDH)
Expand Down