Example #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
Example #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
Example #3
0
 def _hmac(self, content):
     return hmac.new(self._secret,
                     msg=encode_string(content),
                     digestmod=hashlib.sha256).digest()
Example #4
0
 def __init__(self, secret):
     self._secret = encode_string(secret)
Example #5
0
 def _Hmac( self, content ):
   return hmac.new( self._secret,
                    msg = encode_string( content ),
                    digestmod = hashlib.sha256 ).digest()
Example #6
0
 def __init__( self, secret ):
   self._secret = encode_string( secret )