Skip to content

Commit

Permalink
Add remaining functions for looking up constants
Browse files Browse the repository at this point in the history
The automated script that generated functions for looking up #define'd
constants didn't handle edge cases in these files, so these have been
added by hand. They're thus either more likely or less likely to
contain mistakes (depending on one's particular point of view).
  • Loading branch information
stouset committed May 16, 2013
1 parent 2a0f3d0 commit 98c02a2
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/libsodium/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ libsodium_la_SOURCES = \
crypto_core/salsa208/core_salsa208_api.c \
crypto_core/salsa208/ref/api.h \
crypto_generichash/crypto_generichash.c \
crypto_generichash/blake2/generichash_blake2_api.c \
crypto_generichash/blake2/ref/api.h \
crypto_generichash/blake2/ref/blake2-impl.h \
crypto_generichash/blake2/ref/blake2.h \
Expand All @@ -51,6 +52,7 @@ libsodium_la_SOURCES = \
crypto_hashblocks/sha512/ref/api.h \
crypto_onetimeauth/crypto_onetimeauth.c \
crypto_onetimeauth/poly1305/onetimeauth_poly1305.c \
crypto_onetimeauth/poly1305/onetimeauth_poly1305_api.c \
crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c \
crypto_onetimeauth/poly1305/53/api.h \
crypto_onetimeauth/poly1305/53/auth_poly1305_53.c \
Expand Down Expand Up @@ -165,8 +167,10 @@ libsodium_la_SOURCES = \
crypto_stream/xsalsa20/ref/api.h \
crypto_stream/xsalsa20/ref/stream_xsalsa20.c \
crypto_stream/xsalsa20/ref/xor_xsalsa20.c \
crypto_verify/16/verify_16_api.c \
crypto_verify/16/ref/api.h \
crypto_verify/16/ref/verify_16.c \
crypto_verify/32/verify_32_api.c \
crypto_verify/32/ref/api.h \
crypto_verify/32/ref/verify_32.c \
randombytes/randombytes.c \
Expand Down
31 changes: 31 additions & 0 deletions src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "crypto_generichash_blake2b.h"

size_t
crypto_generichash_blake2b_bytes_min(void) {
return crypto_generichash_blake2b_BYTES_MIN;
}

size_t
crypto_generichash_blake2b_bytes_max(void) {
return crypto_generichash_blake2b_BYTES_MAX;
}

size_t
crypto_generichash_blake2b_keybytes_min(void) {
return crypto_generichash_blake2b_KEYBYTES_MIN;
}

size_t
crypto_generichash_blake2b_keybytes_max(void) {
return crypto_generichash_blake2b_KEYBYTES_MAX;
}

size_t
crypto_generichash_blake2b_blockbytes(void) {
return crypto_generichash_blake2b_BLOCKBYTES;
}

const char *
crypto_generichash_blake2b_blockbytes_primitive(void) {
return "blake2b";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "crypto_onetimeauth_poly1305.h"

size_t
crypto_onetimeauth_poly1305_bytes(void) {
return crypto_onetimeauth_poly1305_BYTES;
}

size_t
crypto_onetimeauth_poly1305_keybytes(void) {
return crypto_onetimeauth_poly1305_KEYBYTES;
}

const char *
crypto_onetimeauth_poly1305_primitive(void) {
return "poly1305";
}
6 changes: 6 additions & 0 deletions src/libsodium/crypto_verify/16/verify_16_api.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "crypto_verify_16.h"

size_t
crypto_verify_16_bytes(void) {
return crypto_verify_16_BYTES;
}
6 changes: 6 additions & 0 deletions src/libsodium/crypto_verify/32/verify_32_api.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "crypto_verify_32.h"

size_t
crypto_verify_32_bytes(void) {
return crypto_verify_32_BYTES;
}
19 changes: 19 additions & 0 deletions src/libsodium/include/sodium/crypto_generichash_blake2b.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <stdint.h>
#include <stdlib.h>
#include <stddef.h>

#include "export.h"

Expand Down Expand Up @@ -33,6 +34,24 @@ CRYPTO_ALIGN(64) typedef struct crypto_generichash_blake2b_state {
} crypto_generichash_blake2b_state;
#pragma pack(pop)

SODIUM_EXPORT
size_t crypto_generichash_blake2b_bytes_min(void);

SODIUM_EXPORT
size_t crypto_generichash_blake2b_bytes_max(void);

SODIUM_EXPORT
size_t crypto_generichash_blake2b_keybytes_min(void);

SODIUM_EXPORT
size_t crypto_generichash_blake2b_keybytes_max(void);

SODIUM_EXPORT
size_t crypto_generichash_blake2b_blockbytes(void);

SODIUM_EXPORT
const char * crypto_generichash_blake2b_blockbytes_primitive(void);

SODIUM_EXPORT
int crypto_generichash_blake2b(unsigned char *out, size_t outlen,
const unsigned char *in,
Expand Down
10 changes: 10 additions & 0 deletions src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef crypto_onetimeauth_poly1305_H
#define crypto_onetimeauth_poly1305_H

#include <stddef.h>
#include "export.h"

#define crypto_onetimeauth_poly1305_BYTES 16U
Expand All @@ -26,6 +27,15 @@ typedef struct crypto_onetimeauth_poly1305_implementation {
const unsigned char *k);
} crypto_onetimeauth_poly1305_implementation;

SODIUM_EXPORT
size_t crypto_onetimeauth_poly1305_bytes(void);

SODIUM_EXPORT
size_t crypto_onetimeauth_poly1305_keybytes(void);

SODIUM_EXPORT
const char * crypto_onetimeauth_poly1305_primitive(void);

SODIUM_EXPORT
const char *crypto_onetimeauth_poly1305_ref_implementation_name(void);

Expand Down
4 changes: 4 additions & 0 deletions src/libsodium/include/sodium/crypto_verify_16.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef crypto_verify_16_H
#define crypto_verify_16_H

#include <stddef.h>
#include "export.h"

#define crypto_verify_16_BYTES 16U
Expand All @@ -9,6 +10,9 @@
extern "C" {
#endif

SODIUM_EXPORT
size_t crypto_verify_16_bytes(void);

SODIUM_EXPORT
int crypto_verify_16(const unsigned char *x, const unsigned char *y);

Expand Down
4 changes: 4 additions & 0 deletions src/libsodium/include/sodium/crypto_verify_32.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef crypto_verify_32_H
#define crypto_verify_32_H

#include <stddef.h>
#include "export.h"

#define crypto_verify_32_BYTES 32U
Expand All @@ -9,6 +10,9 @@
extern "C" {
#endif

SODIUM_EXPORT
size_t crypto_verify_32_bytes(void);

SODIUM_EXPORT
int crypto_verify_32(const unsigned char *x, const unsigned char *y);

Expand Down

0 comments on commit 98c02a2

Please sign in to comment.