def primitive(self, key_data: tink_pb2.KeyData) -> _jwt_mac.JwtMac:
     if key_data.type_url != _JWT_HMAC_KEY_TYPE:
         raise _jwt_error.JwtInvalidError('Invalid key data key type')
     jwt_hmac_key = jwt_hmac_pb2.JwtHmacKey.FromString(key_data.value)
     algorithm = _HASH_TYPE_TO_ALGORITHM[jwt_hmac_key.hash_type]
     cc_mac = self._cc_key_manager.primitive(key_data.SerializeToString())
     return _JwtHmac(cc_mac, algorithm)
Example #2
0
 def primitive(self, key_data: tink_pb2.KeyData) -> _jwt_mac.JwtMacInternal:
     if key_data.type_url != _JWT_HMAC_KEY_TYPE:
         raise _jwt_error.JwtInvalidError('Invalid key data key type')
     jwt_hmac_key = jwt_hmac_pb2.JwtHmacKey.FromString(key_data.value)
     algorithm = _ALGORITHM_STRING[jwt_hmac_key.algorithm]
     cc_mac = self._cc_key_manager.primitive(key_data.SerializeToString())
     if jwt_hmac_key.HasField('custom_kid'):
         custom_kid = jwt_hmac_key.custom_kid.value
     else:
         custom_kid = None
     return _JwtHmac(cc_mac, algorithm, custom_kid)
Example #3
0
 def primitive(
     self, key_data: tink_pb2.KeyData
 ) -> _jwt_public_key_verify.JwtPublicKeyVerify:
     verify = self._cc_key_manager.primitive(key_data.SerializeToString())
     algorithm = self._key_data_to_algorithm(key_data)
     return _JwtPublicKeyVerify(verify, algorithm)
Example #4
0
 def public_key_data(self, key_data: tink_pb2.KeyData) -> tink_pb2.KeyData:
     return tink_pb2.KeyData.FromString(
         self._cc_key_manager.public_key_data(key_data.SerializeToString()))
Example #5
0
 def primitive(
     self, key_data: tink_pb2.KeyData
 ) -> _jwt_public_key_sign.JwtPublicKeySignInternal:
     sign = self._cc_key_manager.primitive(key_data.SerializeToString())
     algorithm = self._key_data_to_algorithm(key_data)
     return _JwtPublicKeySign(sign, algorithm)
Example #6
0
 def primitive(self, key_data: tink_pb2.KeyData) -> P:
     return self._primitive_py_wrapper(
         self._cc_key_manager.primitive(key_data.SerializeToString()))