在Andrew Carter的Blowfish密码的实现中,一个函数使用参数*keyparam
并将其复制到变量*key
。
void blowfish_initiate(blowfish_context_t *ctx, void *keyparam, unsigned int keybytes)
{
keybytes %= 57;
unsigned char *key = keyparam; // How is this possible?
int i, j, k;
unsigned long calc;
// ...code...
if(keybytes) {
for(i = 0, j = 0; i < 18; i++) {
for(k = 0, calc = 0; k < 4; k++) {
calc <<= 8, calc |= key[j++];
if(j == keybytes)
j = 0;
}
ctx->pbox[i] ^= calc;
}
}
// ...code...
}
keyparam
void
是如何实现的?
我知道函数可以有void参数,但可以使用吗?