Repository navigation
feat(crypto): import PEM keys and validate symmetric key length - #393
Open
abdullahelmarghany wants to merge 1 commit into
Open
abdullahelmarghany wants to merge 1 commit into
abdullahelmarghany wants to merge 1 commit into
Conversation
abdullahelmarghany
had a problem deploying
to
workflow-approval
November 10, 2026 10:39 — with
GitHub Actions
Error
abdullahelmarghany
had a problem deploying
to
workflow-approval
November 10, 2026 10:39 — with
GitHub Actions
Error
abdullahelmarghany
had a problem deploying
to
workflow-approval
November 10, 2026 10:39 — with
GitHub Actions
Error
Contributor
License Check Results🚀 The license check job ran with the Bazel command: bazel run --lockfile_mode=error //:license-checkStatus: Click to expand output |
Contributor
|
Documentation preview for this pull request is available at: |
abdullahelmarghany
force-pushed
the
feat/wp3-import-validation
branch
from
November 12, 2026 15:10
1f9064b to
b3e50d2
Compare
abdullahelmarghany
had a problem deploying
to
workflow-approval
November 12, 2026 15:10 — with
GitHub Actions
Error
abdullahelmarghany
had a problem deploying
to
workflow-approval
November 12, 2026 15:10 — with
GitHub Actions
Error
abdullahelmarghany
had a problem deploying
to
workflow-approval
November 12, 2026 15:10 — with
GitHub Actions
Error
abdullahelmarghany
force-pushed
the
feat/wp3-import-validation
branch
from
November 16, 2026 12:45
b3e50d2 to
9fada7d
Compare
abdullahelmarghany
had a problem deploying
to
workflow-approval
November 16, 2026 12:45 — with
GitHub Actions
Error
abdullahelmarghany
had a problem deploying
to
workflow-approval
November 16, 2026 12:45 — with
GitHub Actions
Error
abdullahelmarghany
had a problem deploying
to
workflow-approval
November 16, 2026 12:45 — with
GitHub Actions
Error
abdullahelmarghany
marked this pull request as ready for review
November 16, 2026 15:10
abdullahelmarghany
requested review from
ChansAlive,
PandaeDo and
masc2023
as code owners
November 16, 2026 15:10
abdullahelmarghany
force-pushed
the
feat/wp3-import-validation
branch
from
November 23, 2026 10:30
9fada7d to
8856f60
Compare
abdullahelmarghany
had a problem deploying
to
workflow-approval
November 23, 2026 10:30 — with
GitHub Actions
Error
abdullahelmarghany
had a problem deploying
to
workflow-approval
November 23, 2026 10:30 — with
GitHub Actions
Error
abdullahelmarghany
had a problem deploying
to
workflow-approval
November 23, 2026 10:30 — with
GitHub Actions
Error
abdullahelmarghany
force-pushed
the
feat/wp3-import-validation
branch
from
November 25, 2026 10:00
8856f60 to
73a3f38
Compare
abdullahelmarghany
had a problem deploying
to
workflow-approval
November 25, 2026 10:00 — with
GitHub Actions
Error
abdullahelmarghany
had a problem deploying
to
workflow-approval
November 25, 2026 10:00 — with
GitHub Actions
Error
abdullahelmarghany
had a problem deploying
to
workflow-approval
November 25, 2026 10:00 — with
GitHub Actions
Error
Symmetric key import accepted any byte count and ignored the requested format. Asymmetric import accepted DER only, and every caller had to name a format even when the key type fixes it. ImportKeyParams::format is now std::optional<FormatType>, unset by default. Unset means the native format of the key type: raw bytes for AES/HMAC, and for asymmetric keys PEM (data starting with "-----BEGIN"), an uncompressed EC point (leading 0x04, EC algorithms only) or DER. Detection only picks the parser; curve, modulus and type checks still apply. An explicit format stays strict. On the IPC the unset format is sent as operations::kFormatNative (0xFFFFFFFF), with EncodeFormat / DecodeFormat in key_management_operations.hpp; any other value outside FormatType is rejected instead of being cast. Symmetric imports go through a shared IKeyFactory::ValidateSymmetricImport, which both the OpenSSL and the PKCS#11 factory use. The format must be unset or kRaw, otherwise the import fails with kInvalidFormat. An AES key must be exactly 16/24/32 bytes and an HMAC key at least as long as its digest, otherwise the import fails with kIncompatibleKeyType. The file-backed slot handler maps the deployment "key_format" property raw/der/pem to that format, maps an absent property to the native format, and fails the load for any other value. The OpenSSL factory decodes one unencrypted PEM block labelled PRIVATE KEY, EC PRIVATE KEY, RSA PRIVATE KEY or PUBLIC KEY. Encrypted PEM, unknown labels, data around the block and a label that disagrees with the key are rejected. PEM_FLAG_SECURE keeps the decoded body on the secure heap, and no passphrase callback is ever invoked. PKCS#11 asymmetric import stays unsupported. Tests: - OpenSSL key factory unit tests for the symmetric rules, PEM import, native-format import for each key family, and file-backed slot loading with absent, raw, der, pem and unknown key_format. - A request parser test for the format wire encoding. - Integration tests for native and explicit AES-256 import and for PEM, DER and raw-point public key import with raw export. - PEM test vectors derived from the existing NIST DER vectors. Signed-off-by: Abdullah Elmarghany <abdullah.elmarghany@bmw.de>
abdullahelmarghany
force-pushed
the
feat/wp3-import-validation
branch
from
November 27, 2026 15:04
73a3f38 to
508288a
Compare
abdullahelmarghany
requested a deployment
to
workflow-approval
November 27, 2026 15:04 — with
GitHub Actions
Waiting
abdullahelmarghany
requested a deployment
to
workflow-approval
November 27, 2026 15:04 — with
GitHub Actions
Waiting
abdullahelmarghany
requested a deployment
to
workflow-approval
November 27, 2026 15:04 — with
GitHub Actions
Waiting
This branch is waiting to be deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symmetric key import accepted any byte count and ignored the requested format. Asymmetric import accepted DER only, and every caller had to name a format even when the key type fixes it.
ImportKeyParams::formatis nowstd::optional<FormatType>, unset by default. Unset means the native format of the key type: raw bytes for AES/HMAC; for asymmetric keys PEM, an uncompressed EC point (EC only) or DER, detected from the data. Detection only picks the parser; curve, modulus and type checks still apply. An explicit format stays strict.operations::kFormatNative(0xFFFFFFFF). Any other value outsideFormatTypeis rejected instead of being cast.IKeyFactory::ValidateSymmetricImport: format unset orkRaw, elsekInvalidFormat; AES exactly 16/24/32 bytes and HMAC at least the digest length, elsekIncompatibleKeyType.key_formatdeployment property (raw/der/pem); absent means native format, any other value fails the load.kInvalidArgument. A slot whose material is refused at load (for example, a 16-byte key labelled AES-256) now reportskIncompatibleKeyType, whichKeySlotBindingTestfrom feat(crypto): refuse keys that do not fit the context algorithm #345 expects.Tests: OpenSSL key factory unit tests (symmetric rules, PEM, native format per key family, slot loading with each
key_format), a request parser test for the format encoding, integration tests for AES-256 and PEM/DER/raw-point public key import, and PEM vectors derived from the existing NIST DER vectors.