cleanup: use ssh_ prefix in the blf (non-static) functions
Having "ssh_" prefix in the functions' name will avoid possible clashes when compiling libssh statically. Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
родитель
6f60449e18
Коммит
63e52afd5b
@ -53,7 +53,7 @@
|
||||
typedef struct BlowfishContext {
|
||||
uint32_t S[4][256]; /* S-Boxes */
|
||||
uint32_t P[BLF_N + 2]; /* Subkeys */
|
||||
} blf_ctx;
|
||||
} ssh_blf_ctx;
|
||||
|
||||
/* Raw access to customized Blowfish
|
||||
* blf_key is just:
|
||||
@ -61,24 +61,24 @@ typedef struct BlowfishContext {
|
||||
* Blowfish_expand0state( state, key, keylen )
|
||||
*/
|
||||
|
||||
void Blowfish_encipher(blf_ctx *, uint32_t *, uint32_t *);
|
||||
void Blowfish_decipher(blf_ctx *, uint32_t *, uint32_t *);
|
||||
void Blowfish_initstate(blf_ctx *);
|
||||
void Blowfish_expand0state(blf_ctx *, const uint8_t *, uint16_t);
|
||||
void Blowfish_encipher(ssh_blf_ctx *, uint32_t *, uint32_t *);
|
||||
void Blowfish_decipher(ssh_blf_ctx *, uint32_t *, uint32_t *);
|
||||
void Blowfish_initstate(ssh_blf_ctx *);
|
||||
void Blowfish_expand0state(ssh_blf_ctx *, const uint8_t *, uint16_t);
|
||||
void Blowfish_expandstate
|
||||
(blf_ctx *, const uint8_t *, uint16_t, const uint8_t *, uint16_t);
|
||||
(ssh_blf_ctx *, const uint8_t *, uint16_t, const uint8_t *, uint16_t);
|
||||
|
||||
/* Standard Blowfish */
|
||||
|
||||
void blf_key(blf_ctx *, const uint8_t *, uint16_t);
|
||||
void blf_enc(blf_ctx *, uint32_t *, uint16_t);
|
||||
void blf_dec(blf_ctx *, uint32_t *, uint16_t);
|
||||
void ssh_blf_key(ssh_blf_ctx *, const uint8_t *, uint16_t);
|
||||
void ssh_blf_enc(ssh_blf_ctx *, uint32_t *, uint16_t);
|
||||
void ssh_blf_dec(ssh_blf_ctx *, uint32_t *, uint16_t);
|
||||
|
||||
void blf_ecb_encrypt(blf_ctx *, uint8_t *, uint32_t);
|
||||
void blf_ecb_decrypt(blf_ctx *, uint8_t *, uint32_t);
|
||||
void ssh_blf_ecb_encrypt(ssh_blf_ctx *, uint8_t *, uint32_t);
|
||||
void ssh_blf_ecb_decrypt(ssh_blf_ctx *, uint8_t *, uint32_t);
|
||||
|
||||
void blf_cbc_encrypt(blf_ctx *, uint8_t *, uint8_t *, uint32_t);
|
||||
void blf_cbc_decrypt(blf_ctx *, uint8_t *, uint8_t *, uint32_t);
|
||||
void ssh_blf_cbc_encrypt(ssh_blf_ctx *, uint8_t *, uint8_t *, uint32_t);
|
||||
void ssh_blf_cbc_decrypt(ssh_blf_ctx *, uint8_t *, uint8_t *, uint32_t);
|
||||
|
||||
/* Converts uint8_t to uint32_t */
|
||||
uint32_t Blowfish_stream2word(const uint8_t *, uint16_t , uint16_t *);
|
||||
|
4
src/external/bcrypt_pbkdf.c
поставляемый
4
src/external/bcrypt_pbkdf.c
поставляемый
@ -63,7 +63,7 @@
|
||||
static void
|
||||
bcrypt_hash(uint8_t *sha2pass, uint8_t *sha2salt, uint8_t *out)
|
||||
{
|
||||
blf_ctx state;
|
||||
ssh_blf_ctx state;
|
||||
uint8_t ciphertext[BCRYPT_HASHSIZE] =
|
||||
"OxychromaticBlowfishSwatDynamite";
|
||||
uint32_t cdata[BCRYPT_BLOCKS];
|
||||
@ -85,7 +85,7 @@ bcrypt_hash(uint8_t *sha2pass, uint8_t *sha2salt, uint8_t *out)
|
||||
cdata[i] = Blowfish_stream2word(ciphertext, sizeof(ciphertext),
|
||||
&j);
|
||||
for (i = 0; i < 64; i++)
|
||||
blf_enc(&state, cdata, sizeof(cdata) / sizeof(uint64_t));
|
||||
ssh_blf_enc(&state, cdata, sizeof(cdata) / sizeof(uint64_t));
|
||||
|
||||
/* copy out */
|
||||
for (i = 0; i < BCRYPT_BLOCKS; i++) {
|
||||
|
42
src/external/blowfish.c
поставляемый
42
src/external/blowfish.c
поставляемый
@ -70,7 +70,7 @@
|
||||
#define BLFRND(s,p,i,j,n) (i ^= F(s,j) ^ (p)[n])
|
||||
|
||||
void
|
||||
Blowfish_encipher(blf_ctx *c, uint32_t *xl, uint32_t *xr)
|
||||
Blowfish_encipher(ssh_blf_ctx *c, uint32_t *xl, uint32_t *xr)
|
||||
{
|
||||
uint32_t Xl;
|
||||
uint32_t Xr;
|
||||
@ -95,7 +95,7 @@ Blowfish_encipher(blf_ctx *c, uint32_t *xl, uint32_t *xr)
|
||||
}
|
||||
|
||||
void
|
||||
Blowfish_decipher(blf_ctx *c, uint32_t *xl, uint32_t *xr)
|
||||
Blowfish_decipher(ssh_blf_ctx *c, uint32_t *xl, uint32_t *xr)
|
||||
{
|
||||
uint32_t Xl;
|
||||
uint32_t Xr;
|
||||
@ -120,11 +120,11 @@ Blowfish_decipher(blf_ctx *c, uint32_t *xl, uint32_t *xr)
|
||||
}
|
||||
|
||||
void
|
||||
Blowfish_initstate(blf_ctx *c)
|
||||
Blowfish_initstate(ssh_blf_ctx *c)
|
||||
{
|
||||
/* P-box and S-box tables initialized with digits of Pi */
|
||||
|
||||
static const blf_ctx initstate =
|
||||
static const ssh_blf_ctx initstate =
|
||||
{ {
|
||||
{
|
||||
0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
|
||||
@ -420,7 +420,7 @@ Blowfish_stream2word(const uint8_t *data, uint16_t databytes,
|
||||
}
|
||||
|
||||
void
|
||||
Blowfish_expand0state(blf_ctx *c, const uint8_t *key, uint16_t keybytes)
|
||||
Blowfish_expand0state(ssh_blf_ctx *c, const uint8_t *key, uint16_t keybytes)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t j;
|
||||
@ -458,7 +458,7 @@ Blowfish_expand0state(blf_ctx *c, const uint8_t *key, uint16_t keybytes)
|
||||
|
||||
|
||||
void
|
||||
Blowfish_expandstate(blf_ctx *c, const uint8_t *data, uint16_t databytes,
|
||||
Blowfish_expandstate(ssh_blf_ctx *c, const uint8_t *data, uint16_t databytes,
|
||||
const uint8_t *key, uint16_t keybytes)
|
||||
{
|
||||
uint16_t i;
|
||||
@ -501,7 +501,7 @@ Blowfish_expandstate(blf_ctx *c, const uint8_t *data, uint16_t databytes,
|
||||
}
|
||||
|
||||
void
|
||||
blf_key(blf_ctx *c, const uint8_t *k, uint16_t len)
|
||||
ssh_blf_key(ssh_blf_ctx *c, const uint8_t *k, uint16_t len)
|
||||
{
|
||||
/* Initialize S-boxes and subkeys with Pi */
|
||||
Blowfish_initstate(c);
|
||||
@ -511,7 +511,7 @@ blf_key(blf_ctx *c, const uint8_t *k, uint16_t len)
|
||||
}
|
||||
|
||||
void
|
||||
blf_enc(blf_ctx *c, uint32_t *data, uint16_t blocks)
|
||||
ssh_blf_enc(ssh_blf_ctx *c, uint32_t *data, uint16_t blocks)
|
||||
{
|
||||
uint32_t *d;
|
||||
uint16_t i;
|
||||
@ -524,7 +524,7 @@ blf_enc(blf_ctx *c, uint32_t *data, uint16_t blocks)
|
||||
}
|
||||
|
||||
void
|
||||
blf_dec(blf_ctx *c, uint32_t *data, uint16_t blocks)
|
||||
ssh_blf_dec(ssh_blf_ctx *c, uint32_t *data, uint16_t blocks)
|
||||
{
|
||||
uint32_t *d;
|
||||
uint16_t i;
|
||||
@ -537,7 +537,7 @@ blf_dec(blf_ctx *c, uint32_t *data, uint16_t blocks)
|
||||
}
|
||||
|
||||
void
|
||||
blf_ecb_encrypt(blf_ctx *c, uint8_t *data, uint32_t len)
|
||||
ssh_blf_ecb_encrypt(ssh_blf_ctx *c, uint8_t *data, uint32_t len)
|
||||
{
|
||||
uint32_t l, r;
|
||||
uint32_t i;
|
||||
@ -559,7 +559,7 @@ blf_ecb_encrypt(blf_ctx *c, uint8_t *data, uint32_t len)
|
||||
}
|
||||
|
||||
void
|
||||
blf_ecb_decrypt(blf_ctx *c, uint8_t *data, uint32_t len)
|
||||
ssh_blf_ecb_decrypt(ssh_blf_ctx *c, uint8_t *data, uint32_t len)
|
||||
{
|
||||
uint32_t l, r;
|
||||
uint32_t i;
|
||||
@ -581,7 +581,7 @@ blf_ecb_decrypt(blf_ctx *c, uint8_t *data, uint32_t len)
|
||||
}
|
||||
|
||||
void
|
||||
blf_cbc_encrypt(blf_ctx *c, uint8_t *iv, uint8_t *data, uint32_t len)
|
||||
ssh_blf_cbc_encrypt(ssh_blf_ctx *c, uint8_t *iv, uint8_t *data, uint32_t len)
|
||||
{
|
||||
uint32_t l, r;
|
||||
uint32_t i, j;
|
||||
@ -606,7 +606,7 @@ blf_cbc_encrypt(blf_ctx *c, uint8_t *iv, uint8_t *data, uint32_t len)
|
||||
}
|
||||
|
||||
void
|
||||
blf_cbc_decrypt(blf_ctx *c, uint8_t *iva, uint8_t *data, uint32_t len)
|
||||
ssh_blf_cbc_decrypt(ssh_blf_ctx *c, uint8_t *iva, uint8_t *data, uint32_t len)
|
||||
{
|
||||
uint32_t l, r;
|
||||
uint8_t *iv;
|
||||
@ -659,7 +659,7 @@ void
|
||||
main(void)
|
||||
{
|
||||
|
||||
blf_ctx c;
|
||||
ssh_blf_ctx c;
|
||||
char key[] = "AAAAA";
|
||||
char key2[] = "abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
@ -673,19 +673,19 @@ main(void)
|
||||
for (i = 0; i < 10; i++)
|
||||
data[i] = i;
|
||||
|
||||
blf_key(&c, (uint8_t *) key, 5);
|
||||
blf_enc(&c, data, 5);
|
||||
blf_dec(&c, data, 1);
|
||||
blf_dec(&c, data + 2, 4);
|
||||
ssh_blf_key(&c, (uint8_t *) key, 5);
|
||||
ssh_blf_enc(&c, data, 5);
|
||||
ssh_blf_dec(&c, data, 1);
|
||||
ssh_blf_dec(&c, data + 2, 4);
|
||||
printf("Should read as 0 - 9.\n");
|
||||
report(data, 10);
|
||||
|
||||
/* Second test */
|
||||
blf_key(&c, (uint8_t *) key2, strlen(key2));
|
||||
blf_enc(&c, data2, 1);
|
||||
ssh_blf_key(&c, (uint8_t *) key2, strlen(key2));
|
||||
ssh_blf_enc(&c, data2, 1);
|
||||
printf("\nShould read as: 0x324ed0fe 0xf413a203.\n");
|
||||
report(data2, 2);
|
||||
blf_dec(&c, data2, 1);
|
||||
ssh_blf_dec(&c, data2, 1);
|
||||
report(data2, 2);
|
||||
}
|
||||
#endif
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user