public bool VerifyEmbedded(AsymmetricAlgorithm key, byte[]?associatedData = null) { if (key is null) { throw new ArgumentNullException(nameof(key)); } if (Message.IsDetached) { throw new InvalidOperationException(SR.ContentWasDetached); } return(VerifyCore(key, Message.Content.Value.Span, null, associatedData, CoseHelpers.GetKeyType(key))); }
public bool VerifyDetached(AsymmetricAlgorithm key, ReadOnlySpan <byte> detachedContent, ReadOnlySpan <byte> associatedData = default) { if (key is null) { throw new ArgumentNullException(nameof(key)); } if (!Message.IsDetached) { throw new InvalidOperationException(SR.ContentWasEmbedded); } return(VerifyCore(key, detachedContent, null, associatedData, CoseHelpers.GetKeyType(key))); }
public CoseSigner(AsymmetricAlgorithm key, HashAlgorithmName hashAlgorithm, CoseHeaderMap?protectedHeaders = null, CoseHeaderMap?unprotectedHeaders = null) { if (key is null) { throw new ArgumentNullException(nameof(key)); } if (key is RSA) { throw new CryptographicException(SR.CoseSignerRSAKeyNeedsPadding); } Key = key; HashAlgorithm = hashAlgorithm; _protectedHeaders = protectedHeaders; _unprotectedHeaders = unprotectedHeaders; _keyType = CoseHelpers.GetKeyType(key); _algHeaderValueToSlip = ValidateOrSlipAlgorithmHeader(); }
public CoseSigner(RSA key, RSASignaturePadding signaturePadding, HashAlgorithmName hashAlgorithm, CoseHeaderMap?protectedHeaders = null, CoseHeaderMap?unprotectedHeaders = null) { if (key is null) { throw new ArgumentNullException(nameof(key)); } if (signaturePadding is null) { throw new ArgumentNullException(nameof(signaturePadding)); } Key = key; HashAlgorithm = hashAlgorithm; RSASignaturePadding = signaturePadding; _protectedHeaders = protectedHeaders; _unprotectedHeaders = unprotectedHeaders; _keyType = CoseHelpers.GetKeyType(key); _algHeaderValueToSlip = ValidateOrSlipAlgorithmHeader(); }