Commit dd373b8b authored by avi's avatar avi Committed by Commit bot

Switch to standard integer types in crypto/.

BUG=138542
TBR=rsleevi@chromium.org
NOPRESUBMIT=true

Review URL: https://codereview.chromium.org/1539353003

Cr-Commit-Position: refs/heads/master@{#366460}
parent 64114156
......@@ -8,9 +8,10 @@
#include <openssl/aes.h>
#include <openssl/evp.h>
#include <stddef.h>
#include <stdint.h>
#include <string>
#include "base/basictypes.h"
#include "base/strings/string_util.h"
#include "crypto/openssl_util.h"
......@@ -43,7 +44,7 @@ bool Aead::Seal(const base::StringPiece& plaintext,
EVP_AEAD_CTX ctx;
if (!EVP_AEAD_CTX_init(&ctx, aead_,
reinterpret_cast<const uint8*>(key_->data()),
reinterpret_cast<const uint8_t*>(key_->data()),
key_->size(), EVP_AEAD_DEFAULT_TAG_LENGTH, nullptr)) {
return false;
}
......@@ -52,14 +53,14 @@ bool Aead::Seal(const base::StringPiece& plaintext,
const size_t max_output_length =
EVP_AEAD_max_overhead(aead_) + plaintext.size();
size_t output_length;
uint8* out_ptr =
reinterpret_cast<uint8*>(base::WriteInto(&result, max_output_length + 1));
uint8_t* out_ptr = reinterpret_cast<uint8_t*>(
base::WriteInto(&result, max_output_length + 1));
if (!EVP_AEAD_CTX_seal(
&ctx, out_ptr, &output_length, max_output_length,
reinterpret_cast<const uint8*>(nonce.data()), nonce.size(),
reinterpret_cast<const uint8*>(plaintext.data()), plaintext.size(),
reinterpret_cast<const uint8*>(additional_data.data()),
reinterpret_cast<const uint8_t*>(nonce.data()), nonce.size(),
reinterpret_cast<const uint8_t*>(plaintext.data()), plaintext.size(),
reinterpret_cast<const uint8_t*>(additional_data.data()),
additional_data.size())) {
EVP_AEAD_CTX_cleanup(&ctx);
return false;
......@@ -82,7 +83,7 @@ bool Aead::Open(const base::StringPiece& ciphertext,
EVP_AEAD_CTX ctx;
if (!EVP_AEAD_CTX_init(&ctx, aead_,
reinterpret_cast<const uint8*>(key_->data()),
reinterpret_cast<const uint8_t*>(key_->data()),
key_->size(), EVP_AEAD_DEFAULT_TAG_LENGTH, nullptr)) {
return false;
}
......@@ -90,14 +91,15 @@ bool Aead::Open(const base::StringPiece& ciphertext,
std::string result;
const size_t max_output_length = ciphertext.size();
size_t output_length;
uint8* out_ptr =
reinterpret_cast<uint8*>(base::WriteInto(&result, max_output_length + 1));
uint8_t* out_ptr = reinterpret_cast<uint8_t*>(
base::WriteInto(&result, max_output_length + 1));
if (!EVP_AEAD_CTX_open(
&ctx, out_ptr, &output_length, max_output_length,
reinterpret_cast<const uint8*>(nonce.data()), nonce.size(),
reinterpret_cast<const uint8*>(ciphertext.data()), ciphertext.size(),
reinterpret_cast<const uint8*>(additional_data.data()),
reinterpret_cast<const uint8_t*>(nonce.data()), nonce.size(),
reinterpret_cast<const uint8_t*>(ciphertext.data()),
ciphertext.size(),
reinterpret_cast<const uint8_t*>(additional_data.data()),
additional_data.size())) {
EVP_AEAD_CTX_cleanup(&ctx);
return false;
......
......@@ -5,6 +5,8 @@
#ifndef CRYPTO_AEAD_H_
#define CRYPTO_AEAD_H_
#include <stddef.h>
#include "base/strings/string_piece.h"
#include "crypto/crypto_export.h"
......
......@@ -7,7 +7,8 @@
#include <Security/Security.h>
#include "base/basictypes.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "crypto/crypto_export.h"
#if defined (OS_IOS)
......
......@@ -4,7 +4,9 @@
#include "crypto/capi_util.h"
#include "base/basictypes.h"
#include <stddef.h>
#include "base/macros.h"
#include "base/memory/singleton.h"
#include "base/synchronization/lock.h"
......
......@@ -6,6 +6,7 @@
#define CRYPTO_CAPI_UTIL_H_
#include <windows.h>
#include <stddef.h>
#include "crypto/crypto_export.h"
#include "crypto/wincrypt_shim.h"
......
......@@ -5,6 +5,7 @@
#include "crypto/cssm_init.h"
#include <Security/SecBase.h>
#include <stdint.h>
#include "base/logging.h"
#include "base/mac/scoped_cftyperef.h"
......@@ -32,7 +33,7 @@ void* CSSMRealloc(void* ptr, CSSM_SIZE size, void* alloc_ref) {
return realloc(ptr, size);
}
void* CSSMCalloc(uint32 num, CSSM_SIZE size, void* alloc_ref) {
void* CSSMCalloc(uint32_t num, CSSM_SIZE size, void* alloc_ref) {
return calloc(num, size);
}
......
......@@ -7,7 +7,7 @@
#include <Security/cssm.h>
#include "base/basictypes.h"
#include "base/macros.h"
#include "crypto/crypto_export.h"
namespace crypto {
......
......@@ -4,6 +4,8 @@
#include "crypto/curve25519.h"
#include <stdint.h>
#include "crypto/secure_util.h"
// Curve25519 is specified in terms of byte strings, not numbers, so all
......
......@@ -5,6 +5,7 @@
#include "crypto/curve25519.h"
#include <openssl/curve25519.h>
#include <stdint.h>
namespace crypto {
......
......@@ -4,6 +4,8 @@
#include "crypto/curve25519.h"
#include <stdint.h>
#include <string>
#include "crypto/random.h"
......
......@@ -5,10 +5,13 @@
#ifndef CRYPTO_EC_PRIVATE_KEY_H_
#define CRYPTO_EC_PRIVATE_KEY_H_
#include <stddef.h>
#include <stdint.h>
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "crypto/crypto_export.h"
......@@ -45,8 +48,8 @@ class CRYPTO_EXPORT ECPrivateKey {
// Returns NULL if initialization fails.
static ECPrivateKey* CreateFromEncryptedPrivateKeyInfo(
const std::string& password,
const std::vector<uint8>& encrypted_private_key_info,
const std::vector<uint8>& subject_public_key_info);
const std::vector<uint8_t>& encrypted_private_key_info,
const std::vector<uint8_t>& subject_public_key_info);
#if !defined(USE_OPENSSL)
// Imports the key pair into |slot| and returns in |public_key| and |key|.
......@@ -56,7 +59,7 @@ class CRYPTO_EXPORT ECPrivateKey {
static bool ImportFromEncryptedPrivateKeyInfo(
PK11SlotInfo* slot,
const std::string& password,
const uint8* encrypted_private_key_info,
const uint8_t* encrypted_private_key_info,
size_t encrypted_private_key_info_len,
CERTSubjectPublicKeyInfo* decoded_spki,
bool permanent,
......@@ -82,18 +85,18 @@ class CRYPTO_EXPORT ECPrivateKey {
// of 1000 iterations, on modern systems a larger value may be preferrable.
bool ExportEncryptedPrivateKey(const std::string& password,
int iterations,
std::vector<uint8>* output);
std::vector<uint8_t>* output);
// Exports the public key to an X.509 SubjectPublicKeyInfo block.
bool ExportPublicKey(std::vector<uint8>* output);
bool ExportPublicKey(std::vector<uint8_t>* output);
// Exports the public key as an EC point in the uncompressed point format.
bool ExportRawPublicKey(std::string* output);
// Exports private key data for testing. The format of data stored into output
// doesn't matter other than that it is consistent for the same key.
bool ExportValue(std::vector<uint8>* output);
bool ExportECParams(std::vector<uint8>* output);
bool ExportValue(std::vector<uint8_t>* output);
bool ExportECParams(std::vector<uint8_t>* output);
private:
// Constructor is private. Use one of the Create*() methods above instead.
......
......@@ -14,6 +14,8 @@ extern "C" {
#include <keyhi.h>
#include <pk11pub.h>
#include <secmod.h>
#include <stddef.h>
#include <stdint.h>
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
......@@ -27,7 +29,7 @@ namespace {
// Copied from rsa_private_key_nss.cc.
static bool ReadAttribute(SECKEYPrivateKey* key,
CK_ATTRIBUTE_TYPE type,
std::vector<uint8>* output) {
std::vector<uint8_t>* output) {
SECItem item;
SECStatus rv;
rv = PK11_ReadRawAttribute(PK11_TypePrivKey, key, type, &item);
......@@ -102,8 +104,8 @@ ECPrivateKey* ECPrivateKey::Create() {
// static
ECPrivateKey* ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
const std::string& password,
const std::vector<uint8>& encrypted_private_key_info,
const std::vector<uint8>& subject_public_key_info) {
const std::vector<uint8_t>& encrypted_private_key_info,
const std::vector<uint8_t>& subject_public_key_info) {
EnsureNSSInit();
ScopedPK11Slot slot(PK11_GetInternalSlot());
......@@ -149,7 +151,7 @@ ECPrivateKey* ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
bool ECPrivateKey::ImportFromEncryptedPrivateKeyInfo(
PK11SlotInfo* slot,
const std::string& password,
const uint8* encrypted_private_key_info,
const uint8_t* encrypted_private_key_info,
size_t encrypted_private_key_info_len,
CERTSubjectPublicKeyInfo* decoded_spki,
bool permanent,
......@@ -237,10 +239,9 @@ ECPrivateKey* ECPrivateKey::Copy() const {
return copy.release();
}
bool ECPrivateKey::ExportEncryptedPrivateKey(
const std::string& password,
int iterations,
std::vector<uint8>* output) {
bool ECPrivateKey::ExportEncryptedPrivateKey(const std::string& password,
int iterations,
std::vector<uint8_t>* output) {
// We export as an EncryptedPrivateKeyInfo bundle instead of a plain PKCS #8
// PrivateKeyInfo because PK11_ImportDERPrivateKeyInfoAndReturnKey doesn't
// support EC keys.
......@@ -282,7 +283,7 @@ bool ECPrivateKey::ExportEncryptedPrivateKey(
return true;
}
bool ECPrivateKey::ExportPublicKey(std::vector<uint8>* output) {
bool ECPrivateKey::ExportPublicKey(std::vector<uint8_t>* output) {
ScopedSECItem der_pubkey(
SECKEY_EncodeDERSubjectPublicKeyInfo(public_key_));
if (!der_pubkey.get()) {
......@@ -310,11 +311,11 @@ bool ECPrivateKey::ExportRawPublicKey(std::string* output) {
return true;
}
bool ECPrivateKey::ExportValue(std::vector<uint8>* output) {
bool ECPrivateKey::ExportValue(std::vector<uint8_t>* output) {
return ReadAttribute(key_, CKA_VALUE, output);
}
bool ECPrivateKey::ExportECParams(std::vector<uint8>* output) {
bool ECPrivateKey::ExportECParams(std::vector<uint8_t>* output) {
return ReadAttribute(key_, CKA_EC_PARAMS, output);
}
......
......@@ -8,6 +8,8 @@
#include <openssl/evp.h>
#include <openssl/pkcs12.h>
#include <openssl/x509.h>
#include <stddef.h>
#include <stdint.h>
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
......@@ -32,7 +34,7 @@ using ScopedX509_SIG = ScopedOpenSSL<X509_SIG, X509_SIG_free>;
// Helper to export |key| into |output| via the specified ExportBioFunction.
bool ExportKeyWithBio(const void* key,
ExportBioFunction export_fn,
std::vector<uint8>* output) {
std::vector<uint8_t>* output) {
if (!key)
return false;
......@@ -62,7 +64,7 @@ typedef int (*ExportDataFunction)(const void* key, unsigned char** data);
// Helper to export |key| into |output| via the specified export function.
bool ExportKey(const void* key,
ExportDataFunction export_fn,
std::vector<uint8>* output) {
std::vector<uint8_t>* output) {
if (!key)
return false;
......@@ -112,8 +114,8 @@ ECPrivateKey* ECPrivateKey::Create() {
// static
ECPrivateKey* ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
const std::string& password,
const std::vector<uint8>& encrypted_private_key_info,
const std::vector<uint8>& subject_public_key_info) {
const std::vector<uint8_t>& encrypted_private_key_info,
const std::vector<uint8_t>& subject_public_key_info) {
// NOTE: The |subject_public_key_info| can be ignored here, it is only
// useful for the NSS implementation (which uses the public key's SHA1
// as a lookup key when storing the private one in its store).
......@@ -157,10 +159,9 @@ ECPrivateKey* ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
return result.release();
}
bool ECPrivateKey::ExportEncryptedPrivateKey(
const std::string& password,
int iterations,
std::vector<uint8>* output) {
bool ECPrivateKey::ExportEncryptedPrivateKey(const std::string& password,
int iterations,
std::vector<uint8_t>* output) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
// Convert into a PKCS#8 object.
ScopedPKCS8_PRIV_KEY_INFO pkcs8(EVP_PKEY2PKCS8(key_));
......@@ -189,7 +190,7 @@ bool ECPrivateKey::ExportEncryptedPrivateKey(
output);
}
bool ECPrivateKey::ExportPublicKey(std::vector<uint8>* output) {
bool ECPrivateKey::ExportPublicKey(std::vector<uint8_t>* output) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
return ExportKeyWithBio(
key_, reinterpret_cast<ExportBioFunction>(i2d_PUBKEY_bio), output);
......@@ -205,8 +206,8 @@ bool ECPrivateKey::ExportRawPublicKey(std::string* output) {
if (len != kExpectedKeyLength)
return false;
uint8 buf[kExpectedKeyLength];
uint8* derp = buf;
uint8_t buf[kExpectedKeyLength];
uint8_t* derp = buf;
len = i2d_PublicKey(key_, &derp);
if (len != kExpectedKeyLength)
return false;
......@@ -215,7 +216,7 @@ bool ECPrivateKey::ExportRawPublicKey(std::string* output) {
return true;
}
bool ECPrivateKey::ExportValue(std::vector<uint8>* output) {
bool ECPrivateKey::ExportValue(std::vector<uint8_t>* output) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
ScopedEC_KEY ec_key(EVP_PKEY_get1_EC_KEY(key_));
return ExportKey(ec_key.get(),
......@@ -223,7 +224,7 @@ bool ECPrivateKey::ExportValue(std::vector<uint8>* output) {
output);
}
bool ECPrivateKey::ExportECParams(std::vector<uint8>* output) {
bool ECPrivateKey::ExportECParams(std::vector<uint8_t>* output) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
ScopedEC_KEY ec_key(EVP_PKEY_get1_EC_KEY(key_));
return ExportKey(ec_key.get(),
......
......@@ -4,6 +4,8 @@
#include "crypto/ec_private_key.h"
#include <stdint.h>
#include <vector>
#include "base/macros.h"
......@@ -22,19 +24,19 @@ TEST(ECPrivateKeyUnitTest, InitRandomTest) {
ASSERT_TRUE(keypair1.get());
ASSERT_TRUE(keypair2.get());
std::vector<uint8> key1value;
std::vector<uint8> key2value;
std::vector<uint8> key1params;
std::vector<uint8> key2params;
std::vector<uint8_t> key1value;
std::vector<uint8_t> key2value;
std::vector<uint8_t> key1params;
std::vector<uint8_t> key2params;
EXPECT_TRUE(keypair1->ExportValue(&key1value));
EXPECT_TRUE(keypair2->ExportValue(&key2value));
EXPECT_TRUE(keypair1->ExportECParams(&key1params));
EXPECT_TRUE(keypair2->ExportECParams(&key2params));
std::vector<uint8> privkey1;
std::vector<uint8> privkey2;
std::vector<uint8> pubkey1;
std::vector<uint8> pubkey2;
std::vector<uint8_t> privkey1;
std::vector<uint8_t> privkey2;
std::vector<uint8_t> pubkey1;
std::vector<uint8_t> pubkey2;
std::string raw_pubkey1;
std::string raw_pubkey2;
ASSERT_TRUE(keypair1->ExportEncryptedPrivateKey(password1, 1, &privkey1));
......@@ -53,10 +55,10 @@ TEST(ECPrivateKeyUnitTest, InitRandomTest) {
ASSERT_TRUE(keypair3.get());
ASSERT_TRUE(keypair4.get());
std::vector<uint8> key3value;
std::vector<uint8> key4value;
std::vector<uint8> key3params;
std::vector<uint8> key4params;
std::vector<uint8_t> key3value;
std::vector<uint8_t> key4value;
std::vector<uint8_t> key3params;
std::vector<uint8_t> key4params;
EXPECT_TRUE(keypair3->ExportValue(&key3value));
EXPECT_TRUE(keypair4->ExportValue(&key4value));
EXPECT_TRUE(keypair3->ExportECParams(&key3params));
......@@ -67,8 +69,8 @@ TEST(ECPrivateKeyUnitTest, InitRandomTest) {
EXPECT_EQ(key1params, key3params);
EXPECT_EQ(key2params, key4params);
std::vector<uint8> pubkey3;
std::vector<uint8> pubkey4;
std::vector<uint8_t> pubkey3;
std::vector<uint8_t> pubkey4;
std::string raw_pubkey3;
std::string raw_pubkey4;
EXPECT_TRUE(keypair3->ExportPublicKey(&pubkey3));
......@@ -88,20 +90,20 @@ TEST(ECPrivateKeyUnitTest, Copy) {
ASSERT_TRUE(keypair1.get());
ASSERT_TRUE(keypair2.get());
std::vector<uint8> key1value;
std::vector<uint8> key2value;
std::vector<uint8_t> key1value;
std::vector<uint8_t> key2value;
EXPECT_TRUE(keypair1->ExportValue(&key1value));
EXPECT_TRUE(keypair2->ExportValue(&key2value));
EXPECT_EQ(key1value, key2value);
std::vector<uint8> key1params;
std::vector<uint8> key2params;
std::vector<uint8_t> key1params;
std::vector<uint8_t> key2params;
EXPECT_TRUE(keypair1->ExportECParams(&key1params));
EXPECT_TRUE(keypair2->ExportECParams(&key2params));
EXPECT_EQ(key1params, key2params);
std::vector<uint8> pubkey1;
std::vector<uint8> pubkey2;
std::vector<uint8_t> pubkey1;
std::vector<uint8_t> pubkey2;
EXPECT_TRUE(keypair1->ExportPublicKey(&pubkey1));
EXPECT_TRUE(keypair2->ExportPublicKey(&pubkey2));
EXPECT_EQ(pubkey1, pubkey2);
......@@ -121,8 +123,8 @@ TEST(ECPrivateKeyUnitTest, BadPasswordTest) {
crypto::ECPrivateKey::Create());
ASSERT_TRUE(keypair1.get());
std::vector<uint8> privkey1;
std::vector<uint8> pubkey1;
std::vector<uint8_t> privkey1;
std::vector<uint8_t> pubkey1;
ASSERT_TRUE(keypair1->ExportEncryptedPrivateKey(
password1, 1, &privkey1));
ASSERT_TRUE(keypair1->ExportPublicKey(&pubkey1));
......@@ -163,10 +165,9 @@ TEST(ECPrivateKeyUnitTest, LoadNSSKeyTest) {
scoped_ptr<crypto::ECPrivateKey> keypair_nss(
crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
"",
std::vector<uint8>(nss_key, nss_key + arraysize(nss_key)),
std::vector<uint8>(nss_pub_key,
nss_pub_key + arraysize(nss_pub_key))));
"", std::vector<uint8_t>(nss_key, nss_key + arraysize(nss_key)),
std::vector<uint8_t>(nss_pub_key,
nss_pub_key + arraysize(nss_pub_key))));
EXPECT_TRUE(keypair_nss.get());
}
......@@ -202,10 +203,10 @@ TEST(ECPrivateKeyUnitTest, LoadOpenSSLKeyTest) {
scoped_ptr<crypto::ECPrivateKey> keypair_openssl(
crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
"",
std::vector<uint8>(openssl_key, openssl_key + arraysize(openssl_key)),
std::vector<uint8>(openssl_pub_key,
openssl_pub_key + arraysize(openssl_pub_key))));
"", std::vector<uint8_t>(openssl_key,
openssl_key + arraysize(openssl_key)),
std::vector<uint8_t>(openssl_pub_key,
openssl_pub_key + arraysize(openssl_pub_key))));
EXPECT_TRUE(keypair_openssl.get());
}
......@@ -284,10 +285,10 @@ TEST(ECPrivateKeyUnitTest, LoadOldOpenSSLKeyTest) {
scoped_ptr<crypto::ECPrivateKey> keypair_openssl(
crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
"",
std::vector<uint8>(openssl_key, openssl_key + arraysize(openssl_key)),
std::vector<uint8>(openssl_pub_key,
openssl_pub_key + arraysize(openssl_pub_key))));
"", std::vector<uint8_t>(openssl_key,
openssl_key + arraysize(openssl_key)),
std::vector<uint8_t>(openssl_pub_key,
openssl_pub_key + arraysize(openssl_pub_key))));
EXPECT_TRUE(keypair_openssl.get());
}
......
......@@ -5,10 +5,11 @@
#ifndef CRYPTO_EC_SIGNATURE_CREATOR_H_
#define CRYPTO_EC_SIGNATURE_CREATOR_H_
#include <stdint.h>
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "crypto/crypto_export.h"
namespace crypto {
......@@ -48,17 +49,17 @@ class CRYPTO_EXPORT ECSignatureCreator {
// ECDSA-Sig-Value ::= SEQUENCE {
// r INTEGER,
// s INTEGER }
virtual bool Sign(const uint8* data,
virtual bool Sign(const uint8_t* data,
int data_len,
std::vector<uint8>* signature) = 0;
std::vector<uint8_t>* signature) = 0;
// DecodeSignature converts from a DER encoded ECDSA-Sig-Value (as produced
// by Sign) to a `raw' ECDSA signature which consists of a pair of
// big-endian, zero-padded, 256-bit integers, r and s. On success it returns
// true and puts the raw signature into |out_raw_sig|.
// (Only P-256 signatures are supported.)
virtual bool DecodeSignature(const std::vector<uint8>& signature,
std::vector<uint8>* out_raw_sig) = 0;
virtual bool DecodeSignature(const std::vector<uint8_t>& signature,
std::vector<uint8_t>* out_raw_sig) = 0;
};
} // namespace crypto
......
......@@ -5,7 +5,10 @@
#ifndef CRYPTO_EC_SIGNATURE_CREATOR_IMPL_H_
#define CRYPTO_EC_SIGNATURE_CREATOR_IMPL_H_
#include <stdint.h>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "crypto/ec_signature_creator.h"
namespace crypto {
......@@ -15,12 +18,12 @@ class ECSignatureCreatorImpl : public ECSignatureCreator {
explicit ECSignatureCreatorImpl(ECPrivateKey* key);
~ECSignatureCreatorImpl() override;
bool Sign(const uint8* data,
bool Sign(const uint8_t* data,
int data_len,
std::vector<uint8>* signature) override;
std::vector<uint8_t>* signature) override;
bool DecodeSignature(const std::vector<uint8>& der_sig,
std::vector<uint8>* out_raw_sig) override;
bool DecodeSignature(const std::vector<uint8_t>& der_sig,
std::vector<uint8_t>* out_raw_sig) override;
private:
ECPrivateKey* key_;
......
......@@ -9,6 +9,8 @@
#include <secerr.h>
#include <sechash.h>
#if defined(OS_POSIX)
#include <stddef.h>
#include <stdint.h>
#include <unistd.h>