Ejemplo n.º 1
0
 def sign_msg(self, msg, alias):
     reader = keyczar.KeysetPBEJSONFileReader(KEYSET_ROOT_PATH + alias + '/' + SIG_KEY_DIR,self.keyset_password_sig)
     signer = keyczar.Signer.Read(reader) # sender's private signing key
     signer.set_encoding(signer.NO_ENCODING)
     signature = signer.Sign(msg)
     #print "Signed Msg."
     return signature
Ejemplo n.º 2
0
 def decrypt_msg(self, encrypted_msg, alias):
     #print "Decrypting Msg from: ", alias
     #print "keyset psw: " + self.keyset_password_sig
     reader = keyczar.KeysetPBEJSONFileReader(KEYSET_ROOT_PATH + alias + '/' + CRYPT_KEY_DIR, self.keyset_password_crypt)
     crypter = keyczar.Crypter.Read(reader)
     crypter.set_encoding(crypter.NO_ENCODING)
     decrypted_msg = crypter.Decrypt(encrypted_msg)
     return decrypted_msg
Ejemplo n.º 3
0
 def authenticate_user(self, keyset_password_crypt, keyset_password_sig,alias):
     self.log.info("Authenticating " + alias)
     #print "With Passwords:"
     #print "Crypt Psw:", keyset_password_crypt
     #print "Sig Psw:", keyset_password_sig
     isReg = True
     self.log.debug( KEYSET_ROOT_PATH + alias + '/')
     if not os.path.isdir(KEYSET_ROOT_PATH + alias + '/'):
         #Node has not been configured (Factory State). Probably Temp. We will add a first time sequence
         self.log.info( "DSC Node has not been configured. This is where we generate keysets.")
         return False
     try:
         reader_crypt = keyczar.KeysetPBEJSONFileReader(KEYSET_ROOT_PATH + alias + '/' + CRYPT_KEY_DIR, keyset_password_crypt)
         crypter = keyczar.Crypter.Read(reader_crypt)
         reader_sig = keyczar.KeysetPBEJSONFileReader(KEYSET_ROOT_PATH + alias + '/' + SIG_KEY_DIR, keyset_password_sig)
         signer = keyczar.Signer.Read(reader_sig)
     except Exception, e:
         self.log.error("Authentication Exception: ", exc_info=True)
         return False
Ejemplo n.º 4
0
def Encrypt(crypted_path, password):
    if not os.path.exists(crypted_path):
        return

    input = 'Secret message'

    reader = keyczar.KeysetPBEJSONFileReader(crypted_path, password)
    crypter = keyczar.Crypter.Read(reader)
    ciphertext = crypter.Encrypt(input)

    print 'plaintext:', input
    print 'ciphertext:', ciphertext

    decrypted = crypter.Decrypt(ciphertext)
    assert decrypted == input
Ejemplo n.º 5
0
def DecryptMessage(keyset_type, keyset_password, rsa_path, ciphertext):
    reader = keyczar.KeysetPBEJSONFileReader(rsa_path, keyset_password)
    crypter = keyczar.Crypter.Read(reader)
    plaintext = crypter.Decrypt(ciphertext)
    return plaintext