@Test public void readNoSecretFailWithTypeSymmetric() throws Exception { String keyValue = "01234567890123456"; Keyset keyset = TestUtil.createKeyset( TestUtil.createKey( TestUtil.createHmacKeyData(keyValue.getBytes("UTF-8"), 16), 42, KeyStatusType.ENABLED, OutputPrefixType.TINK)); try { KeysetHandle unused = KeysetHandle.readNoSecret(keyset.toByteArray()); fail("Expected GeneralSecurityException"); } catch (GeneralSecurityException e) { assertExceptionContains(e, "keyset contains key material of type"); assertExceptionContains(e, " type.googleapis.com/google.crypto.tink.HmacKey"); } try { KeysetHandle unused = KeysetHandle.readNoSecret(BinaryKeysetReader.withBytes(keyset.toByteArray())); fail("Expected GeneralSecurityException"); } catch (GeneralSecurityException e) { assertExceptionContains(e, "keyset contains key material"); } }
public static final KeysetHandle readNoSecret(KeysetReader reader) throws GeneralSecurityException, IOException { try { Keyset keyset = reader.read(); assertNoSecretKeyMaterial(keyset); return KeysetHandle.fromKeyset(keyset); } catch (@SuppressWarnings("UnusedException") InvalidProtocolBufferException e) { throw new GeneralSecurityException("invalid keyset"); } }
KeysetHandle { public static final KeysetHandle readNoSecret(KeysetReader reader) throws GeneralSecurityException, IOException { try { Keyset keyset = reader.read(); assertNoSecretKeyMaterial(keyset); return KeysetHandle.fromKeyset(keyset); } catch (@SuppressWarnings("UnusedException") InvalidProtocolBufferException e) { throw new GeneralSecurityException("invalid keyset"); } } }
KeysetHandle { public static final KeysetHandle readNoSecret(KeysetReader reader) throws GeneralSecurityException, IOException { try { Keyset keyset = reader.read(); assertNoSecretKeyMaterial(keyset); return KeysetHandle.fromKeyset(keyset); } catch (@SuppressWarnings("UnusedException") InvalidProtocolBufferException e) { throw new GeneralSecurityException("invalid keyset"); } } private  KeysetHandle(Keyset keyset); }
KeysetHandle { public static final KeysetHandle readNoSecret(KeysetReader reader) throws GeneralSecurityException, IOException { try { Keyset keyset = reader.read(); assertNoSecretKeyMaterial(keyset); return KeysetHandle.fromKeyset(keyset); } catch (@SuppressWarnings("UnusedException") InvalidProtocolBufferException e) { throw new GeneralSecurityException("invalid keyset"); } } private  KeysetHandle(Keyset keyset); KeysetInfo getKeysetInfo(); @Deprecated static final KeysetHandle generateNew(com.google.crypto.tink.proto.KeyTemplate keyTemplate); static final KeysetHandle generateNew(KeyTemplate keyTemplate); static final KeysetHandle read(KeysetReader reader, Aead masterKey); static final KeysetHandle readNoSecret(KeysetReader reader); static final KeysetHandle readNoSecret(final byte[] serialized); void write(KeysetWriter keysetWriter, Aead masterKey); void writeNoSecret(KeysetWriter writer); KeysetHandle getPublicKeysetHandle(); @Override String toString(); static void assertEnoughKeyMaterial(Keyset keyset); static void assertEnoughEncryptedKeyMaterial(EncryptedKeyset keyset); P getPrimitive(Class<P> targetClassObject); P getPrimitive(KeyManager<P> customKeyManager, Class<P> targetClassObject); }
KeysetHandle { public static final KeysetHandle readNoSecret(KeysetReader reader) throws GeneralSecurityException, IOException { try { Keyset keyset = reader.read(); assertNoSecretKeyMaterial(keyset); return KeysetHandle.fromKeyset(keyset); } catch (@SuppressWarnings("UnusedException") InvalidProtocolBufferException e) { throw new GeneralSecurityException("invalid keyset"); } } private  KeysetHandle(Keyset keyset); KeysetInfo getKeysetInfo(); @Deprecated static final KeysetHandle generateNew(com.google.crypto.tink.proto.KeyTemplate keyTemplate); static final KeysetHandle generateNew(KeyTemplate keyTemplate); static final KeysetHandle read(KeysetReader reader, Aead masterKey); static final KeysetHandle readNoSecret(KeysetReader reader); static final KeysetHandle readNoSecret(final byte[] serialized); void write(KeysetWriter keysetWriter, Aead masterKey); void writeNoSecret(KeysetWriter writer); KeysetHandle getPublicKeysetHandle(); @Override String toString(); static void assertEnoughKeyMaterial(Keyset keyset); static void assertEnoughEncryptedKeyMaterial(EncryptedKeyset keyset); P getPrimitive(Class<P> targetClassObject); P getPrimitive(KeyManager<P> customKeyManager, Class<P> targetClassObject);  }