Beispiel #1
0
def command_keyfile_new(options):
    ''' Create new certificate '''

    base_path = options.path
    if not base_path:
        print('No directory to store they key files in was specified.')
        sys.exit(1)

    metadata = {}
    metadata['id'] = options.id
    metadata['name'] = options.name
    metadata['email'] = options.email
    if options.organization:
        metadata['organization'] = options.organization
    metadata['created-by'] = 'Laniakea Keytool'
    metadata['date-created'] = str(datetime.datetime.now())

    secret_fname = os.path.join(base_path, '{}.key_secret'.format(options.id))
    public_fname = os.path.join(base_path, '{}.key'.format(options.id))

    # create Curve25519 keys for ZCurve
    if options.sign_only:
        curve_public_key = None
        curve_secret_key = None
    else:
        curve_public_key, curve_secret_key = zmq.curve_keypair()

    # create Ed25519 for our message signing
    ed_key = generate_signing_key(0)
    ed_verify_key = get_verify_key(ed_key)
    ed_secret_key = encode_signing_key_base64(ed_key)
    ed_public_key = encode_verify_key_base64(ed_verify_key)

    # write secret keyfile
    _write_key_file(secret_fname, metadata, curve_public_key, curve_secret_key,
                    ed_public_key, ed_secret_key)

    # write public keyfile
    _write_key_file(public_fname, metadata, curve_public_key, None,
                    ed_public_key, None)
Beispiel #2
0
 def setup_method(self, test_method):
     self.version = "my_version"
     self.key = generate_signing_key(self.version)
     self.key_base64 = encode_signing_key_base64(self.key)
     self.verify_key = get_verify_key(self.key)
     self.verify_key_base64 = encode_verify_key_base64(self.verify_key)
Beispiel #3
0
 def test_generate_key(self):
     my_version = "my_version"
     my_key = generate_signing_key(my_version)
     assert my_key.alg == "ed25519"
     assert my_key.version == my_version