internal CoseMessage(CoseHeaderMap protectedHeader, CoseHeaderMap unprotectedHeader, byte[]?content, byte[] signature, byte[] encodedProtectedHeader) { _content = content; _signature = signature; _protectedHeaderAsBstr = encodedProtectedHeader; _protectedHeaders = protectedHeader; _unprotectedHeaders = unprotectedHeader; }
internal CoseMessage(CoseHeaderMap protectedHeader, CoseHeaderMap unprotectedHeader, byte[]?content, byte[] encodedProtectedHeader, bool isTagged) { _content = content; _protectedHeaderAsBstr = encodedProtectedHeader; _protectedHeaders = protectedHeader; _unprotectedHeaders = unprotectedHeader; _isTagged = isTagged; }
internal CoseSignature(CoseHeaderMap protectedHeaders, CoseHeaderMap unprotectedHeaders, byte[] encodedBodyProtectedHeaders, byte[] encodedSignProtectedHeaders, byte[] signature) { ProtectedHeaders = protectedHeaders; UnprotectedHeaders = unprotectedHeaders; _encodedBodyProtectedHeaders = encodedBodyProtectedHeaders; _encodedSignProtectedHeaders = encodedSignProtectedHeaders; _signature = signature; }
internal CoseMultiSignMessage(CoseHeaderMap protectedHeader, CoseHeaderMap unprotectedHeader, byte[]?content, List <CoseSignature> signatures, byte[] encodedProtectedHeader, bool isTagged) : base(protectedHeader, unprotectedHeader, content, encodedProtectedHeader, isTagged) { foreach (CoseSignature s in signatures) { s.Message = this; } Signatures = new ReadOnlyCollection <CoseSignature>(signatures); _signatures = signatures; }
private static CoseMultiSignMessage DecodeCoseMultiSignCore(CborReader reader) { try { CborTag?tag = DecodeTag(reader); if (tag != null && tag != MultiSignTag) { throw new CryptographicException(SR.Format(SR.DecodeMultiSignIncorrectTag, tag)); } int?arrayLength = reader.ReadStartArray(); if (arrayLength != 4) { throw new CryptographicException(SR.Format(SR.DecodeErrorWhileDecoding, SR.DecodeSign1ArrayLengthMustBeFour)); } var protectedHeaders = new CoseHeaderMap(); DecodeProtectedBucket(reader, protectedHeaders, out byte[] encodedProtectedHeaders); var unprotectedHeaders = new CoseHeaderMap(); DecodeUnprotectedBucket(reader, unprotectedHeaders); if (ContainDuplicateLabels(protectedHeaders, unprotectedHeaders)) { throw new CryptographicException(SR.Sign1SignHeaderDuplicateLabels); } byte[]? payload = DecodePayload(reader); List <CoseSignature> signatures = DecodeCoseSignaturesArray(reader, encodedProtectedHeaders); reader.ReadEndArray(); if (reader.BytesRemaining != 0) { throw new CryptographicException(SR.Format(SR.DecodeErrorWhileDecoding, SR.DecodeMessageContainedTrailingData)); } return(new CoseMultiSignMessage(protectedHeaders, unprotectedHeaders, payload, signatures, encodedProtectedHeaders, tag.HasValue)); } catch (Exception ex) when(ex is CborContentException or InvalidOperationException) { throw new CryptographicException(SR.DecodeErrorWhileDecodingSeeInnerEx, ex); } }
private static CoseSign1Message DecodeCoseSign1Core(CborReader reader) { try { CborTag?tag = DecodeTag(reader); if (tag != null && tag != Sign1Tag) { throw new CryptographicException(SR.Format(SR.DecodeSign1IncorrectTag, tag)); } int?arrayLength = reader.ReadStartArray(); if (arrayLength != 4) { throw new CryptographicException(SR.Format(SR.DecodeErrorWhileDecoding, SR.DecodeSign1ArrayLengthMustBeFour)); } var protectedHeader = new CoseHeaderMap(); DecodeProtectedBucket(reader, protectedHeader, out byte[] protectedHeaderAsBstr); var unprotectedHeader = new CoseHeaderMap(); DecodeUnprotectedBucket(reader, unprotectedHeader); ThrowIfDuplicateLabels(protectedHeader, unprotectedHeader); byte[]? payload = DecodePayload(reader); byte[] signature = DecodeSignature(reader); reader.ReadEndArray(); if (reader.BytesRemaining != 0) { throw new CryptographicException(SR.Format(SR.DecodeErrorWhileDecoding, SR.DecodeSign1MesageContainedTrailingData)); } return(new CoseSign1Message(protectedHeader, unprotectedHeader, payload, signature, protectedHeaderAsBstr, tag.HasValue)); } catch (Exception ex) when(ex is CborContentException or InvalidOperationException) { throw new CryptographicException(SR.DecodeErrorWhileDecodingSeeInnerEx, ex); } }
internal CoseSign1Message(CoseHeaderMap protectedHeader, CoseHeaderMap unprotectedHeader, byte[]?content, byte[] signature, byte[] protectedHeaderAsBstr) : base(protectedHeader, unprotectedHeader, content, signature, protectedHeaderAsBstr) { }
internal CoseSign1Message(CoseHeaderMap protectedHeader, CoseHeaderMap unprotectedHeader, byte[]?content, byte[] signature, byte[] protectedHeaderAsBstr, bool isTagged) : base(protectedHeader, unprotectedHeader, content, protectedHeaderAsBstr, isTagged) { _signature = signature; }
internal CoseSignature(CoseMultiSignMessage message, CoseHeaderMap protectedHeaders, CoseHeaderMap unprotectedHeaders, byte[] encodedBodyProtectedHeaders, byte[] encodedSignProtectedHeaders, byte[] signature) : this(protectedHeaders, unprotectedHeaders, encodedBodyProtectedHeaders, encodedSignProtectedHeaders, signature) { Message = message; }