public async Task <String> RetrieveDHSessionKey(String PublickKey) { String DecryptedServerNumber; String readString = await ActivitySocket.read(); ReadObj = JsonParse.ReadObject(readString); if (FingerPrint.Verification(ReadObj.getServerPrimeNumber(), PublickKey, ReadObj.getFingerPrint())) { if (MacAlgProvider.VerifyHMAC(ReadObj.getServerPrimeNumber(), SymmetricKey.StrKeyBase64, ReadObj.getHmacHash())) { DecryptedServerNumber = AesEncryption.AES_Decrypt(ReadObj.getServerPrimeNumber(), SymmetricKey.StrKeyBase64); } else { throw new Exception("Integrity of SymmetricKey canot verified"); } } else { throw new Exception("Integrity of RSA canot verified"); } return(GeneratoreMachine.SessionDHGenerator(DecryptedServerNumber)); }
public async Task <String> ReceiveDHEncryptedMessage(String PublicKey) { ReadObj = JsonParse.ReadObject(await ActivitySocket.read()); if (FingerPrint.Verification(ReadObj.getEncryptedMessage(), PublicKey, ReadObj.getFingerPrint())) { if (MacAlgProvider.VerifyHMAC(ReadObj.getEncryptedMessage(), sessionKey.SessionKey, ReadObj.getHmacHash())) { return(AesEncryption.AES_Decrypt(ReadObj.getEncryptedMessage(), sessionKey.SessionKey)); } else { throw new Exception("Integrity of SymmetricKey canot verified"); } } else { throw new Exception("Integrity of RSA canot verified"); } }