/// <summary> /// Signs the specified content and encodes it as a COSE_Sign1 message with embedded content. /// </summary> /// <param name="embeddedContent">The content to sign and to include in the message.</param> /// <param name="signer">The signer information used to sign <paramref name="embeddedContent"/>.</param> /// <param name="associatedData">The extra data associated with the signature, which must also be provided during verification.</param> /// <returns>The encoded message.</returns> /// <exception cref="ArgumentNullException"><paramref name="signer"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentException"> /// <para> /// The <see cref="CoseSigner.ProtectedHeaders"/> and <see cref="CoseSigner.UnprotectedHeaders"/> collections in <paramref name="signer"/> have one or more labels in common. /// </para> /// <para>-or-</para> /// <para> /// One or more of the labels specified in a <see cref="CoseHeaderLabel.CriticalHeaders"/> header is missing. /// </para> /// </exception> public static byte[] SignEmbedded(ReadOnlySpan <byte> embeddedContent, CoseSigner signer, ReadOnlySpan <byte> associatedData = default) { if (signer is null) { throw new ArgumentNullException(nameof(signer)); } return(SignCore(embeddedContent, null, signer, associatedData, isDetached: false)); }
public static byte[] SignEmbedded(byte[] embeddedContent, CoseSigner signer, CoseHeaderMap?protectedHeaders = null, CoseHeaderMap?unprotectedHeaders = null, byte[]?associatedData = null) { if (embeddedContent is null) { throw new ArgumentNullException(nameof(embeddedContent)); } return(SignCore(embeddedContent, null, signer, protectedHeaders, unprotectedHeaders, associatedData, isDetached: false)); }
/// <summary> /// Signs the specified content and encodes it as a COSE_Sign1 message with embedded content. /// </summary> /// <param name="embeddedContent">The content to sign and to include in the message.</param> /// <param name="signer">The signer information used to sign <paramref name="embeddedContent"/>.</param> /// <param name="associatedData">The extra data associated with the signature, which must also be provided during verification.</param> /// <returns>The encoded message.</returns> /// <exception cref="ArgumentNullException"><paramref name="embeddedContent"/> or <paramref name="signer"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentException"> /// <para> /// The <see cref="CoseSigner.ProtectedHeaders"/> and <see cref="CoseSigner.UnprotectedHeaders"/> collections in <paramref name="signer"/> have one or more labels in common. /// </para> /// <para>-or-</para> /// <para> /// One or more of the labels specified in a <see cref="CoseHeaderLabel.CriticalHeaders"/> header is missing. /// </para> /// </exception> public static byte[] SignEmbedded(byte[] embeddedContent, CoseSigner signer, byte[]?associatedData = null) { if (embeddedContent is null) { throw new ArgumentNullException(nameof(embeddedContent)); } if (signer is null) { throw new ArgumentNullException(nameof(signer)); } return(SignCore(embeddedContent.AsSpan(), null, signer, associatedData, isDetached: false)); }
public static byte[] SignDetached(Stream detachedContent, CoseSigner signer, CoseHeaderMap?protectedHeaders = null, CoseHeaderMap?unprotectedHeaders = null, ReadOnlySpan <byte> associatedData = default) { if (detachedContent is null) { throw new ArgumentNullException(nameof(detachedContent)); } if (!detachedContent.CanRead) { throw new ArgumentException(SR.Sign1ArgumentStreamNotReadable, nameof(detachedContent)); } if (!detachedContent.CanSeek) { throw new ArgumentException(SR.Sign1ArgumentStreamNotSeekable, nameof(detachedContent)); } return(SignCore(default, detachedContent, signer, protectedHeaders, unprotectedHeaders, associatedData, isDetached: true));
public static byte[] SignEmbedded(ReadOnlySpan <byte> embeddedContent, CoseSigner signer, CoseHeaderMap?protectedHeaders = null, CoseHeaderMap?unprotectedHeaders = null, ReadOnlySpan <byte> associatedData = default) => SignCore(embeddedContent, null, signer, protectedHeaders, unprotectedHeaders, associatedData, isDetached: false);