@Test public void testLoadMalformedPublicKey() { byte[] publicKey = "malformed public key".getBytes(); try { encrypterManager.loadPublicKey(publicKey); fail("Did not throw GeneralSecurityException"); } catch (GeneralSecurityException e) { } }
public synchronized void loadPublicKey(byte[] publicKey) throws GeneralSecurityException { try { capillaryPublicKey = CapillaryPublicKey.parseFrom(publicKey); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("unable to parse public key", e); } encrypter = rawLoadPublicKey(capillaryPublicKey.getKeyBytes().toByteArray()); isLoaded = true; }
EncrypterManager { public synchronized void loadPublicKey(byte[] publicKey) throws GeneralSecurityException { try { capillaryPublicKey = CapillaryPublicKey.parseFrom(publicKey); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("unable to parse public key", e); } encrypter = rawLoadPublicKey(capillaryPublicKey.getKeyBytes().toByteArray()); isLoaded = true; } }
EncrypterManager { public synchronized void loadPublicKey(byte[] publicKey) throws GeneralSecurityException { try { capillaryPublicKey = CapillaryPublicKey.parseFrom(publicKey); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("unable to parse public key", e); } encrypter = rawLoadPublicKey(capillaryPublicKey.getKeyBytes().toByteArray()); isLoaded = true; }  }
EncrypterManager { public synchronized void loadPublicKey(byte[] publicKey) throws GeneralSecurityException { try { capillaryPublicKey = CapillaryPublicKey.parseFrom(publicKey); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("unable to parse public key", e); } encrypter = rawLoadPublicKey(capillaryPublicKey.getKeyBytes().toByteArray()); isLoaded = true; }  synchronized void loadPublicKey(byte[] publicKey); synchronized byte[] encrypt(byte[] data); synchronized void clearPublicKey(); }
EncrypterManager { public synchronized void loadPublicKey(byte[] publicKey) throws GeneralSecurityException { try { capillaryPublicKey = CapillaryPublicKey.parseFrom(publicKey); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("unable to parse public key", e); } encrypter = rawLoadPublicKey(capillaryPublicKey.getKeyBytes().toByteArray()); isLoaded = true; }  synchronized void loadPublicKey(byte[] publicKey); synchronized byte[] encrypt(byte[] data); synchronized void clearPublicKey();  }