Skip to content

Commit

Permalink
working C pqcp-mlkem
Browse files Browse the repository at this point in the history
Signed-off-by: Basil Hess <[email protected]>
  • Loading branch information
bhess committed Dec 9, 2024
1 parent d0d0413 commit 28d2932
Show file tree
Hide file tree
Showing 257 changed files with 15,578 additions and 17,484 deletions.
18 changes: 0 additions & 18 deletions .CMake/alg_support.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -332,24 +332,6 @@ endif()
endif()


if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin")
if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_POPCNT_INSTRUCTIONS))
cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_512_avx2 "" ON "OQS_ENABLE_KEM_ml_kem_512" OFF)
endif()
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin")
if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_POPCNT_INSTRUCTIONS))
cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_768_avx2 "" ON "OQS_ENABLE_KEM_ml_kem_768" OFF)
endif()
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin")
if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_POPCNT_INSTRUCTIONS))
cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_1024_avx2 "" ON "OQS_ENABLE_KEM_ml_kem_1024" OFF)
endif()
endif()


if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux")
if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_POPCNT_INSTRUCTIONS))
Expand Down
5 changes: 1 addition & 4 deletions docs/algorithms/kem/ml_kem.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- **Authors' website**: https://pq-crystals.org/kyber/ and https://csrc.nist.gov/pubs/fips/203
- **Specification version**: ML-KEM.
- **Primary Source**<a name="primary-source"></a>:
- **Source**: https://github.com/pq-crystals/kyber/commit/10b478fc3cc4ff6215eb0b6a11bd758bf0929cbd with copy_from_upstream patches
- **Source**: https://github.com/bhess/mlkem-native/commit/2b650d6676bf6a3a82ab7e9ecd96acd397ca71cd
- **Implementation license (SPDX-Identifier)**: CC0-1.0 or Apache-2.0


