jebin2 commited on
Commit
e8c1799
·
1 Parent(s): 9784c05

Fix encryption: support direct RSA-OAEP and hybrid RSA+AES-GCM modes

Browse files
Files changed (1) hide show
  1. 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
- Each block is a complete base64 JSON payload. Since blocks can vary in size,
192
- we need to find block boundaries by looking for valid JSON structures.
193
 
194
  Args:
195
- encrypted_data: Concatenated base64-encoded encrypted blocks
196
 
197
  Returns:
198
  List of decrypted data objects
199
  """
200
  results = []
201
 
202
- # If it looks like a single block (starts with valid base64 for JSON)
203
- # Try single block first
204
- if encrypted_data:
205
- result = decrypt_data(encrypted_data)
206
- if result and "decryption_error" not in result:
207
- results.append(result)
208
- return results
209
-
210
- # If single block fails, the data might be multiple blocks
211
- # Since each block is base64(JSON), we need to find block boundaries
212
- # Common approach: try to find where one base64 ends and another begins
213
- # For now, store the error result from single attempt
214
- if not results:
215
- result = decrypt_data(encrypted_data)
216
- if result:
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