diff options
author | Andres Morales <anmorales@google.com> | 2015-03-30 16:47:47 -0700 |
---|---|---|
committer | Andres Morales <anmorales@google.com> | 2015-03-30 17:05:46 -0700 |
commit | 11ed52a7139a6c867850113aa19293c05581fcfc (patch) | |
tree | 8557caaf71ce92c5bdb2ff541463add769d3f450 /include | |
parent | 4a29dcb5222110a2ea09cb8b52167c91cf3ab3c5 (diff) | |
download | gatekeeper-11ed52a7139a6c867850113aa19293c05581fcfc.tar.gz |
Use uint32_t instead of size_t
Must be compatible with code running
on arbitrary architectures.
Change-Id: I7223f02792929422f21c52024efe073940248fca
Diffstat (limited to 'include')
-rw-r--r-- | include/gatekeeper/gatekeeper.h | 22 | ||||
-rw-r--r-- | include/gatekeeper/gatekeeper_messages.h | 20 | ||||
-rw-r--r-- | include/gatekeeper/soft_gatekeeper.h | 24 |
3 files changed, 33 insertions, 33 deletions
diff --git a/include/gatekeeper/gatekeeper.h b/include/gatekeeper/gatekeeper.h index f68a4f4..8effc15 100644 --- a/include/gatekeeper/gatekeeper.h +++ b/include/gatekeeper/gatekeeper.h @@ -91,7 +91,7 @@ protected: * Ownership of the auth_token_key pointer is maintained by the implementor. * */ - virtual void GetAuthTokenKey(const uint8_t **auth_token_key, size_t *length) + virtual void GetAuthTokenKey(const uint8_t **auth_token_key, uint32_t *length) const = 0; /** * The key used to sign and verify password data. @@ -104,7 +104,7 @@ protected: * Ownership of the password_key pointer is maintained by the implementor. * */ - virtual void GetPasswordKey(const uint8_t **password_key, size_t *length) = 0; + virtual void GetPasswordKey(const uint8_t **password_key, uint32_t *length) = 0; /** * Uses platform-specific routines to compute a signature on the provided password. @@ -115,9 +115,9 @@ protected: * * Writes the signature_length size signature to the 'signature' pointer. */ - virtual void ComputePasswordSignature(uint8_t *signature, size_t signature_length, - const uint8_t *key, size_t key_length, const uint8_t *password, - size_t password_length, salt_t salt) const = 0; + virtual void ComputePasswordSignature(uint8_t *signature, uint32_t signature_length, + const uint8_t *key, uint32_t key_length, const uint8_t *password, + uint32_t password_length, salt_t salt) const = 0; /** * Retrieves a unique, cryptographically randomly generated buffer for use in password @@ -125,16 +125,16 @@ protected: * * Assings the random to the random UniquePtr, relinquishing ownership to the caller */ - virtual void GetRandom(void *random, size_t requested_size) const = 0; + virtual void GetRandom(void *random, uint32_t requested_size) const = 0; /** * Uses platform-specific routines to compute a signature on the provided message. * * Writes the signature_length size signature to the 'signature' pointer. */ - virtual void ComputeSignature(uint8_t *signature, size_t signature_length, - const uint8_t *key, size_t key_length, const uint8_t *message, - const size_t length) const = 0; + virtual void ComputeSignature(uint8_t *signature, uint32_t signature_length, + const uint8_t *key, uint32_t key_length, const uint8_t *message, + const uint32_t length) const = 0; /** * Write the password file to persistent storage. @@ -160,7 +160,7 @@ private: * The format is consistent with that of AuthToken above. * Also returns the length in length if it is not null. */ - void MintAuthToken(UniquePtr<uint8_t> *auth_token, size_t *length, uint32_t timestamp, + void MintAuthToken(UniquePtr<uint8_t> *auth_token, uint32_t *length, uint32_t timestamp, secure_id_t user_id, secure_id_t authenticator_id); /** @@ -179,7 +179,7 @@ private: */ bool CreatePasswordHandle(SizedBuffer *password_handle, salt_t salt, secure_id_t secure_id, secure_id_t authenticator_id, const uint8_t *password, - size_t password_length); + uint32_t password_length); }; } diff --git a/include/gatekeeper/gatekeeper_messages.h b/include/gatekeeper/gatekeeper_messages.h index 8b4abba..a98e1c5 100644 --- a/include/gatekeeper/gatekeeper_messages.h +++ b/include/gatekeeper/gatekeeper_messages.h @@ -43,7 +43,7 @@ struct SizedBuffer { * Constructs a SizedBuffer of a provided * length. */ - SizedBuffer(size_t length) { + SizedBuffer(uint32_t length) { if (length != 0) { buffer.reset(new uint8_t[length]); } else { @@ -57,13 +57,13 @@ struct SizedBuffer { * Takes ownership of the buf pointer, and deallocates it * when destructed. */ - SizedBuffer(uint8_t *buf, size_t len) { + SizedBuffer(uint8_t *buf, uint32_t len) { buffer.reset(buf); length = len; } UniquePtr<uint8_t> buffer; - size_t length; + uint32_t length; }; /* @@ -80,7 +80,7 @@ struct GateKeeperMessage { * Returns serialized size in bytes of the current state of the * object. */ - size_t GetSerializedSize() const; + uint32_t GetSerializedSize() const; /** * Converts the object into its serialized representation. * @@ -88,7 +88,7 @@ struct GateKeeperMessage { * * Returns the number of bytes written or 0 on error. */ - size_t Serialize(uint8_t *payload, const uint8_t *end) const; + uint32_t Serialize(uint8_t *payload, const uint8_t *end) const; /** * Inflates the object from its serial representation. @@ -105,7 +105,7 @@ struct GateKeeperMessage { * Returns the size of serializing only the elements specific to the * current sublclass. */ - virtual size_t nonErrorSerializedSize() const { return 0; } ; + virtual uint32_t nonErrorSerializedSize() const { return 0; } ; /** * Takes a pointer to a buffer prepared by Serialize and writes * the subclass specific data into it. The size of the buffer must be exactly @@ -132,7 +132,7 @@ struct VerifyRequest : public GateKeeperMessage { VerifyRequest(); ~VerifyRequest(); - virtual size_t nonErrorSerializedSize() const; + virtual uint32_t nonErrorSerializedSize() const; virtual void nonErrorSerialize(uint8_t *buffer) const; virtual gatekeeper_error_t nonErrorDeserialize(const uint8_t *payload, const uint8_t *end); @@ -147,7 +147,7 @@ struct VerifyResponse : public GateKeeperMessage { void SetVerificationToken(SizedBuffer *auth_token); - virtual size_t nonErrorSerializedSize() const; + virtual uint32_t nonErrorSerializedSize() const; virtual void nonErrorSerialize(uint8_t *buffer) const; virtual gatekeeper_error_t nonErrorDeserialize(const uint8_t *payload, const uint8_t *end); @@ -160,7 +160,7 @@ struct EnrollRequest : public GateKeeperMessage { EnrollRequest(); ~EnrollRequest(); - virtual size_t nonErrorSerializedSize() const; + virtual uint32_t nonErrorSerializedSize() const; virtual void nonErrorSerialize(uint8_t *buffer) const; virtual gatekeeper_error_t nonErrorDeserialize(const uint8_t *payload, const uint8_t *end); @@ -187,7 +187,7 @@ public: void SetEnrolledPasswordHandle(SizedBuffer *enrolled_password_handle); - virtual size_t nonErrorSerializedSize() const; + virtual uint32_t nonErrorSerializedSize() const; virtual void nonErrorSerialize(uint8_t *buffer) const; virtual gatekeeper_error_t nonErrorDeserialize(const uint8_t *payload, const uint8_t *end); diff --git a/include/gatekeeper/soft_gatekeeper.h b/include/gatekeeper/soft_gatekeeper.h index aca9b0d..2927cd7 100644 --- a/include/gatekeeper/soft_gatekeeper.h +++ b/include/gatekeeper/soft_gatekeeper.h @@ -35,13 +35,13 @@ namespace gatekeeper { class GateKeeperFileIo { public: virtual ~GateKeeperFileIo() {} - virtual void Write(const char *filename, const uint8_t *bytes, size_t length) = 0; - virtual size_t Read(const char *filename, UniquePtr<uint8_t> *bytes) const = 0; + virtual void Write(const char *filename, const uint8_t *bytes, uint32_t length) = 0; + virtual uint32_t Read(const char *filename, UniquePtr<uint8_t> *bytes) const = 0; }; class SoftGateKeeper : public GateKeeper { public: - static const size_t SIGNATURE_LENGTH_BYTES = 32; + static const uint32_t SIGNATURE_LENGTH_BYTES = 32; // scrypt params static const uint64_t N = 16384; @@ -61,33 +61,33 @@ public: } virtual void GetAuthTokenKey(const uint8_t **auth_token_key, - size_t *length) const { + uint32_t *length) const { if (auth_token_key == NULL || length == NULL) return; *auth_token_key = const_cast<const uint8_t *>(key_.get()); *length = SIGNATURE_LENGTH_BYTES; } - virtual void GetPasswordKey(const uint8_t **password_key, size_t *length) { + virtual void GetPasswordKey(const uint8_t **password_key, uint32_t *length) { if (password_key == NULL || length == NULL) return; *password_key = const_cast<const uint8_t *>(key_.get()); *length = SIGNATURE_LENGTH_BYTES; } - virtual void ComputePasswordSignature(uint8_t *signature, size_t signature_length, - const uint8_t *, size_t, const uint8_t *password, - size_t password_length, salt_t salt) const { + virtual void ComputePasswordSignature(uint8_t *signature, uint32_t signature_length, + const uint8_t *, uint32_t, const uint8_t *password, + uint32_t password_length, salt_t salt) const { if (signature == NULL) return; crypto_scrypt(password, password_length, reinterpret_cast<uint8_t *>(&salt), sizeof(salt), N, r, p, signature, signature_length); } - virtual void GetRandom(void *random, size_t requested_length) const { + virtual void GetRandom(void *random, uint32_t requested_length) const { if (random == NULL) return; RAND_pseudo_bytes((uint8_t *) random, requested_length); } - virtual void ComputeSignature(uint8_t *signature, size_t signature_length, - const uint8_t *, size_t, const uint8_t *, const size_t) const { + virtual void ComputeSignature(uint8_t *signature, uint32_t signature_length, + const uint8_t *, uint32_t, const uint8_t *, const uint32_t) const { if (signature == NULL) return; memset(signature, 0, signature_length); } @@ -96,7 +96,7 @@ public: char buf[MAX_UINT_32_CHARS]; sprintf(buf, "%u", uid); UniquePtr<uint8_t> password_buffer; - size_t length = file_io_->Read(buf, &password_buffer); + uint32_t length = file_io_->Read(buf, &password_buffer); password_file->buffer.reset(password_buffer.release()); password_file->length = length; } |