Example #1
0
    def test_generate(self):
        """ Test generating a key pair.
        """
        crypto = brkt_cli.crypto.new()
        self.assertTrue(
            isinstance(crypto.private_key, ec._EllipticCurvePrivateKey))
        self.assertTrue(
            isinstance(crypto.public_key, ec._EllipticCurvePublicKey))
        self.assertTrue('BEGIN PUBLIC KEY' in crypto.public_key_pem)

        pem = crypto.get_private_key_pem()
        self.assertTrue('BEGIN EC PRIVATE KEY' in pem)
        pem = crypto.get_private_key_pem('test123')
        self.assertTrue('Proc-Type: 4,ENCRYPTED' in pem)
Example #2
0
    def run(self, values):
        passphrase = None
        if values.passphrase:
            passphrase = getpass.getpass('Passphrase: ')
            reentered = getpass.getpass('Reenter passphrase: ')
            if passphrase != reentered:
                raise ValidationError('Passphrases do not match')

        crypto = brkt_cli.crypto.new()
        print crypto.get_private_key_pem(passphrase)
        if values.public_out:
            _write_file(values.public_out, crypto.public_key_pem)

        return 0
Example #3
0
    def test_generate(self):
        """ Test generating a key pair.
        """
        crypto = brkt_cli.crypto.new()
        self.assertTrue(
            isinstance(crypto.private_key, ec._EllipticCurvePrivateKey))
        self.assertTrue(
            isinstance(crypto.public_key, ec._EllipticCurvePublicKey))
        self.assertTrue('BEGIN PUBLIC KEY' in crypto.public_key_pem)

        pem = crypto.get_private_key_pem()
        self.assertTrue('BEGIN EC PRIVATE KEY' in pem)
        pem = crypto.get_private_key_pem('test123')
        self.assertTrue('Proc-Type: 4,ENCRYPTED' in pem)
Example #4
0
    def run(self, values):
        passphrase = None
        if values.passphrase:
            passphrase = getpass.getpass('Passphrase: ')
            reentered = getpass.getpass('Reenter passphrase: ')
            if passphrase != reentered:
                raise ValidationError('Passphrases do not match')

        crypto = brkt_cli.crypto.new()
        print crypto.get_private_key_pem(passphrase)
        if values.public_out:
            _write_file(values.public_out, crypto.public_key_pem)

        return 0