|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
from Crypto.Cipher import AES
|
|
|
|
|
from Crypto.Util.Padding import pad, unpad
|
|
|
|
|
from authorizedkeys.parser import parse_file, dump_file, AuthorizedKey
|
|
|
|
|
import sys
|
|
|
|
|
from base64 import b64decode, b64encode
|
|
|
|
@ -23,7 +24,7 @@ keys = parse_file(input)
|
|
|
|
|
for k in keys:
|
|
|
|
|
if isinstance(k, AuthorizedKey):
|
|
|
|
|
if encrypt:
|
|
|
|
|
k.comment = b64encode(cipher.encrypt(k.comment.encode())).decode()
|
|
|
|
|
k.comment = b64encode(cipher.encrypt(pad(k.comment.encode(), cipher.block_size))).decode()
|
|
|
|
|
else: # And now this is just wow.
|
|
|
|
|
k.comment = cipher.decrypt(b64decode(k.comment)).decode()
|
|
|
|
|
k.comment = unpad(cipher.decrypt(b64decode(k.comment)), cipher.block_size).decode()
|
|
|
|
|
dump_file(keys, output)
|
|
|
|
|