예제 #1
0
        public override BaseResponse Handle(string command)
        {
            if (command.TryConvertTo(out DefineRsaWorkingKeyRequest dwkRequest) == false)
            {
                return(null);
            }

            var decryptedRsaCryptogram = new DecryptedRsaCryptogram();

            decryptedRsaCryptogram.SequentialNumber.Value = random.Next(0, 999999999);

            this.WorkingKey = random.ByteArray(16);
            decryptedRsaCryptogram.WorkingKey.Value = this.WorkingKey;

            var rsaEngine = new RsaEngine();

            rsaEngine.Init(true,
                           new RsaKeyParameters(false, new BigInteger(1, dwkRequest.Modulus.Value), new BigInteger(1, dwkRequest.Exponent.Value))
                           );

            var unprocessedBlock = Encoding.ASCII.GetBytes(decryptedRsaCryptogram.ToString());

            return(new DefineRsaWorkingKeyResponse(rsaEngine.ProcessBlock(unprocessedBlock, 0, unprocessedBlock.Length)));
        }