#endif
#endif
-const char* const SLUNKCRYPT_VERSION = LIB_VERSION_STRING;
-const char* const SLUNKCRYPT_BUILD = __DATE__", "__TIME__;
+/* Version info */
+const uint16_t SLUNKCRYPT_VERSION_MAJOR = MY_VERSION_MAJOR;
+const uint16_t SLUNKCRYPT_VERSION_MINOR = MY_VERSION_MINOR;
+const uint16_t SLUNKCRYPT_VERSION_PATCH = MY_VERSION_PATCH;
+const char* const SLUNKCRYPT_BUILD = __DATE__ " " __TIME__;
+
+// ==========================================================================
+// Data structures
+// ==========================================================================
typedef struct
{
slunkcrypt_t slunkcrypt_alloc(const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len)
{
- if ((!passwd) || (passwd_len < 1U))
+ if ((!passwd) || (passwd_len < SLUNKCRYPT_PWDLEN_MIN) || (passwd_len > SLUNKCRYPT_PWDLEN_MAX))
{
return SLUNKCRYPT_NULL;
}
int slunkcrypt_reset(const slunkcrypt_t context, const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len)
{
crypt_state_t* const state = (crypt_state_t*)context;
- if ((!state) || (!passwd) || (passwd_len < 1U))
+ if ((!state) || (!passwd) || (passwd_len < SLUNKCRYPT_PWDLEN_MIN) || (passwd_len > SLUNKCRYPT_PWDLEN_MAX))
{
return SLUNKCRYPT_FAILURE;
}
{
return SLUNKCRYPT_FAILURE;
}
- for (size_t i = 0; i < length; ++i)
+ if (length > 0U)
{
- output[i] = process_enc(state, input[i]);
- CHECK_ABORTED();
+ for (size_t i = 0; i < length; ++i)
+ {
+ output[i] = process_enc(state, input[i]);
+ CHECK_ABORTED();
+ }
}
return SLUNKCRYPT_SUCCESS;
}
{
return SLUNKCRYPT_FAILURE;
}
- for (size_t i = 0; i < length; ++i)
+ if (length > 0U)
{
- buffer[i] = process_enc(state, buffer[i]);
- CHECK_ABORTED();
+ for (size_t i = 0; i < length; ++i)
+ {
+ buffer[i] = process_enc(state, buffer[i]);
+ CHECK_ABORTED();
+ }
}
return SLUNKCRYPT_SUCCESS;
}
{
return SLUNKCRYPT_FAILURE;
}
- for (size_t i = 0; i < length; ++i)
+ if (length > 0U)
{
- output[i] = process_dec(state, input[i]);
- CHECK_ABORTED();
+ for (size_t i = 0; i < length; ++i)
+ {
+ output[i] = process_dec(state, input[i]);
+ CHECK_ABORTED();
+ }
}
return SLUNKCRYPT_SUCCESS;
}
{
return SLUNKCRYPT_FAILURE;
}
- for (size_t i = 0; i < length; ++i)
+ if (length > 0U)
{
- buffer[i] = process_dec(state, buffer[i]);
- CHECK_ABORTED();
+ for (size_t i = 0; i < length; ++i)
+ {
+ buffer[i] = process_dec(state, buffer[i]);
+ CHECK_ABORTED();
+ }
}
return SLUNKCRYPT_SUCCESS;
}