/// <summary> /// Get the HashAlgorithmName from the given ALG_ID /// </summary> private static HashAlgorithmName?GetHashAlgorithmName(Interop.BCrypt.ECC_CURVE_ALG_ID_ENUM hashId) { Interop.Crypt32.CRYPT_OID_INFO oid = Interop.Crypt32.FindAlgIdOidInfo((int)hashId); if (oid.AlgId == -1) { // The original hash algorithm may not be found and is optional return(null); } return(new HashAlgorithmName(oid.Name)); }
/// <summary> /// Get the ALG_ID from the given HashAlgorithmName /// </summary> private static Interop.BCrypt.ECC_CURVE_ALG_ID_ENUM GetHashAlgorithmId(HashAlgorithmName?name) { if (name.HasValue == false || string.IsNullOrEmpty(name.Value.Name)) { return(Interop.BCrypt.ECC_CURVE_ALG_ID_ENUM.BCRYPT_NO_CURVE_GENERATION_ALG_ID); } Interop.Crypt32.CRYPT_OID_INFO oid = Interop.Crypt32.FindOidInfo( Interop.Crypt32.CryptOidInfoKeyType.CRYPT_OID_INFO_NAME_KEY, name.Value.Name, OidGroup.HashAlgorithm, false); if (oid.AlgId == -1) { throw new CryptographicException(SR.GetString(SR.Cryptography_UnknownHashAlgorithm, name.Value.Name)); } return((Interop.BCrypt.ECC_CURVE_ALG_ID_ENUM)oid.AlgId); }