我想尽可能地保护我的用户数据!在这种情况下,我试图保护内存中的数据不受某些内存攻击,或者至少让邪恶的人更难获取用户的数据。
我真的不明白Dart是如何处理记忆或任何语言的。所以,我正在寻找一些洞察力,方向或确认,在我试图在这里做的,而不需要一个计算机科学硕士。当我使用颤振/飞镖时,这也是一个普遍的问题。
我在这里的工作方式很简单,当我处理一些敏感数据时,我想:
这样做符合我的意愿吗?
如果这样做不符合我的意愿或毫无意义,请解释原因。
/*
- Symmetric encryption
- Encryption before putting data into transit
- This symmetric key and nonce are asymmetrically encrypted with authorized users public keys
- Authorized users can decrypt the key
- Sensitive data is encrypted then zeroed
*/
Future<String> symmetricallyEncrypt(Sale sale) async {
String saleJson = jsonEncode(sale);
final symmetricKey = await secureStorage.read(key: kSSKeySymmetric);
final symmetricNonce = await secureStorage.read(key: kSSKeySymmetricNonce);
final symmetricCypher = AesCrypt(padding: PaddingAES.pkcs7, key: symmetricKey!);
final encryptedSale = symmetricCypher.gcm.encrypt(inp: saleJson, iv: symmetricNonce!);
/* --- ENCRYPTED ZERO --- */
encryptedZero(saleJson);
encryptedZero(symmetricKey);
encryptedZero(symmetricNonce);
encryptedZero(symmetricCypher.toString());
return encryptedSale;
}
/*
Encryption zero method
- Encrypts shredding input
- Zeros all inputs
*/
Future<void> encryptedZero(String shredding) async {
String? asymmetricPublicZeroKey = await secureStorage.read(key: kSSKeyMemoryZeroAsymmetricPublic);
String encryptedShredding = RSAPublicKey.fromPEM(asymmetricPublicZeroKey!).encrypt(shredding);
asymmetricPublicZeroKey = '';
encryptedShredding = '';
shredding = '';
}发布于 2021-08-03 21:51:29
我明白你的要求,但我认为这不是思考你记忆安全的正确方式。
威胁演员是什么-另一个过程?操作系统?根用户?
如果您不信任根用户、操作系统和硬件,那么您已经失败了。
如果你必须相信他们,那么你的威胁演员还有什么?你必须相信你的申请。因此,唯一的其他事情是在同一个系统上运行的其他应用程序。
操作系统阻止其他应用程序读取内存空间(SEG错误等)。在将应用程序的内存页传递到另一个进程之前,操作系统会将其归零。
但这并不是整个故事的全部-更多的细节请阅读https://security.stackexchange.com/questions/29019/are-passwords-stored-in-memory-safe。
https://stackoverflow.com/questions/68629454
复制相似问题