But to get the secret key from the card and pass it in exposes it.
Any ides on how to approach this.
CspParameters cp = new CspParameters(1, "Full Cryptographic Provider");
cp.KeyContainerName =
"MyContainer"; RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cp); //byte[] SecretKey = get this from eracom card container MemoryStream ms = null; CryptoStream encStream = null; TripleDESCryptoServiceProvider enc = null; try{
enc =
new TripleDESCryptoServiceProvider();enc.Mode =
CipherMode.ECB;enc.KeySize = 128;
enc.Padding =
PaddingMode.Zeros; byte[] IV = enc.GenerateIV; //This is not required but we'll pass something in anyhow
ms =
new MemoryStream(CypherText);encStream =
new CryptoStream(ms,enc.CreateDecryptor(SecretKey, IV),
CryptoStreamMode.Read); byte[] fromEncrypt = new byte[CypherText.Length];encStream.Read(fromEncrypt, 0, fromEncrypt.Length);
return fromEncrypt;}
Cheers
Joe
Replies
Know the answer? Post it — somebody with the same question will find it here.