Spaces:
Sleeping
Sleeping
Fix encryption: support direct RSA-OAEP and hybrid RSA+AES-GCM modes
Browse files- encryption.py +17 -20
encryption.py
CHANGED
|
@@ -188,32 +188,29 @@ def decrypt_multiple_blocks(encrypted_data: str) -> list[Any]:
|
|
| 188 |
"""
|
| 189 |
Decrypt multiple concatenated encrypted blocks.
|
| 190 |
|
| 191 |
-
|
| 192 |
-
we need to find block boundaries by looking for valid JSON structures.
|
| 193 |
|
| 194 |
Args:
|
| 195 |
-
encrypted_data:
|
| 196 |
|
| 197 |
Returns:
|
| 198 |
List of decrypted data objects
|
| 199 |
"""
|
| 200 |
results = []
|
| 201 |
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
result
|
| 216 |
-
|
| 217 |
-
results.append(result)
|
| 218 |
-
|
| 219 |
return results
|
|
|
|
| 188 |
"""
|
| 189 |
Decrypt multiple concatenated encrypted blocks.
|
| 190 |
|
| 191 |
+
The input is expected to be a comma-separated list of base64 strings.
|
|
|
|
| 192 |
|
| 193 |
Args:
|
| 194 |
+
encrypted_data: Comma-separated base64-encoded encrypted blocks
|
| 195 |
|
| 196 |
Returns:
|
| 197 |
List of decrypted data objects
|
| 198 |
"""
|
| 199 |
results = []
|
| 200 |
|
| 201 |
+
if not encrypted_data:
|
| 202 |
+
return results
|
| 203 |
+
|
| 204 |
+
# Split by comma to separate blocks
|
| 205 |
+
# Base64 does not use commas, so this is safe
|
| 206 |
+
blocks = encrypted_data.split(',')
|
| 207 |
+
|
| 208 |
+
for block in blocks:
|
| 209 |
+
block = block.strip()
|
| 210 |
+
if not block:
|
| 211 |
+
continue
|
| 212 |
+
|
| 213 |
+
result = decrypt_data(block)
|
| 214 |
+
results.append(result)
|
| 215 |
+
|
|
|
|
|
|
|
| 216 |
return results
|