Skip to content

Commit 29394c2

Browse files
committed
feat(identityproof): Ed25519 app keys
Add Manager::generateEd25519AppKey: persist a sodium-generated Ed25519 keypair (raw 32-byte public, 64-byte secret) under the same appdata layout the existing RSA path uses. Used by OCMSignatoryManager for the slotted RFC 9421 signing keys. Signed-off-by: Micke Nordin <kano@sunet.se>
1 parent 2b919e0 commit 29394c2

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

lib/private/Security/IdentityProof/Manager.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,30 @@ public function generateAppKey(string $app, string $name, array $options = []):
178178
return $this->generateKey($this->generateAppKeyId($app, $name), $options);
179179
}
180180

181+
/**
182+
* Generate an Ed25519 keypair via libsodium. Returns raw 32-byte public
183+
* + 64-byte secret (sodium seed||publickey), no PEM. Overwrites if
184+
* already present.
185+
*/
186+
public function generateEd25519AppKey(string $app, string $name): Key {
187+
$keyPair = sodium_crypto_sign_keypair();
188+
$publicKey = sodium_crypto_sign_publickey($keyPair);
189+
$privateKey = sodium_crypto_sign_secretkey($keyPair);
190+
191+
$id = $this->generateAppKeyId($app, $name);
192+
try {
193+
$this->appData->newFolder($id);
194+
} catch (\Exception) {
195+
}
196+
$folder = $this->appData->getFolder($id);
197+
$folder->newFile('private')
198+
->putContent($this->crypto->encrypt($privateKey));
199+
$folder->newFile('public')
200+
->putContent($publicKey);
201+
202+
return new Key($publicKey, $privateKey);
203+
}
204+
181205
public function deleteAppKey(string $app, string $name): bool {
182206
try {
183207
$folder = $this->appData->getFolder($this->generateAppKeyId($app, $name));

0 commit comments

Comments
 (0)