-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from konstantinullrich/feature/#35_Make_RSAKey…
…pair.fromRandom()_async Add Keypair Factory
- Loading branch information
Showing
7 changed files
with
94 additions
and
13 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:crypton/crypton.dart'; | ||
|
||
/// [KeypairFactory] using the EC Algorithm | ||
class ECKeypairFactory implements KeypairFactory { | ||
/// Create a fresh [ECKeypairFactory] | ||
ECKeypairFactory(); | ||
|
||
/// Generate a random [ECKeypair] | ||
@override | ||
ECKeypair fromRandom() => ECKeypair.fromRandom(); | ||
|
||
/// Generate a random [ECKeypair] asynchronously | ||
@override | ||
Future<ECKeypair> fromRandomAsync() async => | ||
Future(() => ECKeypair.fromRandom()); | ||
} |
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,12 @@ | ||
import 'package:crypton/crypton.dart'; | ||
|
||
abstract class KeypairFactory { | ||
/// Create a fresh [KeypairFactory] | ||
KeypairFactory(); | ||
|
||
/// Generate a random [Keypair] | ||
Keypair fromRandom(); | ||
|
||
/// Generate a random [Keypair] asynchronously | ||
Future<Keypair> fromRandomAsync(); | ||
} |
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 @@ | ||
import 'package:crypton/crypton.dart'; | ||
|
||
/// [KeypairFactory] using the RSA Algorithm | ||
class RSAKeypairFactory implements KeypairFactory { | ||
/// Create a fresh [RSAKeypairFactory] | ||
RSAKeypairFactory(); | ||
|
||
/// Generate a random [RSAKeypair] | ||
@override | ||
RSAKeypair fromRandom({int keySize = 2048}) => | ||
RSAKeypair.fromRandom(keySize: keySize); | ||
|
||
/// Generate a random [RSAKeypair] asynchronously | ||
@override | ||
Future<RSAKeypair> fromRandomAsync({int keySize = 2048}) async => | ||
Future(() => RSAKeypair.fromRandom(keySize: keySize)); | ||
} |
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