blob: 0b0cf19a1d1ed54000410eb0e4faca4e22c8201e [file] [log] [blame]
James E. Blair01f83b72017-03-15 13:03:40 -07001#!/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
15import sys
16import os
17
James E. Blairbf1a4f22017-03-17 10:59:37 -070018from zuul.lib import encryption
James E. Blair01f83b72017-03-15 13:03:40 -070019
20FIXTURE_DIR = os.path.join(os.path.dirname(__file__),
21 'fixtures')
22
23
24def main():
25 private_key_file = os.path.join(FIXTURE_DIR, 'private.pem')
26 with open(private_key_file, "rb") as f:
James E. Blairbf1a4f22017-03-17 10:59:37 -070027 private_key, public_key = \
28 encryption.deserialize_rsa_keypair(f.read())
James E. Blair01f83b72017-03-15 13:03:40 -070029
James E. Blair717e8e92017-03-17 11:03:27 -070030 ciphertext = encryption.encrypt_pkcs1_oaep(sys.argv[1], public_key)
James E. Blair01f83b72017-03-15 13:03:40 -070031 print(ciphertext.encode('base64'))
32
David Shrewsbury699a6b22017-05-19 09:38:36 -040033
James E. Blair01f83b72017-03-15 13:03:40 -070034if __name__ == '__main__':
35 main()