|
|
|
@ -13,6 +13,7 @@ import cokr.xit.base.crypto.Cryptography;
|
|
|
|
|
public class ARIA extends Cryptography {
|
|
|
|
|
private String
|
|
|
|
|
key,
|
|
|
|
|
hashedPassword,
|
|
|
|
|
algorithm;
|
|
|
|
|
private int blockSize;
|
|
|
|
|
|
|
|
|
@ -39,6 +40,21 @@ public class ARIA extends Cryptography {
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**비밀번호 해시값을 반환한다.
|
|
|
|
|
* @return 비밀번호 해시값
|
|
|
|
|
*/
|
|
|
|
|
public String getHashedPassword() {
|
|
|
|
|
return hashedPassword;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**비밀번호 해시값을 설정한다.
|
|
|
|
|
* @param hashedPassword 비밀번호 해시값
|
|
|
|
|
*/
|
|
|
|
|
public ARIA setHashedPassword(String hashedPassword) {
|
|
|
|
|
this.hashedPassword = hashedPassword;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**알고리즘을 반환한다. 디폴트는 SHA-256.
|
|
|
|
|
* @return 알고리즘
|
|
|
|
|
*/
|
|
|
|
@ -71,17 +87,20 @@ public class ARIA extends Cryptography {
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public byte[] encrypt(byte[] plain) {
|
|
|
|
|
return service().encrypt(plain, key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected String doEncrypt(String plain) {
|
|
|
|
|
byte[] bytes = service().encrypt(plain.getBytes(), key);
|
|
|
|
|
byte[] bytes = encrypt(plain.getBytes());
|
|
|
|
|
return Base64.getEncoder().encodeToString(bytes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private EgovPasswordEncoder passwordEncoder() {
|
|
|
|
|
if (passwordEncoder == null) {
|
|
|
|
|
passwordEncoder = new EgovPasswordEncoder();
|
|
|
|
|
String hashed = passwordEncoder.encryptPassword(getKey());
|
|
|
|
|
passwordEncoder.setHashedPassword(hashed);
|
|
|
|
|
passwordEncoder.setHashedPassword(ifEmpty(hashedPassword, hashedPassword = passwordEncoder.encryptPassword(getKey())));
|
|
|
|
|
passwordEncoder.setAlgorithm(getAlgorithm());
|
|
|
|
|
}
|
|
|
|
|
return passwordEncoder;
|
|
|
|
@ -96,10 +115,14 @@ public class ARIA extends Cryptography {
|
|
|
|
|
return aria;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public byte[] decrypt(byte[] encrypted) {
|
|
|
|
|
return service().decrypt(encrypted, key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected String doDecrypt(String encrypted) {
|
|
|
|
|
byte[] bytes = Base64.getDecoder().decode(encrypted);
|
|
|
|
|
return new String(service().decrypt(bytes, key));
|
|
|
|
|
return new String(decrypt(bytes));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**현재 설정상태를 비운다.
|
|
|
|
|