Skip to content

Commit

Permalink
Use standard uint instead of u_int style.
Browse files Browse the repository at this point in the history
  • Loading branch information
kristapsdz committed Jan 26, 2025
1 parent 318a7f8 commit ffff21f
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 188 deletions.
2 changes: 1 addition & 1 deletion compat_arc4random.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ chacha_encrypt_bytes(chacha_ctx *x,const u8 *m,u8 *c,u32 bytes)
u32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
u8 *ctarget = NULL;
u8 tmp[64];
u_int i;
unsigned int i;

if (!bytes) return;

Expand Down
103 changes: 52 additions & 51 deletions compat_blowfish.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
*/

#include <sys/types.h>
#include <stdint.h>

/* Function for Feistel Networks */

Expand All @@ -51,12 +52,12 @@
#define BLFRND(s,p,i,j,n) (i ^= F(s,j) ^ (p)[n])

void
Blowfish_encipher(blf_ctx *c, u_int32_t *xl, u_int32_t *xr)
Blowfish_encipher(blf_ctx *c, uint32_t *xl, uint32_t *xr)
{
u_int32_t Xl;
u_int32_t Xr;
u_int32_t *s = c->S[0];
u_int32_t *p = c->P;
uint32_t Xl;
uint32_t Xr;
uint32_t *s = c->S[0];
uint32_t *p = c->P;

Xl = *xl;
Xr = *xr;
Expand All @@ -76,12 +77,12 @@ Blowfish_encipher(blf_ctx *c, u_int32_t *xl, u_int32_t *xr)
}

void
Blowfish_decipher(blf_ctx *c, u_int32_t *xl, u_int32_t *xr)
Blowfish_decipher(blf_ctx *c, uint32_t *xl, uint32_t *xr)
{
u_int32_t Xl;
u_int32_t Xr;
u_int32_t *s = c->S[0];
u_int32_t *p = c->P;
uint32_t Xl;
uint32_t Xr;
uint32_t *s = c->S[0];
uint32_t *p = c->P;

Xl = *xl;
Xr = *xr;
Expand Down Expand Up @@ -379,13 +380,13 @@ Blowfish_initstate(blf_ctx *c)
*c = initstate;
}

