Ejemplo n.º 1
0
        public CodeRequirementsBlob(byte[] buffer, int offset) : base(buffer, offset)
        {
            uint length = BigEndianConverter.ToUInt32(buffer, offset + 4);
            uint count  = BigEndianConverter.ToUInt32(buffer, offset + 8);

            for (int index = 0; index < count; index++)
            {
                SecurityRequirementType entryType = (SecurityRequirementType)BigEndianConverter.ToUInt32(buffer, offset + 12 + index * 8);
                uint entryOffset         = BigEndianConverter.ToUInt32(buffer, offset + 12 + index * 8 + 4);
                CodeRequirementBlob blob = CodeRequirementBlob.ReadCodeRequirementBlob(buffer, offset + (int)entryOffset);
                Entries.Add(entryType, blob);
            }
        }
Ejemplo n.º 2
0
        public static CodeRequirementsBlob CreateCodeRequirementsBlob(string ident, string certificateCN)
        {
            CodeRequirementsBlob codeRequirements = new CodeRequirementsBlob();
            CodeRequirementBlob  codeRequirement  = new CodeRequirementBlob();

            codeRequirements.Entries.Add(SecurityRequirementType.DesignatedRequirementType, codeRequirement);

            IdentValue         identValue         = new IdentValue(ident);
            AppleGenericAnchor appleGenericAnchor = new AppleGenericAnchor();
            CertificateField   certificateField   = new CertificateField();

            certificateField.CertificateIndex = 0;
            certificateField.FieldName        = "subject.CN";
            certificateField.Match            = new MatchSuffix(MatchOperationName.Equal, certificateCN);
            CertificateGeneric certificateGeneric = new CertificateGeneric();

            certificateGeneric.CertificateIndex = 1;
            certificateGeneric.OID   = APPLE_IOS_OID;
            certificateGeneric.Match = new MatchSuffix(MatchOperationName.Exists);

            codeRequirement.Expression = new AndExpression(identValue, new AndExpression(appleGenericAnchor, new AndExpression(certificateField, certificateGeneric)));

            return(codeRequirements);
        }