<commit_before>import logging

from pyasn1.codec.der import encoder
from pyasn1 import error

from pkcs7.asn1_models.oid import *
from pkcs7.digest import *
import pkcs7.verifier
import pkcs7.rsa_verifier

from cert_finder import *

import time

SHA1RSA_NAME = "SHA1/RSA"
SHA256RSA_NAME = "SHA256/RSA"

# TODO finish
def _verify_date(certificate): 
    '''
    Checks date boundaries in the certificate (actual time must be inside). 
    '''
    tbs = certificate.getComponentByName("tbsCertificate")
    validity = tbs.getComponentByName("validity")
    start = validity.getComponentByName("notBefore")
    end = validity.getComponentByName("notAfter")
    now = time.time()
    return True
    

def verify_certificate(cert, trusted_ca_certs):
    if len(trusted_ca_certs) == 0:<commit_msg>kontrola casovej platnosti certifikatu<commit_after>import logging

from pyasn1.codec.der import encoder
from pyasn1 import error

from pkcs7.asn1_models.oid import *
from pkcs7.digest import *
import pkcs7.verifier
import pkcs7.rsa_verifier

from cert_finder import *

import time

SHA1RSA_NAME = "SHA1/RSA"
SHA256RSA_NAME = "SHA256/RSA"

# TODO finish
def _verify_date(certificate): 
    '''
    Checks date boundaries in the certificate (actual time must be inside). 
    '''
    tbs = certificate.getComponentByName("tbsCertificate")
    validity = tbs.getComponentByName("validity")
    start = validity.getComponentByName("notBefore").getComponentByPosition(0)._value
    
    format = '%y%m%d%H%M%SZ'
    start_time = time.strptime(start, format)
    end = validity.getComponentByName("notAfter").getComponentByPosition(0)._value
    end_time = time.strptime(end, format)
    now = time.gmtime()    
    
    if (start_time < now) and (end_time > now):    
        return True
    return False
    

def verify_certificate(cert, trusted_ca_certs):
    if len(trusted_ca_certs) == 0:
{'fraction_non_alphanumeric': 0.0935672514619883, 'fraction_numerical': 0.018075491759702286, 'mean_word_length': 4.213296398891967, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3062095', 'n_tokens_mistral': 656, 'n_tokens_neox': 632, 'n_words': 142}