Beispiel #1
0
        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));
        }