Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading countersigns gets all very slow #223

Open
mari-ano opened this issue Feb 15, 2022 · 1 comment
Open

Loading countersigns gets all very slow #223

mari-ano opened this issue Feb 15, 2022 · 1 comment

Comments

@mari-ano
Copy link

mari-ano commented Feb 15, 2022

Hi there!
I'm using your modules for a project and I must say they really work well.
But, I think I have encountered what could be a problem: everything is smooth and fast up to when you load in the cms ContentInfo a structure with counter_signature as the type in the ungned_attrs of the SingerInfo.
I wrote a small sample code with a recursive call that does nothing but print out a couple of random values.
If you run the code with a cms that only has "parallel" SignerInfo (parallele.p7m) it runs fast, but if you run it with a cms thas has SignerInfos iside other SignerInfo, i,e, counter signatures (controfirme.p7m), it runs sensitively slower. The number of SignerInfo object is the same in both cases.
This is a small code and the delay is evident but not so important. I'm running a project with a larger code and the delay can get up to 60-70 seconds.
I hope you can help me in finding a solution.

from asn1crypto import cms, tsp
import os

scriptdir = os.path.dirname(os.path.abspath(__file__)) + '/'
k = 0

def print_data(signer):
    global k
    a = k = k + 1
    print('Signer #{:02} - Serial n.: {}'.format(a, signer['sid'].native['serial_number']))
    print('Signer #{:02} - Algorithm: {}'.format(a, signer['signature_algorithm'].native['algorithm']))

    for unsigned_attr in signer['unsigned_attrs']:
        if unsigned_attr.native['type'] == 'counter_signature':
            for countersigner_info in unsigned_attr['values']:
                print_data(countersigner_info)

content_info = cms.ContentInfo.load(open(scriptdir + 'countersign.p7m', 'rb').read())
for signer_info in content_info['content']['signer_infos']:
    print_data(signer_info)

Thanks in advance

test_data.zip

@mari-ano
Copy link
Author

Ok! I got an hint!
Everything goes smooth if you don't import the tsp module...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant