Example #1
0
def verify_and_unseal_blob( public_key_pem, secret, blob_data ):
    """
    verify and unseal a serialized string of JSON
    """

    global CRYPTO_INITED

    if not CRYPTO_INITED:
       c_syndicate.crypto_init()
       CRYPTO_INITED = True 
    
    # verify it 
    rc, sealed_data = syndicate_crypto.verify_and_parse_json( public_key_pem, blob_data )
    if rc != 0:
        logger.error("Failed to verify and parse blob, rc = %s" % rc)
        return None

    logger.info("Unsealing credential data")
    
    rc, data = c_syndicate.symmetric_unseal( sealed_data, secret )
    if rc != 0:
        logger.error("Failed to unseal blob, rc = %s" % rc )
        return None

    return data
Example #2
0
def verify_and_unseal_blob(public_key_pem, secret, blob_data):
    """
    verify and unseal a serialized string of JSON
    """

    global CRYPTO_INITED

    if not CRYPTO_INITED:
        c_syndicate.crypto_init()
        CRYPTO_INITED = True

    # verify it
    rc, sealed_data = syndicate_crypto.verify_and_parse_json(
        public_key_pem, blob_data)
    if rc != 0:
        logger.error("Failed to verify and parse blob, rc = %s" % rc)
        return None

    logger.info("Unsealing credential data")

    rc, data = c_syndicate.symmetric_unseal(sealed_data, secret)
    if rc != 0:
        logger.error("Failed to unseal blob, rc = %s" % rc)
        return None

    return data
Example #3
0
def read_observer_data_from_json( public_key_path, json_text ):
    """
    Parse and validate a JSON structure.
    Return 0 on success
    Return nonzero on error 
    """
    
    # get the public key 
    k = load_public_key( public_key_path )
    if k is None:
        log.error("Failed to load public key from %s" % (public_key_path))
        return (-errno.ENOENT, None)
    
    return crypto.verify_and_parse_json( k.exportKey(), json_text )
Example #4
0
def verify_and_unseal_blob( public_key_pem, secret, blob_data ):
    """
    verify and unseal a serialized string of JSON
    """

    # verify it 
    rc, sealed_data = syndicate_crypto.verify_and_parse_json( public_key_pem, blob_data )
    if rc != 0:
        logger.error("Failed to verify and parse blob, rc = %s" % rc)
        return None

    logger.info("Unsealing credential data")

    rc, data = c_syndicate.password_unseal( sealed_data, secret )
    if rc != 0:
        logger.error("Failed to unseal blob, rc = %s" % rc )
        return None

    return data
Example #5
0
def verify_and_unseal_blob(public_key_pem, secret, blob_data):
    """
    verify and unseal a serialized string of JSON
    """

    # verify it
    rc, sealed_data = syndicate_crypto.verify_and_parse_json(
        public_key_pem, blob_data)
    if rc != 0:
        logger.error("Failed to verify and parse blob, rc = %s" % rc)
        return None

    logger.info("Unsealing credential data")

    rc, data = c_syndicate.password_unseal(sealed_data, secret)
    if rc != 0:
        logger.error("Failed to unseal blob, rc = %s" % rc)
        return None

    return data