forked from underlx/underlx
-
Notifications
You must be signed in to change notification settings - Fork 0
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
5 changed files
with
83 additions
and
24 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
39 changes: 39 additions & 0 deletions
39
app/src/debug/java/im/tny/segvault/disturbances/Ospylac.java.example
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,39 @@ | ||
package im.tny.segvault.disturbances; | ||
|
||
import android.content.Context; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.security.KeyFactory; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.PrivateKey; | ||
import java.security.spec.InvalidKeySpecException; | ||
import java.security.spec.PKCS8EncodedKeySpec; | ||
|
||
/** | ||
* Created by Gabriel on 27/07/2017. | ||
*/ | ||
|
||
final class Ospylac { | ||
public static PrivateKey getPrivateKey(Context context, String param) { | ||
try { | ||
InputStream is = context.getAssets().open(param); | ||
byte[] keyBytes = new byte[is.available()]; | ||
is.read(keyBytes); | ||
is.close(); | ||
|
||
PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes); | ||
KeyFactory kf = KeyFactory.getInstance("EC"); | ||
return kf.generatePrivate(spec); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} catch (InvalidKeySpecException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} catch (NoSuchAlgorithmException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
app/src/release/java/im/tny/segvault/disturbances/Ospylac.java.example
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,39 @@ | ||
package im.tny.segvault.disturbances; | ||
|
||
import android.content.Context; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.security.KeyFactory; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.PrivateKey; | ||
import java.security.spec.InvalidKeySpecException; | ||
import java.security.spec.PKCS8EncodedKeySpec; | ||
|
||
/** | ||
* Created by Gabriel on 27/07/2017. | ||
*/ | ||
|
||
final class Ospylac { | ||
public static PrivateKey getPrivateKey(Context context, String param) { | ||
try { | ||
InputStream is = context.getAssets().open(param); | ||
byte[] keyBytes = new byte[is.available()]; | ||
is.read(keyBytes); | ||
is.close(); | ||
|
||
PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes); | ||
KeyFactory kf = KeyFactory.getInstance("EC"); | ||
return kf.generatePrivate(spec); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} catch (InvalidKeySpecException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} catch (NoSuchAlgorithmException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
} |