docs: add uml models
This commit is contained in:
parent
38cb0a5988
commit
f47c352efb
25
resources/models/aes_classes.puml
Normal file
25
resources/models/aes_classes.puml
Normal file
@ -0,0 +1,25 @@
|
||||
@startuml aes_classes
|
||||
|
||||
abstract class Cipher<T extends CipherChunk> {
|
||||
encrypt(plainText: Uint8List): CipherText<T>
|
||||
decrypt(cipherText: CipherText<T>): Uint8List
|
||||
encryptFile(plainTextFile: Path, cipherTextFile: Path)
|
||||
decryptFile(cipherTextFile: Path, plainTextFile: Path)
|
||||
}
|
||||
|
||||
class AES extends Cipher {
|
||||
key: SecretKey
|
||||
mode: AESMode
|
||||
padding: Padding
|
||||
chunkSize: int
|
||||
|
||||
encrypt(plainText: Uint8List): CipherText<AESCipherChunk>
|
||||
decrypt(cipherText: CipherText<AESCipherChunk>): Uint8List
|
||||
encryptFile(plainTextFile: Path, cipherTextFile: Path)
|
||||
decryptFile(cipherTextFile: Path, plainTextFile: Path)
|
||||
|
||||
encryptWithIV(plainText: Uint8List, iv: Uint8List): AESCipherChunk
|
||||
decryptWithIV(cipherChunk: AESCipherChunk, iv: Uint8List): Uint8List
|
||||
}
|
||||
|
||||
@enduml
|
44
resources/models/aes_dss.puml
Normal file
44
resources/models/aes_dss.puml
Normal file
@ -0,0 +1,44 @@
|
||||
@startuml aes_dss
|
||||
|
||||
actor user
|
||||
participant AES as aes
|
||||
participant CipherText as ct
|
||||
participant CipherChunk as cc
|
||||
participant NativeCrypto as nc
|
||||
|
||||
user -> aes : new(key: SecretKey, mode: Mode, padding: Padding, chunkSize: int)
|
||||
activate aes
|
||||
aes --> user : AES
|
||||
user -> aes : encrypt(plainText: Uint8List)
|
||||
|
||||
loop for each chunk in plainText
|
||||
aes -> nc : encrypt(chunk: Uint8List, key: Uint8List, "aes/gcm/NoPadding")
|
||||
nc --> aes : Uint8List
|
||||
aes -> cc : new(chunk: Uint8List)
|
||||
cc --> aes : CipherChunk
|
||||
end
|
||||
|
||||
aes -> ct : new(chunks: List<CipherChunk>)
|
||||
ct --> aes : CipherText
|
||||
aes --> user : CipherText
|
||||
|
||||
user -> aes : decrypt(cipherText: CipherText)
|
||||
loop for each chunk in cipherText.chunks
|
||||
aes -> nc : decrypt(chunk: Uint8List, key: Uint8List, "aes/gcm/NoPadding")
|
||||
nc --> aes : Uint8List
|
||||
aes --> aes : concat Uint8List
|
||||
end
|
||||
|
||||
aes --> user : Uint8List
|
||||
|
||||
user -> aes : encryptFile(plainTextFile: File, cipherTextFile: File)
|
||||
aes -> nc : encryptFile(plainTextFile: File, cipherTextFile: File, key: Uint8List, "aes/gcm/NoPadding")
|
||||
nc --> aes : void
|
||||
aes --> user : void
|
||||
|
||||
user -> aes : decryptFile(cipherTextFile: File, plainTextFile: File)
|
||||
aes -> nc : decryptFile(cipherTextFile: File, plainTextFile: File, key: Uint8List, "aes/gcm/NoPadding")
|
||||
nc --> aes : void
|
||||
aes --> user : void
|
||||
|
||||
@enduml
|
63
resources/models/cipher_text_classes.puml
Normal file
63
resources/models/cipher_text_classes.puml
Normal file
@ -0,0 +1,63 @@
|
||||
@startuml cipher_text_classes
|
||||
|
||||
abstract class ByteArray {
|
||||
bytes : Uint8List
|
||||
length : int
|
||||
|
||||
ByteArray(bytes: Uint8List)
|
||||
|
||||
fromList(list: List<int>)
|
||||
fromLength(length: int, {fill: int = 0})
|
||||
fromUtf16(encoded: String)
|
||||
fromUtf8(encoded: String)
|
||||
fromBase64(encoded: String)
|
||||
fromBase16(encoded: String)
|
||||
|
||||
toList() : List<int>
|
||||
toUtf16() : String
|
||||
toUtf8() : String
|
||||
toBase64() : String
|
||||
toBase16() : String
|
||||
}
|
||||
|
||||
class CipherChunk extends ByteArray {
|
||||
CipherChunk(bytes: Uint8List)
|
||||
|
||||
fromList(list: List<int>)
|
||||
fromUtf16(encoded: String)
|
||||
fromUtf8(encoded: String)
|
||||
fromBase64(encoded: String)
|
||||
fromBase16(encoded: String)
|
||||
}
|
||||
|
||||
class CipherText<T extends CipherChunk> extends ByteArray {
|
||||
chunkSize : int
|
||||
chunks : List<T>
|
||||
|
||||
CipherText(bytes: Uint8List, {chunkSize: int = 33554432})
|
||||
|
||||
fromList(list: List<int>)
|
||||
fromUtf16(encoded: String)
|
||||
fromUtf8(encoded: String)
|
||||
fromBase64(encoded: String)
|
||||
fromBase16(encoded: String)
|
||||
|
||||
toList() : List<int>
|
||||
toUtf16() : String
|
||||
toUtf8() : String
|
||||
toBase64() : String
|
||||
toBase16() : String
|
||||
|
||||
fromChunks(chunks: List<T>)
|
||||
toChunks() : List<T>
|
||||
toBytes() : Uint8List
|
||||
}
|
||||
|
||||
class AESCipherChunk extends CipherChunk {
|
||||
iv : Uint8List
|
||||
message : Uint8List
|
||||
tag : Uint8List
|
||||
}
|
||||
|
||||
|
||||
@enduml
|
19
resources/models/cipher_text_dss.puml
Normal file
19
resources/models/cipher_text_dss.puml
Normal file
@ -0,0 +1,19 @@
|
||||
@startuml cipher_text_dss
|
||||
|
||||
actor user
|
||||
participant CipherText as ct
|
||||
participant CipherChunk as cc
|
||||
|
||||
user -> ct : new(bytes)
|
||||
loop for each chunk
|
||||
ct -> cc : new(bytes)
|
||||
cc --> ct
|
||||
end
|
||||
ct --> user : CipherText
|
||||
|
||||
user -> ct : new(bytes, chunkSize: bytes.length)
|
||||
ct -> cc : new(bytes)
|
||||
cc --> ct
|
||||
ct --> user : CipherText
|
||||
|
||||
@enduml
|
25
resources/models/digest_classes.puml
Normal file
25
resources/models/digest_classes.puml
Normal file
@ -0,0 +1,25 @@
|
||||
@startuml digest_classes
|
||||
|
||||
abstract class Hash {
|
||||
digest(data: Uint8List): Uint8List
|
||||
}
|
||||
|
||||
abstract class Hmac {
|
||||
digest(data: Uint8List, key: Uint8List): Uint8List
|
||||
}
|
||||
|
||||
Hmac o-- Hash
|
||||
|
||||
class Sha256 extends Hash {
|
||||
static instance: Sha256
|
||||
}
|
||||
|
||||
class Sha512 extends Hash {
|
||||
static instance: Sha512
|
||||
}
|
||||
|
||||
class HmacSha256 extends Hmac {
|
||||
static instance: HmacSha256
|
||||
}
|
||||
|
||||
@enduml
|
29
resources/models/digest_dss.puml
Normal file
29
resources/models/digest_dss.puml
Normal file
@ -0,0 +1,29 @@
|
||||
@startuml digest_dss
|
||||
|
||||
actor user
|
||||
participant Flutter as flt
|
||||
participant Sha256 as sha
|
||||
participant HmacSha256 as hmac
|
||||
participant NativeCrypto as nc
|
||||
|
||||
user -> flt : getDigest("sha256")
|
||||
flt -> sha : getInstance()
|
||||
sha --> flt : Sha256
|
||||
flt --> user : Sha256
|
||||
|
||||
user -> sha : digest(data)
|
||||
sha --> nc : hash(data, "sha256")
|
||||
nc --> sha : digest
|
||||
sha --> user : digest
|
||||
|
||||
user -> flt : getDigest("hmacSha256")
|
||||
flt -> hmac : getInstance()
|
||||
hmac --> flt : HmacSha256
|
||||
flt --> user : HmacSha256
|
||||
|
||||
user -> hmac : digest(data)
|
||||
hmac --> nc : hmac(data, key, "sha256")
|
||||
nc --> hmac : digest
|
||||
hmac --> user : digest
|
||||
|
||||
@enduml
|
9
resources/models/generator_classes.puml
Normal file
9
resources/models/generator_classes.puml
Normal file
@ -0,0 +1,9 @@
|
||||
@startuml generator_classes
|
||||
|
||||
abstract class Random {
|
||||
generate(bytes: int): Uint8List
|
||||
}
|
||||
|
||||
class SecureRandom extends Random {}
|
||||
|
||||
@enduml
|
15
resources/models/generator_dss.puml
Normal file
15
resources/models/generator_dss.puml
Normal file
@ -0,0 +1,15 @@
|
||||
@startuml generator_dss
|
||||
|
||||
actor user
|
||||
participant SecureRandom as rand
|
||||
participant NativeCrypto as nc
|
||||
|
||||
user -> rand : new()
|
||||
rand --> user : SecureRandom
|
||||
|
||||
user -> rand : generate(32)
|
||||
rand -> nc : generateRandomBytes(32)
|
||||
nc --> rand : Uint8List(32)
|
||||
rand --> user : Uint8List(32)
|
||||
|
||||
@enduml
|
17
resources/models/kdf_classes.puml
Normal file
17
resources/models/kdf_classes.puml
Normal file
@ -0,0 +1,17 @@
|
||||
@startuml kdf_classes
|
||||
|
||||
abstract class KeyDerivationFunction {
|
||||
derive(keyMaterial: Uint8List) : Uint8List
|
||||
verify(keyMaterial: Uint8List, expected: Uint8List) : bool
|
||||
}
|
||||
|
||||
class PBKDF2 extends KeyDerivationFunction {
|
||||
hashAlgorithm: Hash
|
||||
iterations: int
|
||||
salt: Uint8List
|
||||
length: int
|
||||
|
||||
call({password: String}) : SecretKey
|
||||
}
|
||||
|
||||
@enduml
|
20
resources/models/kdf_dss.puml
Normal file
20
resources/models/kdf_dss.puml
Normal file
@ -0,0 +1,20 @@
|
||||
@startuml kdf_dss
|
||||
|
||||
actor user
|
||||
participant Pbkdf2 as kdf
|
||||
participant NativeCrypto as nc
|
||||
|
||||
user -> kdf: new(hash, iterations, salt, length)
|
||||
kdf--> user : Pbkdf2
|
||||
|
||||
user -> kdf: derive(password)
|
||||
kdf--> nc : pbkdf2(password, hash, iterations, salt, length)
|
||||
nc --> kdf: Uint8List(length)
|
||||
kdf--> user : SecretKey
|
||||
|
||||
user -> kdf : verify(password, key)
|
||||
kdf--> nc : pbkdf2(password, hash, iterations, salt, length)
|
||||
nc --> kdf: Uint8List(length)
|
||||
kdf--> user : bool
|
||||
|
||||
@enduml
|
40
resources/models/key_classes.puml
Normal file
40
resources/models/key_classes.puml
Normal file
@ -0,0 +1,40 @@
|
||||
@startuml key_classes
|
||||
|
||||
abstract class ByteArray {
|
||||
bytes : Uint8List
|
||||
length : int
|
||||
|
||||
fromList(list: List<int> )
|
||||
fromLength(length: int, {fill: int = 0})
|
||||
fromUtf16(encoded: String)
|
||||
fromUtf8(encoded: String)
|
||||
fromBase64(encoded: String)
|
||||
fromBase16(encoded: String)
|
||||
|
||||
toList() : List<int>
|
||||
toUtf16() : String
|
||||
toUtf8() : String
|
||||
toBase64() : String
|
||||
toBase16() : String
|
||||
|
||||
}
|
||||
|
||||
abstract class Key extends ByteArray {
|
||||
fromList(list: List<int> )
|
||||
fromUtf16(encoded: String)
|
||||
fromUtf8(encoded: String)
|
||||
fromBase64(encoded: String)
|
||||
fromBase16(encoded: String)
|
||||
}
|
||||
|
||||
class SecretKey extends Key {
|
||||
fromList(list: List<int>)
|
||||
fromUtf16(encoded: String)
|
||||
fromUtf8(encoded: String)
|
||||
fromBase64(encoded: String)
|
||||
fromBase16(encoded: String)
|
||||
|
||||
async fromSecureRandom(bytes: int)
|
||||
}
|
||||
|
||||
@enduml
|
17
resources/models/key_dss.puml
Normal file
17
resources/models/key_dss.puml
Normal file
@ -0,0 +1,17 @@
|
||||
@startuml key_dss
|
||||
|
||||
actor user
|
||||
participant SecretKey as sk
|
||||
participant SecureRandom as rand
|
||||
participant NativeCrypto as nc
|
||||
|
||||
user -> sk : fromSecureRandom(32)
|
||||
sk -> rand : new()
|
||||
rand --> sk : SecureRandom
|
||||
sk -> rand : generate(32)
|
||||
rand -> nc : generateRandomBytes(32)
|
||||
nc --> rand : Uint8List(32)
|
||||
rand --> sk : Uint8List(32)
|
||||
sk --> user : SecretKey
|
||||
|
||||
@enduml
|
Loading…
x
Reference in New Issue
Block a user