Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add token and pin initialization #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maxwolfe
Copy link

@maxwolfe maxwolfe commented Feb 6, 2021

Adding implementations and tests for C_InitToken and C_InitPIN

Happens to also solve: #6

@maxwolfe
Copy link
Author

maxwolfe commented Feb 7, 2021

I wrote this casually for personal use and am not super familiar with extending Python with C, so please don't hesitate to comment if there are better ways to do certain things.

Added as Token.init_token and Session.init_pin
@maxwolfe maxwolfe marked this pull request as ready for review February 7, 2021 03:36
@maxwolfe maxwolfe changed the title Feature/initialize tokens Add token and pin initialization Feb 7, 2021
Copy link
Collaborator

@danni danni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. Apologies for the delay. Not sure why I never got notified for this.

assertRV(_funclist.C_InitToken(slot_id, pin_data, pin_length,
label))

return True
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than returning True/False out of this function, it's probably better to return None or raise ArgumentsBad. That means you can try/except/finally your codepath.

tlabel = token_label.encode('utf-8')

if pin and tlabel:
pin_data = pin
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to reassign these?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I suppose you do for nogil, NM

pin = user_pin.encode('utf-8')

if pin:
pin_data = pin
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to reassign this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants