MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / pad_aes_gcm

Function pad_aes_gcm

keepercommander/api.py:140–155  ·  view source on GitHub ↗
(json)

Source from the content-addressed store, hash-verified

138
139
140def pad_aes_gcm(json):
141 # AES-GCM encryption leaks length of plaintext, so we pad the object prior to encryption.
142 result = json
143 json_bytes = json.encode('UTF-8') if isinstance(json, str) else json
144 if isinstance(json_bytes, bytes):
145 bytes_len = len(json_bytes)
146 padded_len = max(384, bytes_len)
147 # padded_len = math.ceil(padded_len / 16) * 16
148 if padded_len % 16: padded_len = padded_len + 16 - (padded_len % 16)
149
150 if padded_len != bytes_len:
151 pad_len = abs(padded_len - bytes_len)
152 pad = ' ' * pad_len # fill with spaces (byte value 0x20)
153 result = result + pad if isinstance(result, str) else b''.join([result, pad.encode('UTF-8')])
154
155 return result
156
157
158def decrypt_rsa_key(encrypted_private_key, data_key):

Callers 4

prepare_record_v3Function · 0.85
add_record_v3Function · 0.85
create_record_data_v3Function · 0.85
update_record_v3Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected