X-Git-Url: http://www.git.cypherpunks.ru/?p=pygost.git;a=blobdiff_plain;f=pygost%2Fasn1schemas%2Fcms.py;h=2df3633158de3bc0fd65edbef29d0a45031b1b6b;hp=a39b10be978f2f2e1b8ad0d27a671ec6bf1a6c9a;hb=141ec28f940fbba3edb67252bc4e8707502b87ce;hpb=fd28fdc0abb235b8a6244b9cc3b3456dffae70f6 diff --git a/pygost/asn1schemas/cms.py b/pygost/asn1schemas/cms.py index a39b10b..2df3633 100644 --- a/pygost/asn1schemas/cms.py +++ b/pygost/asn1schemas/cms.py @@ -1,6 +1,6 @@ # coding: utf-8 # PyGOST -- Pure Python GOST cryptographic functions library -# Copyright (C) 2015-2020 Sergey Matveev +# Copyright (C) 2015-2021 Sergey Matveev # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -59,10 +59,25 @@ class ContentType(ObjectIdentifier): pass +class IssuerAndSerialNumber(Sequence): + schema = ( + ("issuer", Name()), + ("serialNumber", CertificateSerialNumber()), + ) + + +class KeyIdentifier(OctetString): + pass + + +class SubjectKeyIdentifier(KeyIdentifier): + pass + + class RecipientIdentifier(Choice): schema = ( - ("issuerAndSerialNumber", Any()), - # ("subjectKeyIdentifier", SubjectKeyIdentifier(impl=tag_ctxp(0))), + ("issuerAndSerialNumber", IssuerAndSerialNumber()), + ("subjectKeyIdentifier", SubjectKeyIdentifier(impl=tag_ctxp(0))), ) @@ -159,21 +174,6 @@ class OriginatorPublicKey(Sequence): ) -class IssuerAndSerialNumber(Sequence): - schema = ( - ("issuer", Name()), - ("serialNumber", CertificateSerialNumber()), - ) - - -class KeyIdentifier(OctetString): - pass - - -class SubjectKeyIdentifier(KeyIdentifier): - pass - - class OriginatorIdentifierOrKey(Choice): schema = ( ("issuerAndSerialNumber", IssuerAndSerialNumber()), @@ -188,7 +188,7 @@ class UserKeyingMaterial(OctetString): class KeyAgreeRecipientIdentifier(Choice): schema = ( - ("issuerAndSerialNumber", Any()), + ("issuerAndSerialNumber", IssuerAndSerialNumber()), # ("rKeyId", RecipientKeyIdentifier(impl=tag_ctxc(0))), ) @@ -307,10 +307,31 @@ class UnprotectedAttributes(SetOf): bounds = (1, float("+inf")) +class CertificateChoices(Choice): + schema = ( + ("certificate", Certificate()), + # ("extendedCertificate", OctetString(impl=tag_ctxp(0))), + # ("v1AttrCert", AttributeCertificateV1(impl=tag_ctxc(1))), # V1 is osbolete + # ("v2AttrCert", AttributeCertificateV2(impl=tag_ctxc(2))), + # ("other", OtherCertificateFormat(impl=tag_ctxc(3))), + ) + + +class CertificateSet(SetOf): + schema = CertificateChoices() + + +class OriginatorInfo(Sequence): + schema = ( + ("certs", CertificateSet(impl=tag_ctxc(0), optional=True)), + # ("crls", RevocationInfoChoices(impl=tag_ctxc(1), optional=True)), + ) + + class EnvelopedData(Sequence): schema = ( ("version", CMSVersion()), - # ("originatorInfo", OriginatorInfo(impl=tag_ctxc(0), optional=True)), + ("originatorInfo", OriginatorInfo(impl=tag_ctxc(0), optional=True)), ("recipientInfos", RecipientInfos()), ("encryptedContentInfo", EncryptedContentInfo()), ("unprotectedAttrs", UnprotectedAttributes(impl=tag_ctxc(1), optional=True)), @@ -326,8 +347,8 @@ class EncapsulatedContentInfo(Sequence): class SignerIdentifier(Choice): schema = ( - ("issuerAndSerialNumber", Any()), - # ("subjectKeyIdentifier", SubjectKeyIdentifier(impl=tag_ctxp(0))), + ("issuerAndSerialNumber", IssuerAndSerialNumber()), + ("subjectKeyIdentifier", SubjectKeyIdentifier(impl=tag_ctxp(0))), ) @@ -368,20 +389,6 @@ class SignerInfos(SetOf): schema = SignerInfo() -class CertificateChoices(Choice): - schema = ( - ("certificate", Certificate()), - # ("extendedCertificate", ExtendedCertificate(impl=tag_ctxp(0))), - # ("v1AttrCert", AttributeCertificateV1(impl=tag_ctxc(1))), # V1 is osbolete - # ("v2AttrCert", AttributeCertificateV2(impl=tag_ctxc(2))), - # ("other", OtherCertificateFormat(impl=tag_ctxc(3))), - ) - - -class CertificateSet(SetOf): - schema = CertificateChoices() - - class SignedData(Sequence): schema = ( ("version", CMSVersion()),