Beispiel #1
0
        public byte[] Sign([ReadOnlyArray] byte[] securedInput, object key)
        {
            var publicKey = Ensure.Type <ICryptographicKey>(key, "RsaUsingSha expects key to be of type 'ICryptographicKey'");

            //reattach key to alg provider
            byte[] keyBlob = publicKey.Export(CryptographicPrivateKeyBlobType.Pkcs1RsaPrivateKey);

            ICryptographicKey cKey = AlgProvider.ImportKeyPair(keyBlob, CryptographicPrivateKeyBlobType.Pkcs1RsaPrivateKey);

            return(WinRTCrypto.CryptographicEngine.Sign(cKey, securedInput));
        }
        public byte[] Sign([ReadOnlyArray] byte[] securedInput, object key)
        {
            var publicKey = Ensure.Type <CryptographicKey>(key, "RsaPssUsingSha expects key to be of type 'CryptographicKey'");

            IBuffer msg = CryptographicBuffer.CreateFromByteArray(securedInput);

            //reattach key to alg provider
            IBuffer keyBlob = publicKey.Export(CryptographicPrivateKeyBlobType.BCryptPrivateKey);

            CryptographicKey cKey = AlgProvider.ImportKeyPair(keyBlob, CryptographicPrivateKeyBlobType.BCryptPrivateKey);

            return(Buffer.ToBytes(CryptographicEngine.Sign(cKey, msg)));
        }
        public byte[] Unwrap([ReadOnlyArray] byte[] encryptedCek, object key, uint cekSizeBits, JsonObject header)
        {
            var privateKey = Ensure.Type <CryptographicKey>(key, "RsaUsingSha expects key to be of type 'CryptographicKey'");

            IBuffer msg = CryptographicBuffer.CreateFromByteArray(encryptedCek);

            //reattach key to alg provider
            IBuffer keyBlob = privateKey.Export(CryptographicPrivateKeyBlobType.BCryptPrivateKey);

            CryptographicKey cKey = AlgProvider.ImportKeyPair(keyBlob, CryptographicPrivateKeyBlobType.BCryptPrivateKey);

            return(Buffer.ToBytes(CryptographicEngine.Decrypt(cKey, msg, null)));
        }