Skip to content

Commit

Permalink
Merge pull request #209 from olcf/208-add-yubico-piv-tool-backend-for…
Browse files Browse the repository at this point in the history
…-crypto-operations

Add beta yubico piv tool backend for crypto operations
  • Loading branch information
carljbai authored Aug 14, 2023
2 parents d0a5086 + 3a7ed06 commit 4bf2679
Show file tree
Hide file tree
Showing 13 changed files with 264 additions and 95 deletions.
16 changes: 16 additions & 0 deletions libpkpass/commands/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,20 @@
"help": "verbose output (repeat for increased verbosity)",
},
},
"SCBackend": {
"args": ["--scbackend"],
"kwargs": {
"type": str,
"default": "opensc",
"help": "SC backend to use: opensc or yubi",
},
},
"PKCS11_module_path": {
"args": ["--PKCS11-module-path"],
"kwargs": {
"type": str,
"default": "/usr/local/lib/libykcs11.dylib",
"help": "Path to yubi PKCS11 module",
},
},
}
1 change: 1 addition & 0 deletions libpkpass/commands/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def _run_command_execution(self):
2,
self.args["color"],
self.args["theme_map"],
self.args["SCBackend"],
)

def _validate_args(self):
Expand Down
2 changes: 2 additions & 0 deletions libpkpass/commands/clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def _run_command_execution(self):
identity=self.iddb.id,
passphrase=self.passphrase,
card_slot=self.args["card_slot"],
SCBackend=self.args["SCBackend"],
PKCS11_module_path=self.args["PKCS11_module_path"],
)
if not self.args["noverify"]:
result = password.verify_entry(
Expand Down
5 changes: 5 additions & 0 deletions libpkpass/commands/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def _passphrase_check(self):
self.args["verbosity"],
self.args["color"],
self.args["theme_map"],
self.args["SCBackend"],
):
LOGGER.info(mesg)
self.passphrase = getpass.getpass("Enter Pin/Passphrase: ")
Expand Down Expand Up @@ -161,6 +162,8 @@ def update_pass(self, pass_value):
card_slot=self.args["card_slot"],
escrow_users=self.args["escrow_users"],
minimum=self.args["min_escrow"],
SCBackend=self.args["SCBackend"],
PKCS11_module_path=self.args["PKCS11_module_path"],
)
pass_entry["recipients"][self.args["identity"]] = swap_pass["recipients"][
self.args["identity"]
Expand Down Expand Up @@ -196,6 +199,8 @@ def create_pass(self, password1, description, authorizer, recipient_list=None):
card_slot=self.args["card_slot"],
escrow_users=self.args["escrow_users"],
minimum=self.args["min_escrow"],
SCBackend=self.args["SCBackend"],
PKCS11_module_path=self.args["PKCS11_module_path"],
)

password.write_password_data(
Expand Down
4 changes: 4 additions & 0 deletions libpkpass/commands/distribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def _run_command_execution(self):
self.iddb.id,
passphrase=self.passphrase,
card_slot=self.args["card_slot"],
SCBackend=self.args["SCBackend"],
PKCS11_module_path=self.args["PKCS11_module_path"],
)
password.add_recipients(
secret=plaintext_pw,
Expand All @@ -60,6 +62,8 @@ def _run_command_execution(self):
card_slot=self.args["card_slot"],
escrow_users=self.args["escrow_users"],
minimum=self.args["min_escrow"],
SCBackend=self.args["SCBackend"],
PKCS11_module_path=self.args["PKCS11_module_path"],
)

password.write_password_data(dist_pass)
Expand Down
2 changes: 2 additions & 0 deletions libpkpass/commands/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def _iterate_pdb(self, passworddb, crypt_pass=False):
identity=self.iddb.id,
passphrase=self.passphrase,
card_slot=self.args["card_slot"],
SCBackend=self.args["SCBackend"],
PKCS11_module_path=self.args["PKCS11_module_path"],
)
password.recipients[uid]["encrypted_secret"] = plaintext_pw.encode("UTF-8")
password.write_password_data(
Expand Down
2 changes: 2 additions & 0 deletions libpkpass/commands/populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def _decrypt_password_entry(self, password):
identity=self.iddb.id,
passphrase=self.passphrase,
card_slot=self.args["card_slot"],
SCBackend=self.args["SCBackend"],
PKCS11_module_path=self.args["PKCS11_module_path"],
)
distributor = password.recipients[self.iddb.id["name"]]["distributor"]
if not self.args["noverify"]:
Expand Down
2 changes: 2 additions & 0 deletions libpkpass/commands/rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def _run_command_execution(self):
identity=self.iddb.id,
passphrase=self.passphrase,
card_slot=self.args["card_slot"],
SCBackend=self.args["SCBackend"],
PKCS11_module_path=self.args["PKCS11_module_path"],
)
self._confirmation(plaintext_pw)
else:
Expand Down
4 changes: 4 additions & 0 deletions libpkpass/commands/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def _behalf_prep(self, password):
identity=self.iddb.id,
passphrase=self.passphrase,
card_slot=self.args["card_slot"],
SCBackend=self.args["SCBackend"],
PKCS11_module_path=self.args["PKCS11_module_path"],
)
with open(temp_key, "w", encoding="ASCII") as fname:
fname.write(
Expand Down Expand Up @@ -154,6 +156,8 @@ def _decrypt_password_entry(self, password, distributor):
identity=self.iddb.id,
passphrase=self.passphrase,
card_slot=self.args["card_slot"],
SCBackend=self.args["SCBackend"],
PKCS11_module_path=self.args["PKCS11_module_path"],
)
dist_obj = (
self.iddb.session.query(Recipient)
Expand Down
Loading

0 comments on commit 4bf2679

Please sign in to comment.