Example #1
0
 def _GetReader(self, algorithm, crypter, pub_key):
     """ Gets a keyczar reader for the given algorithm and key set crypter"""
     reader = readers.CreateReader(
         self._GetKeyPath(algorithm + crypter + pub_key))
     if crypter:
         key_set_crypter = keyczar.Crypter.Read(self._GetKeyPath(crypter))
         reader = readers.EncryptedReader(reader, key_set_crypter)
     return reader
Example #2
0
  def Read(location):
    """
    Return a Keyczar object created from FileReader at given location.

    @param location: pathname of the directory storing the key files
    @type location: string

    @return: a Keyczar to manage the keys stored at the given location
    @rtype: L{Keyczar}
    """
    return Keyczar(readers.CreateReader(location))
Example #3
0
  def Read(location):
    """
    Return a Signer object created from FileReader at given location.

    @param location: pathname of the directory storing the key files
    @type location: string

    @return: a Signer to manage the keys stored at the given location and
      perform sign and verify functions.
    @rtype: L{Signer}
    """
    return Signer(readers.CreateReader(location))
Example #4
0
  def Read(location):
    """
    Return a Crypter object created from FileReader at given location.

    @param location: pathname of the directory storing the key files
    @type location: string

    @return: a Crypter to manage the keys stored at the given location and
      perform encryption and decryption functions.
    @rtype: L{Crypter}
    """
    return Crypter(readers.CreateReader(location))
Example #5
0
def UseKey(purpose, loc, dest, crypter=None, msg="This is some test data"):
    reader = readers.CreateReader(loc)
    try:
        answer = ""
        if crypter:
            reader = readers.EncryptedReader(reader, crypter)
        if purpose == keyinfo.DECRYPT_AND_ENCRYPT:
            answer = keyczar.Crypter(reader).Encrypt(msg)
        elif purpose == keyinfo.SIGN_AND_VERIFY:
            answer = keyczar.Signer(reader).Sign(msg)
        util.WriteFile(answer, dest)
    finally:
        reader.Close()
Example #6
0
def CreateGenericKeyczar(loc, crypter=None):
    if mock is not None:
        return keyczar.GenericKeyczar(mock)
    if loc is None:
        raise errors.KeyczarError("Need location")
    else:
        generic = None
        reader = readers.CreateReader(loc)
        try:
            if crypter:
                reader = readers.EncryptedReader(reader, crypter)
            generic = keyczar.GenericKeyczar(reader)
        finally:
            reader.Close()
        return generic
Example #7
0
 def Read(location):
   """Return a GenericKeyczar created from FileReader at given location."""
   return GenericKeyczar(readers.CreateReader(location))