Rename Paddin to PlainTextPadding

This commit is contained in:
Hugo Pointcheval 2020-12-19 17:21:01 +01:00
parent 06bb6e1595
commit acc9261a66
2 changed files with 11 additions and 8 deletions

View File

@ -6,13 +6,13 @@ import 'dart:typed_data';
import 'key.dart';
/// Represents different cipher algorithms
enum CipherAlgorithm { AES, BlowFish }
enum CipherAlgorithm { AES, BlowFish, None }
/// Represents different block cipher modes
enum BlockCipherMode { ECB, CBC, CFB, GCM, CGM }
/// Represents different padding
enum Padding { ANSI_X923, PKCS5, PKCS7, None }
enum PlainTextPadding { PKCS5, None }
/// Represents a cipher.
///
@ -32,6 +32,9 @@ abstract class Cipher {
/// Returns true if cipher is initialized
bool get isInitialized;
/// Returnes list of supported [CipherParameters] for this cipher
List<CipherParameters> get supportedParameters;
/// Encrypts data.
///
/// Takes [Uint8List] data as parameter.
@ -62,15 +65,15 @@ abstract class CipherText {
/// Represents a pair of [BlockCipherMode] and [Padding]
class CipherParameters {
BlockCipherMode _mode;
Padding _padding;
PlainTextPadding _padding;
/// Returns mode used in the cipher
BlockCipherMode get mode => _mode;
/// Returns padding used in the cipher
Padding get padding => _padding;
PlainTextPadding get padding => _padding;
CipherParameters(BlockCipherMode mode, Padding padding) {
CipherParameters(BlockCipherMode mode, PlainTextPadding padding) {
_mode = mode;
_padding = padding;
}

View File

@ -29,7 +29,7 @@ extension BlockCipherModeExtension on BlockCipherMode {
String get name => describeEnum(this).toLowerCase();
}
extension PaddingExtension on Padding {
extension PlainTextPaddingExtension on PlainTextPadding {
String get name => describeEnum(this).toLowerCase();
}
@ -121,13 +121,13 @@ class Utils {
static CipherParameters getCipherParameters(String parameters) {
List<String> _query = parameters.toLowerCase().split("/");
BlockCipherMode _mode;
Padding _padding;
PlainTextPadding _padding;
for (BlockCipherMode b in BlockCipherMode.values) {
if (_query[0] == b.name) {
_mode = b;
}
}
for (Padding p in Padding.values) {
for (PlainTextPadding p in PlainTextPadding.values) {
if (_query[1] == p.name) {
_padding = p;
}