| 74 | } |
| 75 | |
| 76 | public static byte[] decryptKeyWithIES(byte[] input, long entryId, |
| 77 | PublicKey publicKey, PrivateKey privateKey) |
| 78 | throws GeneralSecurityException { |
| 79 | try { |
| 80 | // BC appears to be happier with BCECPrivateKeys: |
| 81 | privateKey = new BCECPrivateKey((ECPrivateKey) privateKey, null); |
| 82 | |
| 83 | return _cryptIES(input, privateKey, false); |
| 84 | } catch (GeneralSecurityException e) { |
| 85 | log.error("Error while decrypting key", e); |
| 86 | throw new GeneralSecurityException(e); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | private static byte[] _cryptIES(byte[] input, Key recipient, |
| 91 | boolean forEncryption) throws InvalidKeyException, |