-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
breaking!: Reorganize atchops #770
base: trunk
Are you sure you want to change the base?
Conversation
@@ -36,7 +37,8 @@ void main(List<String> args) async { | |||
atChops = AtChopsImpl(atChopsKeys); | |||
} | |||
|
|||
var atEncryptionKeyPair = atChops.atChopsKeys.atEncryptionKeyPair; | |||
var atEncryptionKeyPair = | |||
atChops.atChopsKeys.atEncryptionKeyPair as AtRSAKeyPair?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example of the place we need the cast, atChopsKeys has been generalized
@@ -1,34 +1,16 @@ | |||
library at_chops; | |||
// export cryptography wrappers | |||
export 'src/hashing/hashing.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added files named after the directories in src to make export management easier.
@@ -65,7 +66,7 @@ class _AtKeysCryptoImpl implements AtKeysCrypto { | |||
String hashKey = | |||
await _getHashKey(passPhrase, _hashingAlgoType, hashParams: hashParams); | |||
|
|||
AESKey aesKey = AESKey(hashKey); | |||
AtAESKey aesKey = AtAESKey(hashKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed to prevent namespace collisions with other packages.
|
||
AtChopsKeys get atChopsKeys => _atChopsKeys; | ||
const AtChops.init(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constructor does nothing, it only exists to allow the class to be extended.
|
||
/// Default self encryption key | ||
SymmetricKey? selfEncryptionKey; | ||
|
||
/// APKAM symmetric key created during new enrollment | ||
SymmetricKey? apkamSymmetricKey; | ||
|
||
/// EnrollmentId associated with pkam keys | ||
String? enrollmentId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added enrollmentId so that AtAuthKeys in at_auth can be casted to and from AtChopsKeys (without losing information).
/// These parameters are particularly useful when working with algorithms | ||
/// like Argon2id, which can be adjusted for performance and security needs. | ||
|
||
class ArgonHashParams extends HashParams { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from a separate file to be with it's hashing algorithm implementation
|
||
class HashParams {} | ||
|
||
class DefaultHashingAlgo extends Md5HashingAlgo {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've taken all the DefaultXXXAlgo and named them after their proper algorithm, then extended each of them to become the new DefaultAlgo. They still all conform to the same interface.
import 'dart:typed_data'; | ||
|
||
/// Represents a key pair for asymmetric public-private key encryption/decryption | ||
abstract class AsymmetricKeyPair<Pub extends AtPublicKey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AsymmetricKeyPairs can now be flavored with covariants of AtPublicKey and AtPrivateKey. Non breaking change, as they still conform to the same interface.
final String _aesKey; | ||
class AtAESKey extends SymmetricKey { | ||
@override | ||
final Uint8List raw; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed so that the stored member is the raw bytes rather than the base64 encoded string. This should reduce decrypt/encrypt latency as we don't need to decode every time now.
19a75e4
to
8d5b3dd
Compare
@@ -1 +1,11 @@ | |||
enum EncryptionKeyType { rsa2048, rsa4096, ecc, aes128, aes192, aes256 } | |||
enum EncryptionKeyType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to be a blocker later...
Sometimes we want to infer an algo, but when we infer from a runtimeType we don't always have the key size, nor care about the key size.
But also, when we get the algo used to encrypt / sign from a string, it's useful to have the algo. It's questionable whether it's useful to have the size. Maybe we need to make this a sealed class later, but, then it's not open to extension...
Setting back to draft, more work to be done. |
- What I did
Breaking:
(although breaking, today it only requires an additional cast in some places from
AtSymmetricKeyPair
toAtRSAKeyPair?
)However, this future proofs the API in preparation for supporting different key types / algos for pkam and shared encryption, it is actually the other parts of the API that need to be adapted which will element the need for the cast
Non-breaking:
- How I did it
- How to verify it
- Description for the changelog
breaking!: Reorganize atchops