Mark local functions as static
This helps to catch unused functions like the former mosh_read_line, allows the compiler to make better inlining decisions, and reduces the binary size a bit. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
committed by
John Hood
parent
a52b095f50
commit
cd2ae36f36
+16
-16
@@ -55,26 +55,26 @@ using Crypto::AlignedBuffer;
|
||||
|
||||
bool verbose = false;
|
||||
|
||||
bool equal( const AlignedBuffer &a, const AlignedBuffer &b ) {
|
||||
static bool equal( const AlignedBuffer &a, const AlignedBuffer &b ) {
|
||||
return ( a.len() == b.len() )
|
||||
&& !memcmp( a.data(), b.data(), a.len() );
|
||||
}
|
||||
|
||||
AlignedBuffer *get_ctx( const AlignedBuffer &key ) {
|
||||
static AlignedBuffer *get_ctx( const AlignedBuffer &key ) {
|
||||
AlignedBuffer *ctx_buf = new AlignedBuffer( ae_ctx_sizeof() );
|
||||
fatal_assert( ctx_buf );
|
||||
fatal_assert( AE_SUCCESS == ae_init( (ae_ctx *)ctx_buf->data(), key.data(), key.len(), NONCE_LEN, TAG_LEN ) );
|
||||
return ctx_buf;
|
||||
}
|
||||
|
||||
void scrap_ctx( AlignedBuffer *ctx_buf ) {
|
||||
static void scrap_ctx( AlignedBuffer *ctx_buf ) {
|
||||
fatal_assert( AE_SUCCESS == ae_clear( (ae_ctx *)ctx_buf->data() ) );
|
||||
delete ctx_buf;
|
||||
}
|
||||
|
||||
void test_encrypt( const AlignedBuffer &key, const AlignedBuffer &nonce,
|
||||
const AlignedBuffer &plaintext, const AlignedBuffer &assoc,
|
||||
const AlignedBuffer &expected_ciphertext ) {
|
||||
static void test_encrypt( const AlignedBuffer &key, const AlignedBuffer &nonce,
|
||||
const AlignedBuffer &plaintext, const AlignedBuffer &assoc,
|
||||
const AlignedBuffer &expected_ciphertext ) {
|
||||
AlignedBuffer *ctx_buf = get_ctx( key );
|
||||
ae_ctx *ctx = (ae_ctx *)ctx_buf->data();
|
||||
|
||||
@@ -97,10 +97,10 @@ void test_encrypt( const AlignedBuffer &key, const AlignedBuffer &nonce,
|
||||
scrap_ctx( ctx_buf );
|
||||
}
|
||||
|
||||
void test_decrypt( const AlignedBuffer &key, const AlignedBuffer &nonce,
|
||||
const AlignedBuffer &ciphertext, const AlignedBuffer &assoc,
|
||||
const AlignedBuffer &expected_plaintext,
|
||||
bool valid ) {
|
||||
static void test_decrypt( const AlignedBuffer &key, const AlignedBuffer &nonce,
|
||||
const AlignedBuffer &ciphertext, const AlignedBuffer &assoc,
|
||||
const AlignedBuffer &expected_plaintext,
|
||||
bool valid ) {
|
||||
AlignedBuffer *ctx_buf = get_ctx( key );
|
||||
ae_ctx *ctx = (ae_ctx *)ctx_buf->data();
|
||||
|
||||
@@ -129,10 +129,10 @@ void test_decrypt( const AlignedBuffer &key, const AlignedBuffer &nonce,
|
||||
scrap_ctx( ctx_buf );
|
||||
}
|
||||
|
||||
void test_vector( const char *key_p, const char *nonce_p,
|
||||
size_t assoc_len, const char *assoc_p,
|
||||
size_t plaintext_len, const char *plaintext_p,
|
||||
size_t ciphertext_len, const char *ciphertext_p ) {
|
||||
static void test_vector( const char *key_p, const char *nonce_p,
|
||||
size_t assoc_len, const char *assoc_p,
|
||||
size_t plaintext_len, const char *plaintext_p,
|
||||
size_t ciphertext_len, const char *ciphertext_p ) {
|
||||
|
||||
AlignedBuffer key ( KEY_LEN, key_p );
|
||||
AlignedBuffer nonce ( NONCE_LEN, nonce_p );
|
||||
@@ -172,7 +172,7 @@ void test_vector( const char *key_p, const char *nonce_p,
|
||||
#define TEST_VECTOR( _key, _nonce, _assoc, _pt, _ct ) \
|
||||
test_vector( _key, _nonce, sizeof(_assoc)-1, _assoc, sizeof(_pt)-1, _pt, sizeof(_ct)-1, _ct )
|
||||
|
||||
void test_all_vectors( void ) {
|
||||
static void test_all_vectors( void ) {
|
||||
/* Test vectors from http://tools.ietf.org/html/draft-krovetz-ocb-03#appendix-A */
|
||||
|
||||
const char ietf_key[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F";
|
||||
@@ -463,7 +463,7 @@ void test_all_vectors( void ) {
|
||||
/* http://tools.ietf.org/html/draft-krovetz-ocb-03#appendix-A
|
||||
also specifies an iterative test algorithm, which we implement here. */
|
||||
|
||||
void test_iterative( void ) {
|
||||
static void test_iterative( void ) {
|
||||
/* Key is always all zeros */
|
||||
AlignedBuffer key( KEY_LEN );
|
||||
memset( key.data(), 0, KEY_LEN );
|
||||
|
||||
Reference in New Issue
Block a user