Class CertGenerator
java.lang.Object
pt.unl.fct.di.novasys.babel2.ssl.CertGenerator
Generator for ephemeral X.509 certificates carrying a long-term peer identity extension.
Following the libp2p TLS specification pattern (RFC 9364), nodes generate an ephemeral EC key pair and certificate for the TLS session (QUIC or TCP). The certificate embeds a critical custom X.509 extension (OID "2.25.143997576564619623049175376840488616895") containing:
- The node's long-term static public key.
- A digital signature of the ephemeral TLS public key produced by the long-term private key.
During connection establishment, the remote peer verifies that the certificate was signed by the ephemeral key, extracts the identity extension, verifies the signature using the static public key, and authenticates the peer ID against authorized identities.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordKey material containing the ephemeral private key, the generated self-signed certificate, and the long-term identity public key. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringCustom X.509 extension OID used to carry the node's long-term identity public key and signature over the ephemeral TLS public key. -
Method Summary
Modifier and TypeMethodDescriptionstatic CertGenerator.KeyMaterialgenerate()Generates an ephemeral key pair and self-signed certificate using a newly created identity key pair.static CertGenerator.KeyMaterialGenerates an ephemeral EC key pair and a self-signed certificate embedding the given long-term identity public key and its signature over the ephemeral key.static KeyPairGenerates a new long-term identity key pair defined byCryptoUtils.DEFAULT_KEY_ALGORITHM.static StringgetSignatureAlgorithm(String keyAlgorithm) Resolves the appropriate signature algorithm corresponding to a private or public key algorithm.
-
Field Details
-
BABEL2_TLS_OID
Custom X.509 extension OID used to carry the node's long-term identity public key and signature over the ephemeral TLS public key.- See Also:
-
-
Method Details
-
generateIdentityKeyPair
Generates a new long-term identity key pair defined byCryptoUtils.DEFAULT_KEY_ALGORITHM.- Returns:
- a newly generated
KeyPair - Throws:
IllegalStateException- ifCryptoUtils.DEFAULT_KEY_ALGORITHMis not supported by the environment
-
generate
Generates an ephemeral key pair and self-signed certificate using a newly created identity key pair.- Returns:
- the generated
CertGenerator.KeyMaterialcontaining ephemeral private key and certificate - Throws:
Exception- if key generation or certificate building fails
-
generate
Generates an ephemeral EC key pair and a self-signed certificate embedding the given long-term identity public key and its signature over the ephemeral key.- Parameters:
identityKeyPair- the node's long-term static identity key pair- Returns:
- the generated
CertGenerator.KeyMaterial - Throws:
Exception- if cryptographic operations fail
-
getSignatureAlgorithm
-