Esempio n. 1
0
def ft_syndicate_principal():
    """
   Functional tests for creating, reading, and deleting SyndicatePrincipals.
   """

    c_syndicate.crypto_init()

    print "generating key pair"
    pubkey_pem, privkey_pem = api.generate_key_pair(4096)

    user_email = "*****@*****.**"

    print "saving principal"

    key = generate_symmetric_secret()

    put_sealed_principal_data(user_email, key, pubkey_pem, privkey_pem)

    print "fetching principal private key"
    saved_privkey_pem = get_principal_pkey(user_email, key)

    assert saved_privkey_pem is not None, "Could not fetch saved private key"
    assert saved_privkey_pem == privkey_pem, "Saved private key does not match actual private key"

    print "delete principal"

    observer_storage.delete_principal_data(user_email)

    print "make sure its deleted..."

    saved_privkey_pem = get_principal_pkey(user_email, key)

    assert saved_privkey_pem is None, "Principal key not deleted"

    c_syndicate.crypto_shutdown()
Esempio n. 2
0
def ft_syndicate_principal():
    """
   Functional tests for creating, reading, and deleting SyndicatePrincipals.
   """
    print "generating key pair"
    pubkey_pem, privkey_pem = api.generate_key_pair(4096)

    user_email = "*****@*****.**"

    print "saving principal"
    put_principal_data(user_email, "asdf", pubkey_pem, privkey_pem)

    print "fetching principal private key"
    saved_privkey_pem = get_principal_pkey(user_email, "asdf")

    assert saved_privkey_pem is not None, "Could not fetch saved private key"
    assert saved_privkey_pem == privkey_pem, "Saved private key does not match actual private key"

    print "delete principal"

    delete_principal_data(user_email)

    print "make sure its deleted..."

    saved_privkey_pem = get_principal_pkey(user_email, "asdf")

    assert saved_privkey_pem is None, "Principal key not deleted"
Esempio n. 3
0
def ft_syndicate_principal():
   """
   Functional tests for creating, reading, and deleting SyndicatePrincipals.
   """
   print "generating key pair"
   pubkey_pem, privkey_pem = api.generate_key_pair( 4096 )
   
   user_email = "*****@*****.**"
   
   print "saving principal"
   put_principal_data( user_email, "asdf", pubkey_pem, privkey_pem )
   
   print "fetching principal private key"
   saved_privkey_pem = get_principal_pkey( user_email, "asdf" )
   
   assert saved_privkey_pem is not None, "Could not fetch saved private key"
   assert saved_privkey_pem == privkey_pem, "Saved private key does not match actual private key"
   
   print "delete principal"
   
   delete_principal_data( user_email )
   
   print "make sure its deleted..."
   
   saved_privkey_pem = get_principal_pkey( user_email, "asdf" )
   
   assert saved_privkey_pem is None, "Principal key not deleted"
Esempio n. 4
0
def ft_syndicate_principal():
    """
   Functional tests for creating, reading, and deleting SyndicatePrincipals.
   """

    c_syndicate.crypto_init()

    print "generating key pair"
    pubkey_pem, privkey_pem = api.generate_key_pair(4096)

    user_email = "*****@*****.**"

    print "saving principal"

    key = generate_symmetric_secret()

    put_sealed_principal_data(user_email, key, pubkey_pem, privkey_pem)

    print "fetching principal private key"
    saved_privkey_pem = get_principal_pkey(user_email, key)

    assert saved_privkey_pem is not None, "Could not fetch saved private key"
    assert saved_privkey_pem == privkey_pem, "Saved private key does not match actual private key"

    print "delete principal"

    observer_storage.delete_principal_data(user_email)

    print "make sure its deleted..."

    saved_privkey_pem = get_principal_pkey(user_email, key)

    assert saved_privkey_pem is None, "Principal key not deleted"

    c_syndicate.crypto_shutdown()
Esempio n. 5
0
def ft_seal_and_unseal():
    """
    Functional test for sealing/unsealing data
    """
    print "generating key pair"
    pubkey_pem, privkey_pem = api.generate_key_pair( 4096 )
    
    sealed_buf = create_sealed_and_signed_blob( privkey_pem, "foo", "hello world")
    print "sealed data is:\n\n%s\n\n" % sealed_buf

    buf = verify_and_unseal_blob( pubkey_pem, "foo", sealed_buf )
    print "unsealed data is: \n\n%s\n\n" % buf
