James E. Blair | 01f83b7 | 2017-03-15 13:03:40 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | import sys |
| 16 | import os |
| 17 | |
James E. Blair | bf1a4f2 | 2017-03-17 10:59:37 -0700 | [diff] [blame] | 18 | from zuul.lib import encryption |
James E. Blair | 01f83b7 | 2017-03-15 13:03:40 -0700 | [diff] [blame] | 19 | |
| 20 | FIXTURE_DIR = os.path.join(os.path.dirname(__file__), |
| 21 | 'fixtures') |
| 22 | |
| 23 | |
| 24 | def main(): |
| 25 | private_key_file = os.path.join(FIXTURE_DIR, 'private.pem') |
| 26 | with open(private_key_file, "rb") as f: |
James E. Blair | bf1a4f2 | 2017-03-17 10:59:37 -0700 | [diff] [blame] | 27 | private_key, public_key = \ |
| 28 | encryption.deserialize_rsa_keypair(f.read()) |
James E. Blair | 01f83b7 | 2017-03-15 13:03:40 -0700 | [diff] [blame] | 29 | |
James E. Blair | 717e8e9 | 2017-03-17 11:03:27 -0700 | [diff] [blame] | 30 | ciphertext = encryption.encrypt_pkcs1_oaep(sys.argv[1], public_key) |
James E. Blair | 01f83b7 | 2017-03-15 13:03:40 -0700 | [diff] [blame] | 31 | print(ciphertext.encode('base64')) |
| 32 | |
David Shrewsbury | 699a6b2 | 2017-05-19 09:38:36 -0400 | [diff] [blame] | 33 | |
James E. Blair | 01f83b7 | 2017-03-15 13:03:40 -0700 | [diff] [blame] | 34 | if __name__ == '__main__': |
| 35 | main() |