package com.eactive.eai.common.security; public interface CryptoModuleExtension { void init(String alg, String mode, String pad, byte[] encKey, byte[] decKey) throws Exception; void init(String alg, String mode, String pad, byte[] iv, byte[] encKey, byte[] decKey) throws Exception; /** 프로바이더를 명시한 초기화. 미지원 구현체는 provider를 무시하고 기본 동작한다. */ default void init(String alg, String mode, String pad, byte[] encKey, byte[] decKey, String provider) throws Exception { init(alg, mode, pad, encKey, decKey); } /** 프로바이더를 명시한 초기화 (IV 포함). 미지원 구현체는 provider를 무시하고 기본 동작한다. */ default void init(String alg, String mode, String pad, byte[] iv, byte[] encKey, byte[] decKey, String provider) throws Exception { init(alg, mode, pad, iv, encKey, decKey); } int encrypt(byte[] src, int sindex, int slength, byte[] dst, int dindex) throws Exception; byte[] encrypt(byte[] src, int sindex, int slength) throws Exception; /** AAD를 명시한 암호화. null이면 구현체 기본 동작(IV를 AAD로 사용하거나 AAD 없음)을 따른다. */ default byte[] encrypt(byte[] src, int sindex, int slength, byte[] aad) throws Exception { return encrypt(src, sindex, slength); } default byte[] encrypt(byte[] src) throws Exception { return encrypt(src, 0, src.length); } default byte[] encrypt(byte[] src, byte[] aad) throws Exception { return encrypt(src, 0, src.length, aad); } int decrypt(byte[] src, int sindex, int slength, byte[] dst, int dindex) throws Exception; byte[] decrypt(byte[] src, int sindex, int slength) throws Exception; /** AAD를 명시한 복호화. null이면 구현체 기본 동작을 따른다. */ default byte[] decrypt(byte[] src, int sindex, int slength, byte[] aad) throws Exception { return decrypt(src, sindex, slength); } default byte[] decrypt(byte[] src) throws Exception { return decrypt(src, 0, src.length); } default byte[] decrypt(byte[] src, byte[] aad) throws Exception { return decrypt(src, 0, src.length, aad); } }