Esempio n. 6
0
def ft_seal_and_unseal():
    """
    Functional test for sealing/unsealing data
    """
    print "generating key pair"
    pubkey_pem, privkey_pem = api.generate_key_pair(4096)

    sealed_buf = create_sealed_and_signed_blob(privkey_pem, "foo",
                                               "hello world")
    print "sealed data is:\n\n%s\n\n" % sealed_buf

    buf = verify_and_unseal_blob(pubkey_pem, "foo", sealed_buf)
    print "unsealed data is: \n\n%s\n\n" % buf
Esempio n. 7
0
def ft_seal_and_unseal():
    """
    Functional test for sealing/unsealing data
    """
    import syndicate.observer.core as observer_core

    c_syndicate.crypto_init()

    print "generating key pair"
    pubkey_pem, privkey_pem = api.generate_key_pair(4096)

    key = observer_core.generate_symmetric_secret()

    sealed_buf = create_sealed_and_signed_blob(privkey_pem, key, "hello world")
    print "sealed data is:\n\n%s\n\n" % sealed_buf

    buf = verify_and_unseal_blob(pubkey_pem, key, sealed_buf)
    print "unsealed data is: \n\n%s\n\n" % buf

    c_syndicate.crypto_shutdown()
Esempio n. 8
0
def ft_seal_and_unseal():
    """
    Functional test for sealing/unsealing data
    """
    import syndicate.observer.core as observer_core
    
    c_syndicate.crypto_init()
    
    print "generating key pair"
    pubkey_pem, privkey_pem = api.generate_key_pair( 4096 )
    
    key = observer_core.generate_symmetric_secret()
    
    sealed_buf = create_sealed_and_signed_blob( privkey_pem, key, "hello world")
    print "sealed data is:\n\n%s\n\n" % sealed_buf

    buf = verify_and_unseal_blob( pubkey_pem, key, sealed_buf )
    print "unsealed data is: \n\n%s\n\n" % buf
    
    c_syndicate.crypto_shutdown()
Esempio n. 9
0
            return None     # user already existed

    if new_user is None:
        # the method itself failed
        raise Exception("Creating %s failed" % user_email)

    else:
        # activate the user.
        # first, generate a keypair, if one was not given
        pubkey_pem = None 
        privkey_pem = None
        generated_keys = False
        
        if 'signing_private_key' not in user_kw.keys():
            log.info("Generating %s-bit key pair for %s" % (msconfig.OBJECT_KEY_SIZE, user_email))
            pubkey_pem, privkey_pem = api.generate_key_pair( msconfig.OBJECT_KEY_SIZE )
            generated_keys = True
        
        else:
            privkey_pem = user_kw['signing_private_key']
            
            try:
               pubkey_pem = CryptoKey.importKey( observer_pkey_pem ).publickey().exportKey()
            except Exception, e:
               logger.error("Malformed private key")
               raise e
               
        # then, activate the account with the keypair
        try:
            activate_rc = client.register_account( user_email, user_activate_pw, signing_public_key=pubkey_pem )
        except Exception, e:
Esempio n. 10
0
    if new_user is None:
        # the method itself failed
        raise Exception("Creating %s failed" % user_email)

    else:
        # activate the user.
        # first, generate a keypair, if one was not given
        pubkey_pem = None
        privkey_pem = None
        generated_keys = False

        if 'signing_private_key' not in user_kw.keys():
            log.info("Generating %s-bit key pair for %s" %
                     (msconfig.OBJECT_KEY_SIZE, user_email))
            pubkey_pem, privkey_pem = api.generate_key_pair(
                msconfig.OBJECT_KEY_SIZE)
            generated_keys = True

        else:
            privkey_pem = user_kw['signing_private_key']

            try:
                pubkey_pem = CryptoKey.importKey(
                    observer_pkey_pem).publickey().exportKey()
            except Exception, e:
                logger.error("Malformed private key")
                raise e

        # then, activate the account with the keypair
        try:
            activate_rc = client.register_account(