def test_mech_conversions(self, flavor): """ Test that converting each mechanism works as expected w/ valid params. """ params = MECH_PARAMS[flavor] mech = Mechanism(flavor, params=params) cmech = mech.to_c_mech() # Would prefer to check if it's a c_void_p, but it gets transformed directly to # an int/long depending on memory location. assert isinstance(cmech.pParameter, (integer_types, c_ulong)) assert isinstance(cmech.usParameterLen, (integer_types, c_ulong)) assert isinstance(cmech, CK_MECHANISM) assert cmech.mechanism == flavor
def test_null_mechanism_indirect_instantiation(self): """ Test automech by instantiating Mechanism() instead of AutoMech() :return: """ # Patch the mechanism lookup so that we don't have to have an undefined # mechanism to test the automech. with patch.dict(MECH_LOOKUP, {}, clear=True): pymech = Mechanism(CKM_RSA_PKCS_PSS) assert isinstance(pymech, NullMech) cmech = pymech.to_c_mech() assert cmech.pParameter is None assert cmech.usParameterLen == 0