def hmac_type_str(self, val=None): """Returns the HMAC type string for the given value. If no value is given, the HMAC type for the current context is returned. """ if val == None: val = _fko.get_spa_hmac_type(self.ctx) if val == FKO_HMAC_INVALID_DATA: ht = "invalid_data" elif val == FKO_HMAC_UNKNOWN: ht = "unknown" elif val == FKO_HMAC_MD5: ht = "MD5" elif val == FKO_HMAC_SHA1: ht = "SHA1" elif val == FKO_HMAC_SHA256: ht = "SHA256" elif val == FKO_HMAC_SHA384: ht = "SHA384" elif val == FKO_HMAC_SHA512: ht = "SHA512" else: ht = "Invalid HMAC digest type value" return ht
def hmac_type(self, val=None): """Get or set the spa_hmac_type This is an integer value. If no argument is given, the current value is returned. Otherwise, the SPA message client timeout value will be set to the given value. """ if val != None: _fko.set_spa_hmac_type(self.ctx, val) else: return _fko.get_spa_hmac_type(self.ctx)
def spa_data_final(self, key, hmac_key): """Perform final processing and generation of the SPA message data. This function is the final step in creating a complete encrypted SPA data string suitable for transmission to an fwknop server. It does require all of the requisite SPA data fields be set. Otherwise, it will fail and throw an fko.error exception. We do set the default HMAC digest to SHA256 if an HMAC key was provided and the HMAC mode was not already set. """ if hmac_key and not _fko.get_spa_hmac_type(self.ctx): _fko.set_spa_hmac_type(self.ctx, FKO_HMAC_SHA256) _fko.spa_data_final(self.ctx, key, hmac_key)