Пример #1
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:
    reader = readers.FileReader(loc)
    if crypter:
      reader = readers.EncryptedReader(reader, crypter)
    return keyczar.GenericKeyczar(reader)
Пример #2
0
def UseKey(purpose, loc, dest, crypter=None, msg="This is some test data"):
  reader = readers.FileReader(loc)
  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)
Пример #3
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.FileReader(location))
Пример #4
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.FileReader(location))
Пример #5
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.FileReader(location))
Пример #6
0
 def Read(location):
     """Return a GenericKeyczar created from FileReader at given location."""
     return GenericKeyczar(readers.FileReader(location))