Browse Source

Make encrypt_secret.py work with OpenSSL 0.x

The format was changed in 1.0. This enables Mac OS's default openssl CLI
tool to work with encrypt_secret.py

Change-Id: Ib5d7a0c5cc6a729bed6fa4a64193444bb48022fb
changes/33/517133/2
Clint Byrum 4 years ago
parent
commit
2dc31dd567
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      tools/encrypt_secret.py

+ 6
- 1
tools/encrypt_secret.py View File

@ -86,7 +86,12 @@ def main():
if p.returncode != 0:
raise Exception("Return code %s from openssl" % p.returncode)
output = stdout.decode('utf-8')
m = re.match(r'^Public-Key: \((\d+) bit\)$', output, re.MULTILINE)
openssl_version = subprocess.check_output(
['openssl', 'version']).split()[1]
if openssl_version.startswith(b'0.'):
m = re.match(r'^Modulus \((\d+) bit\):$', output, re.MULTILINE)
else:
m = re.match(r'^Public-Key: \((\d+) bit\)$', output, re.MULTILINE)
nbits = int(m.group(1))
nbytes = int(nbits / 8)
max_bytes = nbytes - 42 # PKCS1-OAEP overhead


Loading…
Cancel
Save