public byte[] Calculate(IAsymmetricPublicKey publicKey) { General.Utils.ApprovedModeCheck("service", algDetails.Algorithm); byte[] receivedKey = ((AsymmetricNHPublicKey)publicKey).GetKeyData(); byte[] sharedKey = new byte[NewHopeImpl.AgreementSize]; NewHopeImpl.SharedA(sharedKey, privateKey.privateKeyData, receivedKey); return(sharedKey); }
public override AsymmetricKeyPair <AsymmetricNHPublicKey, AsymmetricNHPrivateKey> GenerateKeyPair() { General.Utils.ApprovedModeCheck("generator", Alg); byte[] send = new byte[NewHopeImpl.SendABytes]; ushort[] secret = new ushort[NewHopeImpl.PolySize]; NewHopeImpl.KeyGen(random, send, secret); return(new AsymmetricKeyPair <AsymmetricNHPublicKey, AsymmetricNHPrivateKey>( new AsymmetricNHPublicKey(send), new AsymmetricNHPrivateKey(secret))); }
public ExchangePair GenerateExchange(IAsymmetricPublicKey otherKey) { General.Utils.ApprovedModeCheck("generator", Alg); byte[] ourSharedKey = new byte[NewHopeImpl.AgreementSize]; byte[] ourSend = new byte[NewHopeImpl.SendBBytes]; AsymmetricNHPublicKey publicKey = (AsymmetricNHPublicKey)otherKey; NewHopeImpl.SharedB(random, ourSharedKey, ourSend, publicKey.GetKeyData()); return(new ExchangePair(new AsymmetricNHPublicKey(ourSend), ourSharedKey)); }