Skip to content

Commit

Permalink
build: pin encrypt package to 5.0.2
Browse files Browse the repository at this point in the history
fix: where we were using encrypt package's IV.fromLength(16) to generate empty IVs, we now need to use IV(Uint8List(16)) as encrypt package 5.0.2 has changed the behaviour of IV.fromLength
build: temporarily change the git branch from which we are cloning `at_tools` to `gkc/work-around-encrypt-package-breaking-change` rather than trunk so can verify changes that have been made there before merging that PR
  • Loading branch information
gkc committed Sep 15, 2023
1 parent fead07d commit ac6b0c2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/at_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ jobs:
with:
repository: atsign-foundation/at_tools
path: at_tools
ref: trunk
ref: gkc/work-around-encrypt-package-breaking-change

- name: Fetch Cram Keys
id: cram_keys
Expand Down
2 changes: 1 addition & 1 deletion packages/at_secondary_server/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies:
collection: 1.18.0
basic_utils: 5.6.1
ecdsa: 0.0.4
encrypt: 5.0.1
encrypt: 5.0.2
at_commons: 3.0.55
at_utils: 3.0.15
at_chops: 1.0.4
Expand Down
3 changes: 2 additions & 1 deletion packages/at_secondary_server/test/keys_verb_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:convert';
import 'dart:typed_data';

import 'package:at_commons/at_commons.dart';
import 'package:at_persistence_secondary_server/at_persistence_secondary_server.dart';
Expand Down Expand Up @@ -730,7 +731,7 @@ void main() {
var apkamSymmetricKeyEncrypter = Encrypter(AES(Key.fromSecureRandom(32)));

var encryptedDefaultEncryptionPrivateKey = apkamSymmetricKeyEncrypter
.encrypt(encryptionPrivateKey, iv: IV.fromLength(16))
.encrypt(encryptionPrivateKey, iv: IV(Uint8List(16)))
.base64;
var valueJson = {};
valueJson['value'] = encryptedDefaultEncryptionPrivateKey;
Expand Down
4 changes: 3 additions & 1 deletion tests/at_functional_test/test/encryption_util.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

import 'dart:typed_data';

import 'package:crypton/crypton.dart';
import 'package:encrypt/encrypt.dart';

class EncryptionUtil {

static IV getIV(String? ivBase64) {
if (ivBase64 == null) {
return IV.fromLength(16);
return IV(Uint8List(16));
} else {
return IV.fromBase64(ivBase64);
}
Expand Down
5 changes: 3 additions & 2 deletions tests/at_functional_test/test/keys_verb_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';

import 'package:at_demo_data/at_demo_data.dart';
import 'package:at_demo_data/at_demo_data.dart' as at_demos;
Expand Down Expand Up @@ -102,7 +103,7 @@ void main() {
//3. put encryption private key which is encrypted with self symmetric key
var rsaPrivateKey = encryptionPrivateKeyMap[firstAtsign];
var encryptedPrivateKey = Encrypter(AES(Key.fromBase64(aesKey)))
.encrypt(rsaPrivateKey!, iv: IV.fromLength(16))
.encrypt(rsaPrivateKey!, iv: IV(Uint8List(16)))
.base64;
var privateKeyCommand =
'keys:put:private:namespace:__global:appName:wavi:deviceName:pixel:keyType:aes:encryptionKeyName:myAESkey:keyName:myPrivateKey $encryptedPrivateKey';
Expand Down Expand Up @@ -276,7 +277,7 @@ void main() {
//3. put encryption private key which is encrypted with self symmetric key
var rsaPrivateKey = encryptionPrivateKeyMap[firstAtsign];
var encryptedPrivateKey = Encrypter(AES(Key.fromBase64(aesKey)))
.encrypt(rsaPrivateKey!, iv: IV.fromLength(16))
.encrypt(rsaPrivateKey!, iv: IV(Uint8List(16)))
.base64;
var privateKeyCommand =
'keys:put:private:namespace:__global:appName:wavi:deviceName:pixel:keyType:aes:encryptionKeyName:myAESkey:keyName:myPrivateKey $encryptedPrivateKey';
Expand Down

0 comments on commit ac6b0c2

Please sign in to comment.