-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
106 changed files
with
10,428 additions
and
9,383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: pre-commit | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [develop] | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
- uses: actions/setup-java@v1 | ||
with: | ||
java-version: '11' | ||
- uses: pre-commit/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
repos: | ||
- repo: https://github.com/c4dt/google-style-precommit-hook | ||
rev: v1.0 | ||
hooks: | ||
- id: google-style-java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,30 @@ | ||
/** | ||
* This file only serves as an example on how to get keys in the right encoding. | ||
* This outputs the keys in the PKCS8 format for the private key and the X509 format for the publickey | ||
* | ||
* DO NOT USE THEM IN PRODUCTION UNLESS THE KEYSPECS ARE OK FOR YOU | ||
* This file only serves as an example on how to get keys in the right encoding. This outputs the | ||
* keys in the PKCS8 format for the private key and the X509 format for the publickey | ||
* | ||
* <p>DO NOT USE THEM IN PRODUCTION UNLESS THE KEYSPECS ARE OK FOR YOU | ||
*/ | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.security.Key; | ||
import java.security.KeyPair; | ||
import java.security.KeyPairGenerator; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.PrivateKey; | ||
import java.security.PublicKey; | ||
import java.security.Security; | ||
import java.util.Base64; | ||
|
||
import java.security.Security; | ||
public class GenerateKeyPair { | ||
public static void main(String[] args) throws Exception { | ||
Security.setProperty("crypto.policy", "unlimited"); | ||
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA"); | ||
KeyPair pair = generator.genKeyPair(); | ||
PrivateKey privateKey = pair.getPrivate(); | ||
PublicKey publicKey = pair.getPublic(); | ||
FileOutputStream outputStream = new FileOutputStream("generated_pub.pem"); | ||
outputStream.write(Base64.getEncoder().encode(publicKey.getEncoded())); | ||
outputStream.close(); | ||
|
||
public class GenerateKeyPair{ | ||
public static void main(String[] args) throws Exception { | ||
Security.setProperty("crypto.policy", "unlimited"); | ||
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA"); | ||
KeyPair pair = generator.genKeyPair(); | ||
PrivateKey privateKey = pair.getPrivate(); | ||
PublicKey publicKey = pair.getPublic(); | ||
FileOutputStream outputStream = new FileOutputStream("generated_pub.pem"); | ||
outputStream.write(Base64.getEncoder().encode(publicKey.getEncoded())); | ||
outputStream.close(); | ||
|
||
outputStream = new FileOutputStream("generated_private.pem"); | ||
outputStream.write(Base64.getEncoder().encode(privateKey.getEncoded())); | ||
outputStream.close(); | ||
} | ||
} | ||
outputStream = new FileOutputStream("generated_private.pem"); | ||
outputStream.write(Base64.getEncoder().encode(privateKey.getEncoded())); | ||
outputStream.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,51 @@ | ||
/** | ||
* This file only serves as an example on how to get keys in the right encoding. | ||
* In order to use it you need BouncyCastle on the classpath! | ||
* | ||
* DO NOT USE THEM IN PRODUCTION UNLESS THE KEYSPECS ARE OK FOR YOU | ||
* This file only serves as an example on how to get keys in the right encoding. In order to use it | ||
* you need BouncyCastle on the classpath! | ||
* | ||
* <p>DO NOT USE THEM IN PRODUCTION UNLESS THE KEYSPECS ARE OK FOR YOU | ||
*/ | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.security.Key; | ||
import java.io.StringWriter; | ||
import java.security.KeyPair; | ||
import java.security.KeyPairGenerator; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.PrivateKey; | ||
import java.security.PublicKey; | ||
import java.util.Base64; | ||
import java.security.spec.ECGenParameterSpec; | ||
import java.io.StringWriter; | ||
|
||
import java.security.Security; | ||
import java.security.spec.ECGenParameterSpec; | ||
import java.util.Base64; | ||
import org.bouncycastle.jce.provider.BouncyCastleProvider; | ||
import org.bouncycastle.util.io.pem.PemWriter; | ||
import org.bouncycastle.util.io.pem.PemObject; | ||
import org.bouncycastle.util.io.pem.PemWriter; | ||
|
||
public class GenerateKeyPairEC { | ||
public static void main(String[] args) throws Exception { | ||
Security.addProvider(new BouncyCastleProvider()); | ||
Security.setProperty("crypto.policy", "unlimited"); | ||
KeyPairGenerator generator = KeyPairGenerator.getInstance("ECDSA", "BC"); | ||
ECGenParameterSpec spec = new ECGenParameterSpec("secp256r1"); | ||
generator.initialize(spec); | ||
KeyPair pair = generator.genKeyPair(); | ||
PrivateKey privateKey = pair.getPrivate(); | ||
PublicKey publicKey = pair.getPublic(); | ||
|
||
public class GenerateKeyPairEC{ | ||
public static void main(String[] args) throws Exception { | ||
Security.addProvider(new BouncyCastleProvider()); | ||
Security.setProperty("crypto.policy", "unlimited"); | ||
KeyPairGenerator generator = KeyPairGenerator.getInstance("ECDSA", "BC"); | ||
ECGenParameterSpec spec = new ECGenParameterSpec("secp256r1"); | ||
generator.initialize(spec); | ||
KeyPair pair = generator.genKeyPair(); | ||
PrivateKey privateKey = pair.getPrivate(); | ||
PublicKey publicKey = pair.getPublic(); | ||
StringWriter privateKeyWriter = new StringWriter(); | ||
PemWriter privateKeyPemWriter = new PemWriter(privateKeyWriter); | ||
privateKeyPemWriter.writeObject(new PemObject("PRIVATE KEY", privateKey.getEncoded())); | ||
privateKeyPemWriter.flush(); | ||
privateKeyPemWriter.close(); | ||
|
||
StringWriter privateKeyWriter = new StringWriter(); | ||
PemWriter privateKeyPemWriter = new PemWriter(privateKeyWriter); | ||
privateKeyPemWriter.writeObject(new PemObject("PRIVATE KEY", privateKey.getEncoded())); | ||
privateKeyPemWriter.flush(); | ||
privateKeyPemWriter.close(); | ||
StringWriter publicKeyWriter = new StringWriter(); | ||
PemWriter publicKeyPemWriter = new PemWriter(publicKeyWriter); | ||
publicKeyPemWriter.writeObject(new PemObject("PUBLIC KEY", publicKey.getEncoded())); | ||
publicKeyPemWriter.flush(); | ||
publicKeyPemWriter.close(); | ||
|
||
StringWriter publicKeyWriter = new StringWriter(); | ||
PemWriter publicKeyPemWriter = new PemWriter(publicKeyWriter); | ||
publicKeyPemWriter.writeObject(new PemObject("PUBLIC KEY", publicKey.getEncoded())); | ||
publicKeyPemWriter.flush(); | ||
publicKeyPemWriter.close(); | ||
FileOutputStream outputStream = new FileOutputStream("generated_pub.pem"); | ||
outputStream.write(Base64.getEncoder().encode(publicKeyWriter.toString().getBytes())); | ||
outputStream.close(); | ||
|
||
FileOutputStream outputStream = new FileOutputStream("generated_pub.pem"); | ||
outputStream.write(Base64.getEncoder().encode( | ||
publicKeyWriter.toString().getBytes() | ||
)); | ||
outputStream.close(); | ||
|
||
outputStream = new FileOutputStream("generated_private.pem"); | ||
outputStream.write(Base64.getEncoder().encode( | ||
privateKeyWriter.toString().getBytes() | ||
)); | ||
outputStream.close(); | ||
} | ||
} | ||
outputStream = new FileOutputStream("generated_private.pem"); | ||
outputStream.write(Base64.getEncoder().encode(privateKeyWriter.toString().getBytes())); | ||
outputStream.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.