def new_key_data(self,
                  key_template: tink_pb2.KeyTemplate) -> tink_pb2.KeyData:
     data = self._cc_key_manager.new_key_data(
         key_template.SerializeToString())
     key_data = tink_pb2.KeyData()
     key_data.ParseFromString(data)
     return key_data
Esempio n. 2
0
def new_keyset(stub: testing_api_pb2_grpc.KeysetStub,
               key_template: tink_pb2.KeyTemplate) -> bytes:
    gen_request = testing_api_pb2.KeysetGenerateRequest(
        template=key_template.SerializeToString())
    gen_response = stub.Generate(gen_request)
    if gen_response.err:
        raise tink.TinkError(gen_response.err)
    return gen_response.keyset
Esempio n. 3
0
def new_keyset_handle(stub: testing_api_pb2_grpc.KeysetStub,
                      key_template: tink_pb2.KeyTemplate) -> tink.KeysetHandle:
    gen_request = testing_api_pb2.KeysetGenerateRequest(
        template=key_template.SerializeToString())
    gen_response = stub.Generate(gen_request)
    if gen_response.err:
        raise tink.TinkError(gen_response.err)
    return cleartext_keyset_handle.read(
        tink.BinaryKeysetReader(gen_response.keyset))
Esempio n. 4
0
 def new_key_data(self,
                  key_template: tink_pb2.KeyTemplate) -> tink_pb2.KeyData:
     return tink_pb2.KeyData.FromString(
         self._cc_key_manager.new_key_data(
             key_template.SerializeToString()))