@@ -13,7 +13,7 @@ import javax.crypto.SecretKey
13
13
14
14
class MastgTest (private val context : Context ) {
15
15
16
- // Vulnerable encryption using DES (broken algorithm)
16
+ // Vulnerable encryption using DES (weak algorithm)
17
17
fun vulnerableDesEncryption (data : String ): String {
18
18
try {
19
19
// Weak key for DES
@@ -23,7 +23,7 @@ class MastgTest(private val context: Context) {
23
23
val keyFactory = SecretKeyFactory .getInstance(" DES" )
24
24
val secretKey: Key = keyFactory.generateSecret(keySpec)
25
25
26
- // Broken encryption algorithm (DES)
26
+ // Weak encryption algorithm (DES)
27
27
val cipher = Cipher .getInstance(" DES" )
28
28
cipher.init (Cipher .ENCRYPT_MODE , secretKey)
29
29
@@ -35,7 +35,7 @@ class MastgTest(private val context: Context) {
35
35
}
36
36
37
37
38
- // Risky encryption using 3DES (Triple DES)
38
+ // Vulnerable encryption using 3DES (Triple DES)
39
39
fun vulnerable3DesEncryption (data : String ): String {
40
40
try {
41
41
val keyBytes = ByteArray (24 )
@@ -44,7 +44,7 @@ class MastgTest(private val context: Context) {
44
44
val keyFactory = SecretKeyFactory .getInstance(" DESede" )
45
45
val secretKey: Key = keyFactory.generateSecret(keySpec)
46
46
47
- // Risky encryption algorithm (3DES)
47
+ // Weak encryption algorithm (3DES)
48
48
val cipher = Cipher .getInstance(" DESede" )
49
49
cipher.init (Cipher .ENCRYPT_MODE , secretKey)
50
50
@@ -72,15 +72,15 @@ class MastgTest(private val context: Context) {
72
72
}
73
73
}
74
74
75
- // Insecure encryption using Blowfish (broken algorithm)
75
+ // Insecure encryption using Blowfish (weak algorithm)
76
76
fun vulnerableBlowfishEncryption (data : String ): String {
77
77
return try {
78
78
// Weak key for Blowfish (insecure, small key size)
79
79
val keyBytes = ByteArray (8 ) // Only 8 bytes (64-bit key) - not secure
80
80
SecureRandom ().nextBytes(keyBytes)
81
81
val secretKey: SecretKey = SecretKeySpec (keyBytes, " Blowfish" )
82
82
83
- // Broken encryption algorithm (Blowfish)
83
+ // Weak encryption algorithm (Blowfish)
84
84
val cipher = Cipher .getInstance(" Blowfish" )
85
85
cipher.init (Cipher .ENCRYPT_MODE , secretKey)
86
86
@@ -95,16 +95,16 @@ class MastgTest(private val context: Context) {
95
95
fun mastgTest (): String {
96
96
val sensitiveString = " Hello from the OWASP MASTG Test app."
97
97
98
- // Encrypt with broken DES
98
+ // Encrypt with weak DES
99
99
val desEncryptedString = vulnerableDesEncryption(sensitiveString)
100
100
101
- // Encrypt with risky 3DES
101
+ // Encrypt with weak 3DES
102
102
val tripleDesEncryptedString = vulnerable3DesEncryption(sensitiveString)
103
103
104
104
// Encrypt with deprecated RC4
105
105
val rc4EncryptedString = vulnerableRc4Encryption(sensitiveString)
106
106
107
- // Encrypt with broken Blowfish
107
+ // Encrypt with weak Blowfish
108
108
val blowfishEncryptedString = vulnerableBlowfishEncryption(sensitiveString)
109
109
110
110
// Returning the encrypted results
0 commit comments