Repository navigation
feat(crypto): export public keys as SPKI DER/PEM - #394
Open
abdullahelmarghany wants to merge 2 commits into
Open
abdullahelmarghany wants to merge 2 commits into
abdullahelmarghany wants to merge 2 commits 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-export
branch
from
November 12, 2026 15:10
3f8afd8 to
7a62c9a
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-export
branch
from
November 16, 2026 12:45
7a62c9a to
78919fb
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 17, 2026 10:05
abdullahelmarghany
requested review from
ChansAlive,
PandaeDo and
masc2023
as code owners
November 17, 2026 10:05
abdullahelmarghany
force-pushed
the
feat/wp3-export
branch
from
November 23, 2026 10:30
78919fb to
14d73c5
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-export
branch
from
November 25, 2026 10:00
14d73c5 to
8fe2385
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>
The OpenSSL key factory only exported EC public keys as a raw point. Asymmetric keys (EC, RSA, Ed25519) now export their public half as SubjectPublicKeyInfo in DER or PEM, or for EC as the raw point. The export format is now optional: std::nullopt (wire kFormatNative) asks for the provider's native format, which is DER SPKI for public keys. The export handlers parse it with ExtractOptionalFormat, so the ExtractFormatOrDefault helper is removed. Private and secret key material is never exported in plaintext; it can only leave wrapped. Every client-visible refusal is kKeyNotExportable: a public key without kExport, any symmetric key, and secret keys on the PKCS#11 provider. GetExportKeySize refuses the same way. ExportKey and GetExportKeySize share one encoding function, so the size query always matches the exported length. Signed-off-by: Abdullah Elmarghany <abdullah.elmarghany@bmw.de>
abdullahelmarghany
force-pushed
the
feat/wp3-export
branch
from
November 27, 2026 15:04
8fe2385 to
176ad54
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.
Depends on #393; only the last commit is new.
The OpenSSL key factory only exported EC public keys as a raw point.
kFormatNative) asks for the provider's native format, DER SPKI for public keys.kKeyNotExportable: a public key withoutkExport, any symmetric key, and secret keys on PKCS#11.GetExportKeySizerefuses the same way.ExportKeyandGetExportKeySizeshare one encoder, so the size query always matches the exported length.Tests: OpenSSL key handler tests (SPKI DER/PEM for every asymmetric key type matching the size query, P-256 SPKI matching OpenSSL and re-importing, raw export refused for non-EC keys, refusals without
kExportand for secret keys), a PKCS#11 secret-key export refusal, and integration tests (DER round trip, PEM size-then-data, unset format gives DER SPKI, secret key export refused).