Crypt::PK::X448(3)
π Crypt::PK::X448 β the Crypt::PK::X448(3) era π
okay so bestie, picture this: asymmetric cryptography based on X448, and it lives in a Perl module called Crypt::PK::X448. That's the whole vibe. It's a user-contributed Perl module, and it's about to be your new hyperfixation. π¦
β¨ SYNOPSIS β¨
use Crypt::PK::X448;
my $alice = Crypt::PK::X448->new->generate_key;
my $bob = Crypt::PK::X448->new->generate_key;
my $alice_secret = $alice->shared_secret($bob);
my $bob_secret = $bob->shared_secret($alice);
die "ERROR" unless $alice_secret eq $bob_secret;
my $pk = Crypt::PK::X448->new;
$pk->import_key_raw(
pack("H*", "cf807ab0fc3efa03108469f29e499db2eefefeb12544d8d4e711f187385aaf31b4f38c8f84a3dd9e43da309fd410c3816a50e644b5500c05"),
"public",
);
my $sk = Crypt::PK::X448->new;
$sk->import_key_raw(
pack("H*", "10d418b111401956abc5a92c2fbb8406d1d646ba930fdefa2108efe68f2000973755aa952be018f640947c05135fbf9925ebd4da828d86ec"),
"private",
);
my $generated = Crypt::PK::X448->new->generate_key;
my $private_der = $generated->export_key_der('private');
my $public_pem = $generated->export_key_pem('public');
my $private_jwk = $generated->export_key_jwk('private');
like, look at Alice and Bob deriving the same secret and the die "ERROR" there as the vibe check. iconic behaviour, no notes. π₯
πΈ DESCRIPTION πΈ
Since: CryptX-0.089 β yes she's been around, yes she ate. π
π METHODS π
π new
my $source = Crypt::PK::X448->new();
$source->generate_key;
my $public_der = $source->export_key_der('public');
my $pub = Crypt::PK::X448->new(\$public_der);
my $private_pem = $source->export_key_pem('private', 'secret', 'AES-256-CBC');
my $priv = Crypt::PK::X448->new(\$private_pem, 'secret');
okay so passing $filename or "\$buffer" to new is literally equivalent: both forms immediately import the key material into the new object. same energy, different packaging. π«Ά
π generate_key
Returns the object itself (for chaining). main character energy β she returns herself so you can keep going. π
$pk->generate_key;
π import_key
Loads X448 private or public keys from DER, PEM, PKCS#8, SubjectPublicKeyInfo, or JWK. so many formats, all welcome, all slaying. π
my $source = Crypt::PK::X448->new();
$source->generate_key;
my $public_der = $source->export_key_der('public');
my $pub = Crypt::PK::X448->new();
$pub->import_key(\$public_der);
my $private_pem = $source->export_key_pem('private', 'secret', 'AES-256-CBC');
my $priv = Crypt::PK::X448->new();
$priv->import_key(\$private_pem, 'secret');
$pk->import_key({
curve => "x448",
pub => "CF807AB0FC3EFA03108469F29E499DB2EEFEFEB12544D8D4E711F187385AAF31B4F38C8F84A3DD9E43DA309FD410C3816A50E644B5500C05",
priv => "10D418B111401956ABC5A92C2FBB8406D1D646BA930FDEFA2108EFE68F2000973755AA952BE018F640947C05135FBF9925EBD4DA828D86EC",
});
$pk->import_key({
kty => "OKP",
crv => "X448",
d => "ENQYsRFAGVarxaksL7uEBtHWRrqTD976IQjv5o8gAJc3VaqVK-AY9kCUfAUTX7-ZJevU2oKNhuw",
x => "z4B6sPw--gMQhGnynkmdsu7-_rElRNjU5xHxhzharzG084yPhKPdnkPaMJ_UEMOBalDmRLVQDAU",
});
The same method also accepts filenames instead of buffers. bestie she's flexible like that. β¨
π import_key_raw
Import raw public/private key bytes.
$pk->import_key_raw($key, 'public');
$pk->import_key_raw($key, 'private');
β οΈ The raw key must be exactly56bytes long. not 55, not 57. exactly56. do not test her. π
π export_key_der
Returns the key as a binary DER-encoded string. binary, so don't go printing it in your terminal and acting surprised. π
my $der = $pk->export_key_der('private');
my $der = $pk->export_key_der('public');
π export_key_pem
Returns the key as a PEM-encoded string (ASCII). printable, postable, the classic. π
my $pem = $pk->export_key_pem('private');
my $pem = $pk->export_key_pem('public');
my $pem = $pk->export_key_pem('private', $password, 'AES-256-CBC');
π export_key_jwk
Returns a JSON string, or a hashref if the optional second argument is true. yes she can serve both looks. π
my $json = $pk->export_key_jwk('private');
my $hash = $pk->export_key_jwk('public', 1);
π export_key_raw
Returns the raw key as a binary string.
my $raw = $pk->export_key_raw('private');
my $raw = $pk->export_key_raw('public');
π shared_secret
Returns the shared secret as a binary string (raw bytes). this is the moment, the two of you meeting in the middle. π«Ά
my $shared_secret = $private_key->shared_secret($public_key);
π is_private
my $rv = $pk->is_private;
just a little vibe check: is she private? π΅οΈββοΈ
π key2hash
Returns a hashref with the key components, or undef if no key is loaded. no key, no hash, no problem. π
my $hash = $pk->key2hash;
Returns a hash like:
{
curve => "x448",
pub => "CF807AB0FC3EFA03108469F29E499DB2EEFEFEB12544D8D4E711F187385AAF31B4F38C8F84A3DD9E43DA309FD410C3816A50E644B5500C05",
priv => "10D418B111401956ABC5A92C2FBB8406D1D646BA930FDEFA2108EFE68F2000973755AA952BE018F640947C05135FBF9925EBD4DA828D86EC",
}
π¦ OpenSSL interoperability π¦
collab era! her and OpenSSL, getting along, exchanging keys. it's giving diplomacy. πΈ
# Generate a key with OpenSSL
# openssl genpkey -algorithm x448 -out x448_priv.pem
# openssl pkey -in x448_priv.pem -pubout -out x448_pub.pem
# Load the OpenSSL-generated key in CryptX
use Crypt::PK::X448;
my $alice = Crypt::PK::X448->new("x448_priv.pem");
my $bob_pub = Crypt::PK::X448->new("bob_x448_pub.pem");
# Derive shared secret
my $shared_secret = $alice->shared_secret($bob_pub);
# Export CryptX key for OpenSSL
my $pem = $alice->export_key_pem('private');
# then: openssl pkey -in priv.pem -text -noout
β SEE ALSO β
- <https://www.rfc-editor.org/rfc/rfc7748> β the lore, the source text, required reading bestie π
Crypt::PK::X25519β her sister. also iconic. π
and that's the page!! π this masterpiece is perl v5.42.0, dated 2026-05-11, and it's filed under Crypt::PK::X448(3) β go forth, derive those secrets, and slay β¨π
π¦
π¦ where this page comes from
- opensuse-leap 16.0: perl-CryptX 0.89.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-CryptX 0.89.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-CryptX 0.89.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-CryptX 0.89.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms