Esempio n. 1
0
def load_pkcs7(p7file):
    bio = m2.bio_new_file(p7file, "r")
    if bio is None:
        raise BIO.BIOError(Err.get_error())

    try:
        p7_ptr = m2.pkcs7_read_bio(bio)
    finally:
        m2.bio_free(bio)

    if p7_ptr is None:
        raise PKCS7_Error(Err.get_error())
    return PKCS7(p7_ptr, 1)
Esempio n. 2
0
def load_pkcs7(p7file):
    bio = m2.bio_new_file(p7file, 'r')
    if bio is None:
        raise Err.get_error()

    try:
        p7_ptr = m2.pkcs7_read_bio(bio)
    finally:
        m2.bio_free(bio)
        
    if p7_ptr is None:
        raise Err.get_error()
    return PKCS7(p7_ptr, 1)
Esempio n. 3
0
def load_pkcs7(p7file):
    bio = m2.bio_new_file(p7file, 'r')
    if bio is None:
        raise Err.get_error()

    try:
        p7_ptr = m2.pkcs7_read_bio(bio)
    finally:
        m2.bio_free(bio)

    if p7_ptr is None:
        raise Err.get_error()
    return PKCS7(p7_ptr, 1)
Esempio n. 4
0
def smime_load_pkcs7(p7file):
    bio = m2.bio_new_file(p7file, "r")
    if bio is None:
        raise BIO.BIOError(Err.get_error())

    try:
        p7_ptr, bio_ptr = m2.smime_read_pkcs7(bio)
    finally:
        m2.bio_free(bio)

    if p7_ptr is None:
        raise SMIME_Error(Err.get_error())
    if bio_ptr is None:
        return PKCS7(p7_ptr, 1), None
    else:
        return PKCS7(p7_ptr, 1), BIO.BIO(bio_ptr, 1)
Esempio n. 5
0
def smime_load_pkcs7(p7file):
    bio = m2.bio_new_file(p7file, 'r')
    if bio is None:
        raise Err.get_error()

    try:
        p7_ptr, bio_ptr = m2.smime_read_pkcs7(bio)
    finally:
        m2.bio_free(bio)

    if p7_ptr is None:
        raise Err.get_error()
    if bio_ptr is None:
        return PKCS7(p7_ptr, 1), None
    else:
        return PKCS7(p7_ptr, 1), BIO.BIO(bio_ptr, 1)
Esempio n. 6
0
def load_key(file, callback=util.passphrase_callback):
    """
    Load an M2Crypto.EVP.PKey from file.

    @type file: string
    @param file: Name of file containing the key in PEM format.

    @type callback: Python callable
    @param callback: A Python callable object that is invoked
    to acquire a passphrase with which to protect the key.

    @rtype: M2Crypto.EVP.PKey
    @return: M2Crypto.EVP.PKey object.
    """
    bio = m2.bio_new_file(file, 'r')
    if bio is None:
        raise Err.get_error()
    cptr = m2.pkey_read_pem(bio, callback)
    m2.bio_free(bio)
    if cptr is None:
        raise Err.get_error()
    return PKey(cptr, 1)
Esempio n. 7
0
def load_key(file, callback=util.passphrase_callback):
    """
    Load an M2Crypto.EVP.PKey from file.

    @type file: string
    @param file: Name of file containing the key in PEM format.

    @type callback: Python callable
    @param callback: A Python callable object that is invoked
    to acquire a passphrase with which to protect the key.

    @rtype: M2Crypto.EVP.PKey
    @return: M2Crypto.EVP.PKey object.
    """
    bio = m2.bio_new_file(file, "r")
    if bio is None:
        raise BIO.BIOError(Err.get_error())
    cptr = m2.pkey_read_pem(bio, callback)
    m2.bio_free(bio)
    if cptr is None:
        raise EVPError(Err.get_error())
    return PKey(cptr, 1)