| 59 | public class Crypto { |
| 60 | |
| 61 | public static byte[] encryptKeyWithIES(byte[] input, long entryId, |
| 62 | PublicKey publicKey, PrivateKey privateKey) |
| 63 | throws GeneralSecurityException { |
| 64 | try { |
| 65 | // BC appears to be happier with BCECPublicKeys: |
| 66 | // see BC's IESCipher.engineInit's check for ECPublicKey |
| 67 | publicKey = new BCECPublicKey((ECPublicKey) publicKey, null); |
| 68 | |
| 69 | return _cryptIES(input, publicKey, true); |
| 70 | } catch (GeneralSecurityException e) { |
| 71 | log.error("Error while encrypting key", e); |
| 72 | throw e; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | public static byte[] decryptKeyWithIES(byte[] input, long entryId, |
| 77 | PublicKey publicKey, PrivateKey privateKey) |