class AppReceiptField(univ.Sequence):
    """Apple App Receipt field"""
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('type',    AppReceiptFieldType()),
        namedtype.NamedType('version', rfc2315.Version()),
        namedtype.NamedType('value',   univ.OctetString())
    )
Exemplo n.º 2
0
class SignedData(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('version', rfc2315.Version()),
        namedtype.NamedType('digestAlgorithms',
                            rfc2315.DigestAlgorithmIdentifiers()),
        namedtype.NamedType('contentInfo', rfc2315.ContentInfo()),
        namedtype.OptionalNamedType(
            'certificates',
            CertificateSet().subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatConstructed, 0))),
        namedtype.OptionalNamedType(
            'crls',
            rfc2315.CertificateRevocationLists().subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatConstructed, 1))),
        namedtype.NamedType('signerInfos', rfc2315.SignerInfos()))
Exemplo n.º 3
0
class TSTInfo(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('version', rfc2315.Version()),
        namedtype.NamedType('policy', univ.ObjectIdentifier()),
        namedtype.NamedType('messageImprint', univ.Any()),
        namedtype.NamedType('serialNumber', univ.Integer()),
        namedtype.NamedType('genTime', useful.GeneralizedTime()),
        namedtype.OptionalNamedType('accuracy', univ.Any()),
        namedtype.OptionalNamedType('ordering', univ.Boolean()),
        namedtype.OptionalNamedType('nonce', univ.Integer()),
        namedtype.OptionalNamedType(
            'tsa',
            rfc2315.GeneralName().subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.OptionalNamedType(
            'extensions',
            rfc2315.Extensions().subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatConstructed, 1))))
Exemplo n.º 4
0
    def toDER(self):
        contentInfo = rfc2315.ContentInfo()
        contentInfo['contentType'] = rfc2315.signedData

        signedData = rfc2315.SignedData()
        signedData['version'] = rfc2315.Version(1)

        digestAlgorithms = rfc2315.DigestAlgorithmIdentifiers()
        digestAlgorithms[0] = self.pykeyHashToDigestAlgorithm(pykey.HASH_SHA1)
        signedData['digestAlgorithms'] = digestAlgorithms

        dataContentInfo = rfc2315.ContentInfo()
        dataContentInfo['contentType'] = rfc2315.data
        signedData['contentInfo'] = dataContentInfo

        certificates = rfc2315.ExtendedCertificatesAndCertificates().subtype(
            implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed,
                                0))
        extendedCertificateOrCertificate = rfc2315.ExtendedCertificateOrCertificate(
        )
        certificate = decoder.decode(self.signer.toDER(),
                                     asn1Spec=rfc2459.Certificate())[0]
        extendedCertificateOrCertificate['certificate'] = certificate
        certificates[0] = extendedCertificateOrCertificate
        signedData['certificates'] = certificates

        signerInfos = rfc2315.SignerInfos()

        if len(self.sha1) > 0:
            signerInfos[len(signerInfos)] = self.buildSignerInfo(
                certificate, pykey.HASH_SHA1, self.sha1)
        if len(self.sha256) > 0:
            signerInfos[len(signerInfos)] = self.buildSignerInfo(
                certificate, pykey.HASH_SHA256, self.sha256)
        signedData['signerInfos'] = signerInfos

        encoded = encoder.encode(signedData)
        anyTag = univ.Any(encoded).subtype(explicitTag=tag.Tag(
            tag.tagClassContext, tag.tagFormatConstructed, 0))

        contentInfo['content'] = anyTag
        return encoder.encode(contentInfo)