Skip to content

Commit

Permalink
RELEASE
Browse files Browse the repository at this point in the history
  • Loading branch information
kaifer authored and root committed Apr 12, 2023
1 parent cf501a2 commit 71dfa31
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ JAVA 1.8버전 사용자들을 위한 세션키 발급 및 개인정보 암복

예시)
```
<version>0.0.10</version>
<version>0.0.11</version>
```

pom.xml 을 사용하시면 아래와 같이 추가해주세요.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group 'com.github.toss'
version '0.0.10'
version '0.0.11'

sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
Expand Down
32 changes: 28 additions & 4 deletions src/main/java/im/toss/cert/sdk/TossCertSession.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package im.toss.cert.sdk;

import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

Expand Down Expand Up @@ -42,8 +46,18 @@ public String encrypt(String plainText) {
String encrypted = aesCipher.encrypt(plainText);
String hash = calculateHash(plainText);
return addMeta(StringUtils.join(separator, new String[]{encrypted, hash}));
} catch (Exception e) {
throw new RuntimeException(e);
} catch (InvalidAlgorithmParameterException e) {
throw new RuntimeException(e.getCause());
} catch (NoSuchPaddingException e) {
throw new RuntimeException(e.getCause());
} catch (IllegalBlockSizeException e) {
throw new RuntimeException(e.getCause());
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e.getCause());
} catch (BadPaddingException e) {
throw new RuntimeException(e.getCause());
} catch (InvalidKeyException e) {
throw new RuntimeException(e.getCause());
}
}

Expand All @@ -62,8 +76,18 @@ public String decrypt(String encryptedText) {
String plainText = aesCipher.decrypt(items[2]);
verify(plainText, items);
return plainText;
} catch (Exception e) {
throw new RuntimeException(e);
} catch (InvalidAlgorithmParameterException e) {
throw new RuntimeException(e.getCause());
} catch (NoSuchPaddingException e) {
throw new RuntimeException(e.getCause());
} catch (IllegalBlockSizeException e) {
throw new RuntimeException(e.getCause());
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e.getCause());
} catch (BadPaddingException e) {
throw new RuntimeException(e.getCause());
} catch (InvalidKeyException e) {
throw new RuntimeException(e.getCause());
}
}

Expand Down
33 changes: 26 additions & 7 deletions src/main/java/im/toss/cert/sdk/TossCertSessionGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
import javax.crypto.NoSuchPaddingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.UUID;

public class TossCertSessionGenerator {
private final static String version = "v1_0.0.10";
private final static String version = "v1_0.0.11";
private final static String publicKey = "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAoVdxG0Qi9pip46Jw9ImSlPVD8+L2mM47ey6EZna7D7utgNdh8Tzkjrm1Yl4h6kPJrhdWvMIJGS51+6dh041IXcJEoUquNblUEqAUXBYwQM8PdfnS12SjlvZrP4q6whBE7IV1SEIBJP0gSK5/8Iu+uld2ctJiU4p8uswL2bCPGWdvVPltxAg6hfAG/ImRUKPRewQsFhkFvqIDCpO6aeaR10q6wwENZltlJeeRnl02VWSneRmPqqypqCxz0Y+yWCYtsA+ngfZmwRMaFkXcWjaWnvSqqV33OAsrQkvuBHWoEEkvQ0P08+h9Fy2+FhY9TeuukQ2CVFz5YyOhp25QtWyQI+IaDKk+hLxJ1APR0c3tmV0ANEIjO6HhJIdu2KQKtgFppvqSrZp2OKtI8EZgVbWuho50xvlaPGzWoMi9HSCb+8ARamlOpesxHH3O0cTRUnft2Zk1FHQb2Pidb2z5onMEnzP2xpTqAIVQyb6nMac9tof5NFxwR/c4pmci+1n8GFJIFN18j2XGad1mNyio/R8LabqnzNwJC6VPnZJz5/pDUIk9yKNOY0KJe64SRiL0a4SNMohtyj6QlA/3SGxaEXb8UHpophv4G9wN1CgfyUamsRqp8zo5qDxBvlaIlfkqJvYPkltj7/23FHDjPi8q8UkSiAeu7IV5FTfB5KsiN8+sGSMCAwEAAQ==";

private final RSACipher rsaCipher;
Expand All @@ -20,8 +21,10 @@ public TossCertSessionGenerator() {
public TossCertSessionGenerator(String publicKeyString) {
try {
this.rsaCipher = new RSACipher(publicKeyString);
} catch (Exception e) {
throw new RuntimeException(e);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e.getCause());
} catch (InvalidKeySpecException e) {
throw new RuntimeException(e.getCause());
}
}

Expand Down Expand Up @@ -53,8 +56,16 @@ private TossCertSession generate(AESAlgorithm algorithm, int keyLength, int ivLe
}
String encryptedSessionKey = buildEncryptSessionKeyPart(algorithm, secretKey, iv);
return new TossCertSession(version, id, algorithm, secretKey, iv, encryptedSessionKey);
} catch (Exception e) {
throw new RuntimeException(e);
} catch (NoSuchPaddingException e) {
throw new RuntimeException(e.getCause());
} catch (IllegalBlockSizeException e) {
throw new RuntimeException(e.getCause());
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e.getCause());
} catch (BadPaddingException e) {
throw new RuntimeException(e.getCause());
} catch (InvalidKeyException e) {
throw new RuntimeException(e.getCause());
}
}

Expand All @@ -66,8 +77,16 @@ public TossCertSession deserialize(String serializedSessionKey) {
String iv = fields[4];
String encryptedSessionKey = buildEncryptSessionKeyPart(algorithm, secretKey, iv);
return new TossCertSession(fields[0], fields[1], algorithm, secretKey, iv, encryptedSessionKey);
} catch (Exception e) {
throw new RuntimeException(e);
} catch (NoSuchPaddingException e) {
throw new RuntimeException(e.getCause());
} catch (IllegalBlockSizeException e) {
throw new RuntimeException(e.getCause());
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e.getCause());
} catch (BadPaddingException e) {
throw new RuntimeException(e.getCause());
} catch (InvalidKeyException e) {
throw new RuntimeException(e.getCause());
}
}

Expand Down

0 comments on commit 71dfa31

Please sign in to comment.