Skip to content

Implement atcab_write_pubkey and atcab_priv_write commands #7

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

Open
brentru opened this issue Oct 30, 2019 · 6 comments
Open

Implement atcab_write_pubkey and atcab_priv_write commands #7

brentru opened this issue Oct 30, 2019 · 6 comments
Labels
enhancement New feature or request

Comments

@brentru
Copy link
Member

brentru commented Oct 30, 2019

atcab_write_pubkey: Uses the write command to write a public key to a slot in the proper format.

atcab_priv_write: Executes PrivWrite command, to write externally generated ECC private keys into the device.

uCryptoAuthLib Implementation for pubkey (priv_write is not implemented): https://github.com/dmazzella/ucryptoauthlib/blob/master/cryptoauthlib/basic.py#L852

Discussion about these commands: MicrochipTech/cryptoauthlib#44

@brentru brentru added the enhancement New feature or request label Oct 30, 2019
@tannewt
Copy link
Member

tannewt commented Mar 5, 2020

I'd suggest splitting this library into more modules so folks can import just the bits they need to use.

@brentru
Copy link
Member Author

brentru commented Mar 5, 2020

@tannewt I have some of this library split, but would like some advice on what to split out further. Here's my start:

@tannewt
Copy link
Member

tannewt commented Mar 6, 2020

I like the idea of having modules for random and hashlib! What functions are left in the regular atecc module?

@brentru
Copy link
Member Author

brentru commented Mar 6, 2020

Random would contain the following from the atecc module:

  • nonce
  • random

hashlib would contain:

  • sha_start,sha_digest, and sha_update

Which leave us with a few public, non-driver-specific methods like: ecdsa_sign, sign, write_config, gen_key.

These could be moved to a class within atecc_cert_util since they're related to certificate generation and STORAGE. I feel adafruit_atecc_asn1 could be its own class, contained within cert_util as well.

@tannewt
Copy link
Member

tannewt commented Mar 9, 2020

I like the hashlib idea and please ensure the API matches CPython's hashlib.

Looks like this would work to mimic for ECDSA: https://github.com/warner/python-ecdsa

Can you find similar analogs for sign and gen_key?

@brentru
Copy link
Member Author

brentru commented Mar 10, 2020

That lib is promising. I'd need to adapt sign and gen_key to work properly with .generate and .sign.

sk = SigningKey.generate(curve=NIST384p)
vk = sk.verifying_key
signature = sk.sign(b"message")```

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

No branches or pull requests

2 participants