public byte[] CryptDeriveKey(string algname, string alghashname, int keySize, byte[] rgbIV) { if (keySize < 0) { throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize")); } int algidHash = X509Utils.OidToAlgId(alghashname); if (algidHash == 0) { throw new CryptographicException(Environment.GetResourceString("Cryptography_PasswordDerivedBytes_InvalidAlgorithm")); } int algid = X509Utils.OidToAlgId(algname); if (algid == 0) { throw new CryptographicException(Environment.GetResourceString("Cryptography_PasswordDerivedBytes_InvalidAlgorithm")); } if (rgbIV == null) { throw new CryptographicException(Environment.GetResourceString("Cryptography_PasswordDerivedBytes_InvalidIV")); } byte[] o = null; DeriveKey(this.ProvHandle, algid, algidHash, this._password, this._password.Length, keySize << 0x10, rgbIV, rgbIV.Length, JitHelpers.GetObjectHandleOnStack <byte[]>(ref o)); return(o); }
public byte[] SignHash(byte[] rgbHash, string str) { if (rgbHash == null) { throw new ArgumentNullException("rgbHash"); } if (this.PublicOnly) { throw new CryptographicException(Environment.GetResourceString("Cryptography_CSP_NoPrivateKey")); } int calgHash = X509Utils.OidToAlgId(str); if (rgbHash.Length != (this._sha1.HashSize / 8)) { throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidHashSize", new object[] { "SHA1", this._sha1.HashSize / 8 })); } this.GetKeyPair(); if (!this.CspKeyContainerInfo.RandomlyGenerated) { KeyContainerPermission permission = new KeyContainerPermission(KeyContainerPermissionFlags.NoFlags); KeyContainerPermissionAccessEntry accessEntry = new KeyContainerPermissionAccessEntry(this._parameters, KeyContainerPermissionFlags.Sign); permission.AccessEntries.Add(accessEntry); permission.Demand(); } return(Utils.SignValue(this._safeKeyHandle, this._parameters.KeyNumber, 0x2200, calgHash, rgbHash)); }
public bool VerifyHash(byte[] rgbHash, string str, byte[] rgbSignature) { if (rgbHash == null) { throw new ArgumentNullException("rgbHash"); } if (rgbSignature == null) { throw new ArgumentNullException("rgbSignature"); } this.GetKeyPair(); int calgHash = X509Utils.OidToAlgId(str, OidGroup.HashAlgorithm); return this.VerifyHash(rgbHash, calgHash, rgbSignature); }
public bool VerifyHash(byte[] rgbHash, string str, byte[] rgbSignature) { if (rgbHash == null) { throw new ArgumentNullException("rgbHash"); } if (rgbSignature == null) { throw new ArgumentNullException("rgbSignature"); } int calgHash = X509Utils.OidToAlgId(str); if (rgbHash.Length != (this._sha1.HashSize / 8)) { throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidHashSize", new object[] { "SHA1", this._sha1.HashSize / 8 })); } this.GetKeyPair(); return(Utils.VerifySign(this._safeKeyHandle, 0x2200, calgHash, rgbHash, rgbSignature)); }