Use arpa/inet.h functions instead of endian.h

Even though arpa/inet.h is "networky" and this isn't a network
application, arpa/inet.h is in POSIX whereas endian.h is non-standard.

This should let git-crypt build on Mac OS X.
This commit is contained in:
Andrew Ayer
2013-01-24 21:57:49 -08:00
parent d3dcc7da64
commit b2164be760

View File

@@ -27,7 +27,7 @@
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <endian.h>
#include <arpa/inet.h>
void load_keys (const char* filepath, keys_t* keys)
{
@@ -71,7 +71,7 @@ void aes_ctr_state::process (const AES_KEY* key, const uint8_t* in, uint8_t* out
// first 12 bytes - nonce
// last 4 bytes - block number (sequentially increasing with each block)
uint8_t ctr[16];
uint32_t blockno = htole32(byte_counter / 16);
uint32_t blockno = htonl(byte_counter / 16);
memcpy(ctr, nonce, 12);
memcpy(ctr + 12, &blockno, 4);
AES_encrypt(ctr, otp, key);