u_int32_t
Blowfish_stream2word(const u_int8_t *data, u_int16_t databytes,
u_int16_t *current)
uint32_t
Blowfish_stream2word(const uint8_t *data, uint16_t databytes,
uint16_t *current)
{
u_int8_t i;
u_int16_t j;
u_int32_t temp;
uint8_t i;
uint16_t j;
uint32_t temp;

temp = 0x00000000;
j = *current;
Expand All @@ -401,14 +402,14 @@ Blowfish_stream2word(const u_int8_t *data, u_int16_t databytes,
}

void
Blowfish_expand0state(blf_ctx *c, const u_int8_t *key, u_int16_t keybytes)
Blowfish_expand0state(blf_ctx *c, const uint8_t *key, uint16_t keybytes)
{
u_int16_t i;
u_int16_t j;
u_int16_t k;
u_int32_t temp;
u_int32_t datal;
u_int32_t datar;
uint16_t i;
uint16_t j;
uint16_t k;
uint32_t temp;
uint32_t datal;
uint32_t datar;

j = 0;
for (i = 0; i < BLF_N + 2; i++) {
Expand Down Expand Up @@ -438,15 +439,15 @@ Blowfish_expand0state(blf_ctx *c, const u_int8_t *key, u_int16_t keybytes)
}

void
Blowfish_expandstate(blf_ctx *c, const u_int8_t *data, u_int16_t databytes,
const u_int8_t *key, u_int16_t keybytes)
Blowfish_expandstate(blf_ctx *c, const uint8_t *data, uint16_t databytes,
const uint8_t *key, uint16_t keybytes)
{
u_int16_t i;
u_int16_t j;
u_int16_t k;
u_int32_t temp;
u_int32_t datal;
u_int32_t datar;
uint16_t i;
uint16_t j;
uint16_t k;
uint32_t temp;
uint32_t datal;
uint32_t datar;

j = 0;
for (i = 0; i < BLF_N + 2; i++) {
Expand Down Expand Up @@ -481,7 +482,7 @@ Blowfish_expandstate(blf_ctx *c, const u_int8_t *data, u_int16_t databytes,
}

void
blf_key(blf_ctx *c, const u_int8_t *k, u_int16_t len)
blf_key(blf_ctx *c, const uint8_t *k, uint16_t len)
{
/* Initialize S-boxes and subkeys with Pi */
Blowfish_initstate(c);
Expand All @@ -491,10 +492,10 @@ blf_key(blf_ctx *c, const u_int8_t *k, u_int16_t len)
}

void
blf_enc(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
blf_enc(blf_ctx *c, uint32_t *data, uint16_t blocks)
{
u_int32_t *d;
u_int16_t i;
uint32_t *d;
uint16_t i;

d = data;
for (i = 0; i < blocks; i++) {
Expand All @@ -504,10 +505,10 @@ blf_enc(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
}

void
blf_dec(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
blf_dec(blf_ctx *c, uint32_t *data, uint16_t blocks)
{
u_int32_t *d;
u_int16_t i;
uint32_t *d;
uint16_t i;

d = data;
for (i = 0; i < blocks; i++) {
Expand All @@ -517,10 +518,10 @@ blf_dec(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
}

void
blf_ecb_encrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
blf_ecb_encrypt(blf_ctx *c, uint8_t *data, uint32_t len)
{
u_int32_t l, r;
u_int32_t i;
uint32_t l, r;
uint32_t i;

for (i = 0; i < len; i += 8) {
l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
Expand All @@ -539,10 +540,10 @@ blf_ecb_encrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
}

void
blf_ecb_decrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
blf_ecb_decrypt(blf_ctx *c, uint8_t *data, uint32_t len)
{
u_int32_t l, r;
u_int32_t i;
uint32_t l, r;
uint32_t i;

for (i = 0; i < len; i += 8) {
l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
Expand All @@ -561,10 +562,10 @@ blf_ecb_decrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
}

void
blf_cbc_encrypt(blf_ctx *c, u_int8_t *iv, u_int8_t *data, u_int32_t len)
blf_cbc_encrypt(blf_ctx *c, uint8_t *iv, uint8_t *data, uint32_t len)
{
u_int32_t l, r;
u_int32_t i, j;
uint32_t l, r;
uint32_t i, j;

for (i = 0; i < len; i += 8) {
for (j = 0; j < 8; j++)
Expand All @@ -586,11 +587,11 @@ blf_cbc_encrypt(blf_ctx *c, u_int8_t *iv, u_int8_t *data, u_int32_t len)
}

void
blf_cbc_decrypt(blf_ctx *c, u_int8_t *iva, u_int8_t *data, u_int32_t len)
blf_cbc_decrypt(blf_ctx *c, uint8_t *iva, uint8_t *data, uint32_t len)
{
u_int32_t l, r;
u_int8_t *iv;
u_int32_t i, j;
uint32_t l, r;
uint8_t *iv;
uint32_t i, j;

iv = data + len - 16;
data = data + len - 8;
Expand Down
42 changes: 21 additions & 21 deletions compat_crypt_newhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
#define BCRYPT_SALTSPACE (7 + (BCRYPT_MAXSALT * 4 + 2) / 3 + 1)
#define BCRYPT_HASHSPACE 61

static int encode_base64(char *, const u_int8_t *, size_t);
static int decode_base64(u_int8_t *, size_t, const char *);
static int encode_base64(char *, const uint8_t *, size_t);
static int decode_base64(uint8_t *, size_t, const char *);

/*
* Generates a salt for this version of crypt.
Expand Down Expand Up @@ -94,13 +94,13 @@ bcrypt_hashpass(const char *key, const char *salt, char *encrypted,
size_t encryptedlen)
{
blf_ctx state;
u_int32_t rounds, i, k;
u_int16_t j;
uint32_t rounds, i, k;
uint16_t j;
size_t key_len;
u_int8_t salt_len, logr, minor;
u_int8_t ciphertext[4 * BCRYPT_WORDS] = "OrpheanBeholderScryDoubt";
u_int8_t csalt[BCRYPT_MAXSALT];
u_int32_t cdata[BCRYPT_WORDS];
uint8_t salt_len, logr, minor;
uint8_t ciphertext[4 * BCRYPT_WORDS] = "OrpheanBeholderScryDoubt";
uint8_t csalt[BCRYPT_MAXSALT];
uint32_t cdata[BCRYPT_WORDS];

if (encryptedlen < BCRYPT_HASHSPACE)
goto inval;
Expand All @@ -116,7 +116,7 @@ bcrypt_hashpass(const char *key, const char *salt, char *encrypted,
/* Check for minor versions */
switch ((minor = salt[1])) {
case 'a':
key_len = (u_int8_t)(strlen(key) + 1);
key_len = (uint8_t)(strlen(key) + 1);
break;
case 'b':
/* strlen() returns a size_t, but the function calls
Expand Down Expand Up @@ -160,9 +160,9 @@ bcrypt_hashpass(const char *key, const char *salt, char *encrypted,
/* Setting up S-Boxes and Subkeys */
Blowfish_initstate(&state);
Blowfish_expandstate(&state, csalt, salt_len,
(u_int8_t *) key, key_len);
(uint8_t *) key, key_len);
for (k = 0; k < rounds; k++) {
Blowfish_expand0state(&state, (u_int8_t *) key, key_len);
Blowfish_expand0state(&state, (uint8_t *) key, key_len);
Blowfish_expand0state(&state, csalt, salt_len);
}

Expand Down Expand Up @@ -272,10 +272,10 @@ _bcrypt_autorounds(void)
/*
* internal utilities
*/
static const u_int8_t Base64Code[] =
static const uint8_t Base64Code[] =
"./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

static const u_int8_t index_64[128] = {
static const uint8_t index_64[128] = {
255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
Expand All @@ -296,11 +296,11 @@ static const u_int8_t index_64[128] = {
* read buflen (after decoding) bytes of data from b64data
*/
static int
decode_base64(u_int8_t *buffer, size_t len, const char *b64data)
decode_base64(uint8_t *buffer, size_t len, const char *b64data)
{
u_int8_t *bp = buffer;
const u_int8_t *p = (const u_int8_t *)b64data;
u_int8_t c1, c2, c3, c4;
uint8_t *bp = buffer;
const uint8_t *p = (const uint8_t *)b64data;
uint8_t c1, c2, c3, c4;

while (bp < buffer + len) {
c1 = CHAR64(*p);
Expand Down Expand Up @@ -339,11 +339,11 @@ decode_base64(u_int8_t *buffer, size_t len, const char *b64data)
* This works without = padding.
*/
static int
encode_base64(char *b64buffer, const u_int8_t *data, size_t len)
encode_base64(char *b64buffer, const uint8_t *data, size_t len)
{
u_int8_t *bp = (u_int8_t *)b64buffer;
const u_int8_t *p = data;
u_int8_t c1, c2;
uint8_t *bp = (uint8_t *)b64buffer;
const uint8_t *p = data;
uint8_t c1, c2;

while (p < data + len) {
c1 = *p++;
Expand Down
1 change: 1 addition & 0 deletions compat_md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include <sys/types.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

Expand Down
Loading

0 comments on commit ffff21f

Please sign in to comment.