|
MCCI TweetNaCl
TweetNaCl library adapted for embedded use
|
Collaboration diagram for Signatures:Data Structures | |
| struct | mcci_tweetnacl_sign_privatekey_t |
| Private Key for TweetNaCl sign operations. More... | |
| struct | mcci_tweetnacl_sign_publickey_t |
| Public Key for TweetNaCl sign operations. More... | |
| struct | mcci_tweetnacl_sign_signature_t |
| Signature block for TweetNaCl sign operations. More... | |
Macros | |
| #define | mcci_tweetnacl_sign_signature_size() sizeof(((mcci_tweetnacl_sign_signature_t *)NULL)->bytes) |
| Return size of signature, in bytes. More... | |
Functions | |
| mcci_tweetnacl_result_t | mcci_tweetnacl_sign (unsigned char *pSignedMessage, size_t *pSignedMessageSize, const unsigned char *pMessage, size_t messageSize, const mcci_tweetnacl_sign_privatekey_t *pPrivateKey) |
| sign a message (typically a hash of the real message) More... | |
| mcci_tweetnacl_randombytes_error_t | mcci_tweetnacl_sign_keypair (mcci_tweetnacl_sign_publickey_t *pPublicKey, mcci_tweetnacl_sign_privatekey_t *pPrivateKey) |
| generate a private key and a corresponding public key More... | |
| static mcci_tweetnacl_result_t | mcci_tweetnacl_sign_open (unsigned char *pMessage, size_t *pMessageSize, const unsigned char *pSignedMessage, size_t messageSize, const mcci_tweetnacl_sign_publickey_t *pPublicKey) |
| given a signed message, verify and output signed contents More... | |
| #define mcci_tweetnacl_sign_signature_size | ( | ) | sizeof(((mcci_tweetnacl_sign_signature_t *)NULL)->bytes) |
Return size of signature, in bytes.
Definition at line 103 of file mcci_tweetnacl_sign.h.
| mcci_tweetnacl_result_t mcci_tweetnacl_sign | ( | unsigned char * | pSignedMessage, |
| size_t * | pSignedMessageSize, | ||
| const unsigned char * | pMessage, | ||
| size_t | messageSize, | ||
| const mcci_tweetnacl_sign_privatekey_t * | pPrivateKey | ||
| ) |
sign a message (typically a hash of the real message)
| [out] | pSignedMessage | points to buffer to received signed message. |
| [out] | pSignedMessageSize | points to cell to receive size of signed message. |
| [in] | pMessage | input message |
| [in] | messageSize | size of input message, in bytes |
| [in] | pPrivateKey | private key to be used to sign message. |
*pSignedMessageSize is set to the size. Otherwise non-zero, in which case *pSignedMessageSize is zero.This is a wrapper for TweetNaCl's crypto_sign(), enforcing a few adjustments. Size is a size_t rather than unsigned long long; if the input size is so large that it would wrap around, we refuse to sign, and return a failure. Because crypto_sign() productes an unsigned long long by reference, we have to stage the result and narrow it when copying back to the client. We are careful to avoid overflow, although overflow arguably is impossible.
pSignedMessage must be at least messageSize + mcci_tweetnacl_sign_signature_size() bytes long. | mcci_tweetnacl_randombytes_error_t mcci_tweetnacl_sign_keypair | ( | mcci_tweetnacl_sign_publickey_t * | pPublicKey, |
| mcci_tweetnacl_sign_privatekey_t * | pPrivateKey | ||
| ) |
generate a private key and a corresponding public key
| [out] | pPublicKey | is set to the generated public key. |
| [in] | pPrivateKey | is set to the generated private key. |
randombytes() be implemented and successful. Further, it requires a cryptographically secure string of bytes when randombytes() succeeds.
|
inlinestatic |
given a signed message, verify and output signed contents
| [out] | pMessage | points to buffer to received verified message. |
| [out] | pMessageSize | points to cell to receive size of verified message. |
| [in] | pSignedMessage | input signed (opaque) message |
| [in] | messageSize | size of signed message, in bytes |
| [in] | pPublicKey | public key to be used to verify message. |
pMessage[] is set to the validated contents, and *pMessageSize is set to the size. Otherwise non-zero, in which case pMessage[] may be changed but should be ignored.This is a wrapper for TweetNaCl's crypto_sign_open(), enforcing a few adjustments. Size is a size_t rather than unsigned long long. Because crypto_sign_out() productes an unsigned long long by reference, we have to stage the result and narrow it when copying back to the client.
pMessage must be at least messageSize - 64 bytes long. Definition at line 162 of file mcci_tweetnacl_sign.h.
References mcci_tweetnacl_sign_publickey_t::bytes.