Expand All @@ -24,7 +24,6 @@
| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage?‡ |
|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:----------------------|
| [Primary Source](#primary-source) | ref | All | All | None | True | True | False |
| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,POPCNT | True | True | False |

Are implementations chosen based on runtime CPU feature detection? **Yes**.

Expand All @@ -35,7 +34,6 @@ Are implementations chosen based on runtime CPU feature detection? **Yes**.
| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? |
|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------|
| [Primary Source](#primary-source) | ref | All | All | None | True | True | False |
| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,POPCNT | True | True | False |

Are implementations chosen based on runtime CPU feature detection? **Yes**.

Expand All @@ -44,7 +42,6 @@ Are implementations chosen based on runtime CPU feature detection? **Yes**.
| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? |
|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------|
| [Primary Source](#primary-source) | ref | All | All | None | True | True | False |
| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,POPCNT | True | True | False |

Are implementations chosen based on runtime CPU feature detection? **Yes**.

Expand Down
51 changes: 1 addition & 50 deletions docs/algorithms/kem/ml_kem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ website: https://pq-crystals.org/kyber/ and https://csrc.nist.gov/pubs/fips/203
nist-round: FIPS203
spec-version: ML-KEM
primary-upstream:
source: https://github.com/pq-crystals/kyber/commit/10b478fc3cc4ff6215eb0b6a11bd758bf0929cbd
with copy_from_upstream patches
source: https://github.com/bhess/mlkem-native/commit/2b650d6676bf6a3a82ab7e9ecd96acd397ca71cd
spdx-license-identifier: CC0-1.0 or Apache-2.0
parameter-sets:
- name: ML-KEM-512
Expand All @@ -38,22 +37,6 @@ parameter-sets:
no-secret-dependent-branching-claimed: true
no-secret-dependent-branching-checked-by-valgrind: true
large-stack-usage: false
- upstream: primary-upstream
upstream-id: avx2
supported-platforms:
- architecture: x86_64
operating_systems:
- Linux
- Darwin
required_flags:
- avx2
- bmi2
- popcnt
common-crypto:
- SHA3: liboqs
no-secret-dependent-branching-claimed: true
no-secret-dependent-branching-checked-by-valgrind: true
large-stack-usage: false
- name: ML-KEM-768
claimed-nist-level: 3
claimed-security: IND-CCA2
Expand All @@ -71,22 +54,6 @@ parameter-sets:
no-secret-dependent-branching-claimed: true
no-secret-dependent-branching-checked-by-valgrind: true
large-stack-usage: false
- upstream: primary-upstream
upstream-id: avx2
supported-platforms:
- architecture: x86_64
operating_systems:
- Linux
- Darwin
required_flags:
- avx2
- bmi2
- popcnt
common-crypto:
- SHA3: liboqs
no-secret-dependent-branching-claimed: true
no-secret-dependent-branching-checked-by-valgrind: true
large-stack-usage: false
- name: ML-KEM-1024
claimed-nist-level: 5
claimed-security: IND-CCA2
Expand All @@ -104,19 +71,3 @@ parameter-sets:
no-secret-dependent-branching-claimed: true
no-secret-dependent-branching-checked-by-valgrind: true
large-stack-usage: false
- upstream: primary-upstream
upstream-id: avx2
supported-platforms:
- architecture: x86_64
operating_systems:
- Linux
- Darwin
required_flags:
- avx2
- bmi2
- popcnt
common-crypto:
- SHA3: liboqs
no-secret-dependent-branching-claimed: true
no-secret-dependent-branching-checked-by-valgrind: true
large-stack-usage: false
95 changes: 7 additions & 88 deletions docs/cbom.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
"$schema": "https://raw.githubusercontent.com/CycloneDX/specification/1.6/schema/bom-1.6.schema.json",
"bomFormat": "CycloneDX",
"specVersion": "1.6",
"serialNumber": "urn:uuid:de1355bb-9681-4a7e-8aa9-0ccc414ebe3b",
"serialNumber": "urn:uuid:d66add05-17dd-4986-8894-ed47d1e910b6",
"version": 1,
"metadata": {
"timestamp": "2024-11-05T12:25:53.012740+00:00",
"timestamp": "2024-12-09T14:24:28.343759+00:00",
"component": {
"type": "library",
"bom-ref": "pkg:github/open-quantum-safe/liboqs@69a80f8a66988521d51e94d716cff8c936c07b8d",
"bom-ref": "pkg:github/open-quantum-safe/liboqs@d0d0413dc9fff538296ab86bac492cb4bf54dedb",
"name": "liboqs",
"version": "69a80f8a66988521d51e94d716cff8c936c07b8d"
"version": "d0d0413dc9fff538296ab86bac492cb4bf54dedb"
}
},
"components": [
{
"type": "library",
"bom-ref": "pkg:github/open-quantum-safe/liboqs@69a80f8a66988521d51e94d716cff8c936c07b8d",
"bom-ref": "pkg:github/open-quantum-safe/liboqs@d0d0413dc9fff538296ab86bac492cb4bf54dedb",
"name": "liboqs",
"version": "69a80f8a66988521d51e94d716cff8c936c07b8d"
"version": "d0d0413dc9fff538296ab86bac492cb4bf54dedb"
},
{
"type": "cryptographic-asset",
Expand Down Expand Up @@ -1060,26 +1060,6 @@
}
}
},
{
"type": "cryptographic-asset",
"bom-ref": "alg:ML-KEM-512:x86_64",
"name": "ML-KEM",
"cryptoProperties": {
"assetType": "algorithm",
"algorithmProperties": {
"parameterSetIdentifier": "ML-KEM-512",
"primitive": "kem",
"executionEnvironment": "software-plain-ram",
"cryptoFunctions": [
"keygen",
"encapsulate",
"decapsulate"
],
"nistQuantumSecurityLevel": 1,
"implementationPlatform": "x86_64"
}
}
},
{
"type": "cryptographic-asset",
"bom-ref": "alg:ML-KEM-768:generic",
Expand All @@ -1100,26 +1080,6 @@
}
}
},
{
"type": "cryptographic-asset",
"bom-ref": "alg:ML-KEM-768:x86_64",
"name": "ML-KEM",
"cryptoProperties": {
"assetType": "algorithm",
"algorithmProperties": {
"parameterSetIdentifier": "ML-KEM-768",
"primitive": "kem",
"executionEnvironment": "software-plain-ram",
"cryptoFunctions": [
"keygen",
"encapsulate",
"decapsulate"
],
"nistQuantumSecurityLevel": 3,
"implementationPlatform": "x86_64"
}
}
},
{
"type": "cryptographic-asset",
"bom-ref": "alg:ML-KEM-1024:generic",
Expand All @@ -1140,26 +1100,6 @@
}
}
},
{
"type": "cryptographic-asset",
"bom-ref": "alg:ML-KEM-1024:x86_64",
"name": "ML-KEM",
"cryptoProperties": {
"assetType": "algorithm",
"algorithmProperties": {
"parameterSetIdentifier": "ML-KEM-1024",
"primitive": "kem",
"executionEnvironment": "software-plain-ram",
"cryptoFunctions": [
"keygen",
"encapsulate",
"decapsulate"
],
"nistQuantumSecurityLevel": 5,
"implementationPlatform": "x86_64"
}
}
},
{
"type": "cryptographic-asset",
"bom-ref": "alg:sntrup761:generic",
Expand Down Expand Up @@ -3127,7 +3067,7 @@
],
"dependencies": [
{
"ref": "pkg:github/open-quantum-safe/liboqs@69a80f8a66988521d51e94d716cff8c936c07b8d",
"ref": "pkg:github/open-quantum-safe/liboqs@d0d0413dc9fff538296ab86bac492cb4bf54dedb",
"provides": [
"alg:BIKE-L1:x86_64",
"alg:BIKE-L3:x86_64",
Expand Down Expand Up @@ -3181,11 +3121,8 @@
"alg:Kyber1024:x86_64",
"alg:Kyber1024:armv8-a",
"alg:ML-KEM-512:generic",
"alg:ML-KEM-512:x86_64",
"alg:ML-KEM-768:generic",
"alg:ML-KEM-768:x86_64",
"alg:ML-KEM-1024:generic",
"alg:ML-KEM-1024:x86_64",
"alg:sntrup761:generic",
"alg:sntrup761:x86_64",
"alg:cross-rsdp-128-balanced:generic",
Expand Down Expand Up @@ -3605,36 +3542,18 @@
"alg:sha3"
]
},
{
"ref": "alg:ML-KEM-512:x86_64",
"dependsOn": [
"alg:sha3"
]
},
{
"ref": "alg:ML-KEM-768:generic",
"dependsOn": [
"alg:sha3"
]
},
{
"ref": "alg:ML-KEM-768:x86_64",
"dependsOn": [
"alg:sha3"
]
},
{
"ref": "alg:ML-KEM-1024:generic",
"dependsOn": [
"alg:sha3"
]
},
{
"ref": "alg:ML-KEM-1024:x86_64",
"dependsOn": [
"alg:sha3"
]
},
{
"ref": "alg:sntrup761:generic",
"dependsOn": [
Expand Down
9 changes: 8 additions & 1 deletion scripts/copy_from_upstream/copy_from_upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ upstreams:
kem_meta_path: '{pretty_name_full}_META.yml'
kem_scheme_path: '.'
patches: [pqcrystals-ml_kem.patch]
-
name: mlkem-native
git_url: https://github.com/bhess/mlkem-native.git
git_branch: updates
git_commit: 14141720b0149cad6c2f91b037e3e6a15882840c
kem_meta_path: '{pretty_name_full}_META.yml'
kem_scheme_path: '.'
-
name: pqcrystals-dilithium
git_url: https://github.com/pq-crystals/dilithium.git
Expand Down Expand Up @@ -166,7 +173,7 @@ kems:
-
name: ml_kem
default_implementation: ref
upstream_location: pqcrystals-kyber-standard
upstream_location: mlkem-native
schemes:
-
scheme: "512"
Expand Down
Loading

0 comments on commit 28d2932

Please sign in to comment.