Beispiel #1
0
        public bool DeriveKeysServer()
        {
            if (publicPreKey == null || publicEphemeralKey == null)
            {
                //return false;
                throw new EncryptionKeyIsMissingException();
            }
            // ephermeral And Public Pre Key
            KeyPair ePPK = new KeyPair();

            // ephermeral and Public One Time Key
            KeyPair ePOTK = new KeyPair();

            // own Pre Key and Public Pre Key
            KeyPair oPKPPK = new KeyPair();
            // own Pre Key and Public One Time Key
            KeyPair oPKPOTK = new KeyPair();

            if (oneTimeKeyPair != null)
            {
                NativeLibsodium.crypto_kx_server_session_keys(ePOTK.publicKey, ePOTK.secretKey, oneTimeKeyPair.publicKey, oneTimeKeyPair.secretKey, publicEphemeralKey);
                NativeLibsodium.crypto_kx_server_session_keys(oPKPOTK.publicKey, oPKPOTK.secretKey, oneTimeKeyPair.publicKey, oneTimeKeyPair.secretKey, publicPreKey);
            }
            NativeLibsodium.crypto_kx_server_session_keys(ePPK.publicKey, ePPK.secretKey, ownPreKeyPair.publicKey, ownPreKeyPair.secretKey, publicEphemeralKey);
            NativeLibsodium.crypto_kx_server_session_keys(oPKPPK.publicKey, oPKPPK.secretKey, ownPreKeyPair.publicKey, ownPreKeyPair.secretKey, publicPreKey);

            DeriveSessionKeys(ePPK, oPKPPK, oPKPOTK, ePOTK);
            return(true);
        }
Beispiel #2
0
 public void ComputeKeysServer()
 {
     NativeLibsodium.crypto_kx_server_session_keys(sessionReceiveKey, sessionSendKey, ownIdentKeyPair.publicKey, ownIdentKeyPair.secretKey, publicIdentKey);
 }
Beispiel #3
0
 public override void DeriveServerSessionKeys(byte[] data, KeyPair ownKeyPair)
 {
     NativeLibsodium.crypto_kx_server_session_keys(sessionSendKey, sessionReceiveKey, ownKeyPair.publicKey, ownKeyPair.secretKey, data);
 }