Beispiel #1
0
        private void SetPgpSignature(SignatureTag tag, PgpSignature signature)
        {
            PgpSignatureList signatureList = new PgpSignatureList(signature);
            byte[] value = signature.GetEncoded();

            this.SetByteArray(tag, value);
        }
Beispiel #2
0
        protected void SetValue<T>(SignatureTag tag, IndexType type, T[] value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            var collection = new Collection<T>(value);

            IndexRecord record = new IndexRecord()
            {
                Header = new IndexHeader()
                {
                    Count = collection.Count,
                    Offset = 0,
                    Tag = (uint)tag,
                    Type = type
                },
                Value = collection
            };

            if (!this.Package.Signature.Records.ContainsKey(tag))
            {
                this.Package.Signature.Records.Add(tag, record);
            }
            else
            {
                this.Package.Signature.Records[tag] = record;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Gets a PGP signature.
        /// </summary>
        /// <param name="tag">
        /// The tag which contains the PGP signature.
        /// </param>
        /// <returns>
        /// A <see cref="PgpSignature"/> object which represents the PGP signature.
        /// </returns>
        private PgpSignature GetPgpSignature(SignatureTag tag)
        {
            byte[] value = (byte[])this.Package.Signature.Records[tag].Value;

            using (MemoryStream stream = new MemoryStream(value))
            using (var signatureStream = PgpUtilities.GetDecoderStream(stream))
            {
                PgpObjectFactory pgpFactory = new PgpObjectFactory(signatureStream);
                PgpSignatureList signatureList = (PgpSignatureList)pgpFactory.NextPgpObject();
                PgpSignature signature = signatureList[0];
                return signature;
            }
        }
        private void AssertTagEqual(SignatureTag tag, RpmPackage originalPackage, RpmPackage package)
        {
            var originalRecord = originalPackage.Signature.Records[tag];
            var record         = package.Signature.Records[tag];

            // Don't have the private key
            if (tag != SignatureTag.RPMSIGTAG_PGP && tag != SignatureTag.RPMSIGTAG_RSA && tag != SignatureTag.RPMTAG_HEADERSIGNATURES)
            {
                Assert.Equal(originalRecord.Value, record.Value);
            }

            Assert.Equal(originalRecord.Header.Count, record.Header.Count);
            Assert.Equal(originalRecord.Header.Tag, record.Header.Tag);
            Assert.Equal(originalRecord.Header.Type, record.Header.Type);
            Assert.Equal(originalRecord.Header.Offset, record.Header.Offset);
        }
Beispiel #5
0
        protected void SetSingleValue<T>(SignatureTag tag, IndexType type, T value)
        {
            IndexRecord record = new IndexRecord()
            {
                Header = new IndexHeader()
                {
                    Count = 1,
                    Offset = 0,
                    Tag = (uint)tag,
                    Type = type
                },
                Value = value
            };

            if (!this.Package.Signature.Records.ContainsKey(tag))
            {
                this.Package.Signature.Records.Add(tag, record);
            }
            else
            {
                this.Package.Signature.Records[tag] = record;
            }
        }
        private static ICCTagData ReadTagData(TypeSignature type, byte[] iccData, int index,
                                              ICCHeader header)
        {
            ICCTagData t = null;

            switch (type)
            {
            case TypeSignature.chromaticity:
                t = new ChromaticityTag();
                break;

            case TypeSignature.colorantOrder:
                t = new ColorantOrderTag();
                break;

            case TypeSignature.colorantTable:
                t = new ColorantTableTag();
                break;

            case TypeSignature.curve:
                t = new CurveTag();
                break;

            case TypeSignature.data:
                t = new DataTag();
                break;

            case TypeSignature.dateTime:
                t = new DateTimeTag();
                break;

            case TypeSignature.lut16:
                t = new Lut16Tag();
                break;

            case TypeSignature.lut8:
                t = new Lut8Tag();
                break;

            case TypeSignature.lutAToB:
                t = new LutAToBTag();
                break;

            case TypeSignature.lutBToA:
                t = new LutBToATag();
                break;

            case TypeSignature.measurement:
                t = new MeasurementTag();
                break;

            case TypeSignature.multiLocalizedUnicode:
                t = new MultiLocalizedUnicodeTag()
                {
                    IsPlaceHolder = false
                };

                break;

            case TypeSignature.multiProcessElements:
                t = new MultiProcessElementsTag();
                break;

            case TypeSignature.namedColor2:
                t = new NamedColor2Tag();
                break;

            case TypeSignature.parametricCurve:
                t = new ParametricCurveTag();
                break;

            case TypeSignature.profileSequenceDesc:
                t = new ProfileSequenceDescTag();
                break;

            case TypeSignature.profileSequenceIdentifier:
                t = new ProfileSequenceIdentifierTag();
                break;

            case TypeSignature.responseCurveSet16:
                t = new ResponseCurveSet16Tag();
                break;

            case TypeSignature.s15Fixed16Array:
                t = new s15Fixed16ArrayTag();
                break;

            case TypeSignature.signature:
                t = new SignatureTag();
                break;

            case TypeSignature.text:
                t = new TextTag();
                break;

            case TypeSignature.u16Fixed16Array:
                t = new u16Fixed16ArrayTag();
                break;

            case TypeSignature.uInt16Array:
                t = new uInt16ArrayTag();
                break;

            case TypeSignature.uInt32Array:
                t = new uInt32ArrayTag();
                break;

            case TypeSignature.uInt64Array:
                t = new uInt64ArrayTag();
                break;

            case TypeSignature.uInt8Array:
                t = new uInt8ArrayTag();
                break;

            case TypeSignature.viewingConditions:
                t = new ViewingConditionTag();
                break;

            case TypeSignature.XYZ:
                t = new XYZTag();
                break;
            }
            t.GetTagData(iccData, index, header);
            return(t);
        }
Beispiel #7
0
 protected void SetByteArray(SignatureTag tag, byte[] value)
 {
     this.SetValue(tag, IndexType.RPM_BIN_TYPE, value);
 }
Beispiel #8
0
 protected void SetString(SignatureTag tag, string value)
 {
     this.SetSingleValue(tag, IndexType.RPM_STRING_TYPE, value);
 }
Beispiel #9
0
 protected void SetInt(SignatureTag tag, int value)
 {
     this.SetSingleValue(tag, IndexType.RPM_INT32_TYPE, value);
 }