1 // Copyright 2022 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 //////////////////////////////////////////////////////////////////////////////// 16 17 package com.google.crypto.tink.monitoring; 18 19 import com.google.crypto.tink.annotations.Alpha; 20 21 /** 22 * Interface for a monitoring client which can be registered with Tink. 23 * 24 * <p>A MonitoringClient is informed by Tink about certain events happening during cryptographic 25 * operations. It can be registered in the Registry. 26 * 27 * <p>When a new primitive is created, the monitoring client will be called to create logger 28 * objects. These loggers are then called on each operation of the primitive. 29 * 30 * <p>DO NOT USE. This API is not yet ready and may change or be removed. 31 */ 32 @Alpha 33 public interface MonitoringClient { 34 35 /** Interface that logs specific API calls of a specific primitive.*/ 36 public interface Logger { log(int keyId, long numBytesAsInput)37 public void log(int keyId, long numBytesAsInput); 38 logFailure()39 public void logFailure(); 40 } 41 42 /** Function that creates Logger objects. It is called when a primitive is created. */ createLogger(MonitoringKeysetInfo keysetInfo, String primitive, String api)43 public Logger createLogger(MonitoringKeysetInfo keysetInfo, String primitive, String api); 44 } 45