Ejemplo n.º 1
0
def TemporaryHmacSecretFile( secret ):
  """Helper function for passing the hmac secret when starting a JediHTTP server

    with TemporaryHmacSecretFile( 'mysecret' ) as hmac_file:
      jedihttp = subprocess.Popen( ['python',
                                    'jedihttp',
                                    '--hmac-file-secret', hmac_file.name ] )

    The JediHTTP Server as soon as it reads the hmac secret will remove the file
  """
  hmac_file = tempfile.NamedTemporaryFile( 'w', delete = False )
  encoded_secret = decode_string( b64encode( encode_string( secret ) ) )
  json.dump( { 'hmac_secret': encoded_secret }, hmac_file )
  return hmac_file
Ejemplo n.º 2
0
def TemporaryHmacSecretFile(secret):
    """Helper function for passing the hmac secret when starting a JediHTTP server

    with TemporaryHmacSecretFile( 'mysecret' ) as hmac_file:
      jedihttp = subprocess.Popen( ['python',
                                    'jedihttp',
                                    '--hmac-file-secret', hmac_file.name ] )

    The JediHTTP Server as soon as it reads the hmac secret will remove the file
  """
    hmac_file = tempfile.NamedTemporaryFile('w', delete=False)
    encoded_secret = decode_string(b64encode(encode_string(secret)))
    json.dump({'hmac_secret': encoded_secret}, hmac_file)
    return hmac_file
Ejemplo n.º 3
0
 def _hmac(self, content):
     return hmac.new(self._secret,
                     msg=encode_string(content),
                     digestmod=hashlib.sha256).digest()
Ejemplo n.º 4
0
 def __init__(self, secret):
     self._secret = encode_string(secret)
Ejemplo n.º 5
0
 def _Hmac( self, content ):
   return hmac.new( self._secret,
                    msg = encode_string( content ),
                    digestmod = hashlib.sha256 ).digest()
Ejemplo n.º 6
0
 def __init__( self, secret ):
   self._secret = encode_string( secret )