@Test public void toHashWithDefaultData() throws Exception { AbstractPublicKey goodPublicKey1 = new RSAOAEPPublicKey( BigIntegers.asUnsignedByteArray(randomPublicKey1.getModulus()), BigIntegers.asUnsignedByteArray(randomPublicKey1.getExponent()), HashType.SHA1, HashType.SHA1, new SecureRandom()); Map map1 = goodPublicKey1.toHash(); assertArrayEquals((byte[]) map1.get("n"), BigIntegers.asUnsignedByteArray(randomPublicKey1.getModulus())); assertArrayEquals((byte[]) map1.get("e"), BigIntegers.asUnsignedByteArray(randomPublicKey1.getExponent())); assertFalse(map1.containsKey("hash")); assertFalse(map1.containsKey("mgf1Hash")); }
@NonNull @Override public Map<String, Object> toHash() throws IllegalStateException { if (state == null) { throw new IllegalStateException(); } else { return Collections.unmodifiableMap(new HashMap<String, Object>() {{ put("n", BigIntegers.asUnsignedByteArray(state.keyParameters.getModulus())); put("e", BigIntegers.asUnsignedByteArray(state.keyParameters.getExponent())); if (!state.mgf1HashType.equals(DEFAULT_MGF1_HASH)) { put("mgf1Hash", state.mgf1HashType.getAlgorithmName()); } }}); } }
RSAOAEPPublicKey extends AbstractPublicKey { @NonNull @Override public Map<String, Object> toHash() throws IllegalStateException { if (state == null) { throw new IllegalStateException(); } else { return Collections.unmodifiableMap(new HashMap<String, Object>() {{ put("n", BigIntegers.asUnsignedByteArray(state.keyParameters.getModulus())); put("e", BigIntegers.asUnsignedByteArray(state.keyParameters.getExponent())); if (!state.mgf1HashType.equals(DEFAULT_MGF1_HASH)) { put("mgf1Hash", state.mgf1HashType.getAlgorithmName()); } }}); } } }
RSAOAEPPublicKey extends AbstractPublicKey { @NonNull @Override public Map<String, Object> toHash() throws IllegalStateException { if (state == null) { throw new IllegalStateException(); } else { return Collections.unmodifiableMap(new HashMap<String, Object>() {{ put("n", BigIntegers.asUnsignedByteArray(state.keyParameters.getModulus())); put("e", BigIntegers.asUnsignedByteArray(state.keyParameters.getExponent())); if (!state.mgf1HashType.equals(DEFAULT_MGF1_HASH)) { put("mgf1Hash", state.mgf1HashType.getAlgorithmName()); } }}); } } RSAOAEPPublicKey();   RSAOAEPPublicKey(byte[] n, byte[] e, HashType oaepHashType, HashType mgf1HashType, SecureRandom rng); }
RSAOAEPPublicKey extends AbstractPublicKey { @NonNull @Override public Map<String, Object> toHash() throws IllegalStateException { if (state == null) { throw new IllegalStateException(); } else { return Collections.unmodifiableMap(new HashMap<String, Object>() {{ put("n", BigIntegers.asUnsignedByteArray(state.keyParameters.getModulus())); put("e", BigIntegers.asUnsignedByteArray(state.keyParameters.getExponent())); if (!state.mgf1HashType.equals(DEFAULT_MGF1_HASH)) { put("mgf1Hash", state.mgf1HashType.getAlgorithmName()); } }}); } } RSAOAEPPublicKey();   RSAOAEPPublicKey(byte[] n, byte[] e, HashType oaepHashType, HashType mgf1HashType, SecureRandom rng); @Override String toString(); @Override boolean canEncrypt(); @Override int getBitStrength(); @Override boolean isInitialized(); @NonNull @Override byte[] encrypt(byte[] plaintext); @NonNull @Override boolean checkSignature(InputStream input, byte[] signature, HashType hashType, int saltLength); @NonNull @Override String algorithmTag(); @NonNull @Override Map<String, Object> toHash(); @Override void updateFromHash(Map<String, Object> hash); }
RSAOAEPPublicKey extends AbstractPublicKey { @NonNull @Override public Map<String, Object> toHash() throws IllegalStateException { if (state == null) { throw new IllegalStateException(); } else { return Collections.unmodifiableMap(new HashMap<String, Object>() {{ put("n", BigIntegers.asUnsignedByteArray(state.keyParameters.getModulus())); put("e", BigIntegers.asUnsignedByteArray(state.keyParameters.getExponent())); if (!state.mgf1HashType.equals(DEFAULT_MGF1_HASH)) { put("mgf1Hash", state.mgf1HashType.getAlgorithmName()); } }}); } } RSAOAEPPublicKey();   RSAOAEPPublicKey(byte[] n, byte[] e, HashType oaepHashType, HashType mgf1HashType, SecureRandom rng); @Override String toString(); @Override boolean canEncrypt(); @Override int getBitStrength(); @Override boolean isInitialized(); @NonNull @Override byte[] encrypt(byte[] plaintext); @NonNull @Override boolean checkSignature(InputStream input, byte[] signature, HashType hashType, int saltLength); @NonNull @Override String algorithmTag(); @NonNull @Override Map<String, Object> toHash(); @Override void updateFromHash(Map<String, Object> hash); static final HashType DEFAULT_OAEP_HASH; static final HashType DEFAULT_MGF1_HASH; }