Closed PiotrKowalski93 closed 8 months ago
First, it seems you're importing the byte arrays in CreateSSK
as Ed25519
keys but then performing key agreement using X25519
. That won't work: Ed25519
keys are for signatures, not for key agreement. Second, if you want to do algorythm.Agree(privateKeyObj, publicKeyObj)
, then both privateKeyObj
and publicKeyObj
must be created/import using algorythm
. Try changing ...Import(SignatureAlgorithm.Ed25519, ...
to ...Import(algorythm, ...
.
Oh yes, I changed that and got:
System.InvalidOperationException: 'The key cannot be exported.'
for
byte[] SSK = sharedSecretKey.Export(SharedSecretBlobFormat.RawSharedSecret);
Exceptions related to Keys are documented here https://nsec.rocks/docs/api/nsec.cryptography.key
Is it possible to create shared secret key on the server side when Public Key will come over tcp? Belows code throw exception:
'Cannot use a key created for a different algorithm instance. (key.Algorithm must be the same object as the current object.) (Parameter 'key')'
Documentation lack of examples and explanations unfortunately