Skip to content

Commit

Permalink
bks, pfx, zed, sappse: switch onto specific simd interface for pkcs12
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekseyCherepanov authored and solardiz committed May 21, 2022
1 parent 7f5b21b commit 7e20cba
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/bks_fmt_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ static int crypt_all(int *pcount, struct db_salt *salt)

for (j = 0; j < SSE_GROUP_SZ_SHA1; ++j)
mackey[j] = real_keys[j];
pkcs12_pbe_derive_key_simd(1, cur_salt->iteration_count,
pkcs12_pbe_derive_key_simd_sha1(cur_salt->iteration_count,
MBEDTLS_PKCS12_DERIVE_MAC_KEY,
keys, lens, cur_salt->salt,
cur_salt->saltlen, mackey, mackeylen);
Expand Down Expand Up @@ -361,15 +361,15 @@ static int crypt_all(int *pcount, struct db_salt *salt)
iv[j] = iv_[j];
ckey[j] = ckey_[j];
}
pkcs12_pbe_derive_key_simd(1, cur_salt->iteration_count,
pkcs12_pbe_derive_key_simd_sha1(cur_salt->iteration_count,
MBEDTLS_PKCS12_DERIVE_IV,
keys,
lens, cur_salt->salt,
cur_salt->saltlen, iv, 16);
// lengths get tromped on, so re-load them for the load keys call.
for (j = 0; j < SSE_GROUP_SZ_SHA1; ++j)
lens[j] = saved_len[index+j];
pkcs12_pbe_derive_key_simd(1, cur_salt->iteration_count,
pkcs12_pbe_derive_key_simd_sha1(cur_salt->iteration_count,
MBEDTLS_PKCS12_DERIVE_KEY,
keys,
lens, cur_salt->salt,
Expand Down
6 changes: 3 additions & 3 deletions src/pfx_fmt_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ static int crypt_all(int *pcount, struct db_salt *salt)
lens[j] = saved_len[index+j];
keys[j] = (const unsigned char*)(saved_key[index+j]);
}
pkcs12_pbe_derive_key_simd(cur_salt->mac_algo, cur_salt->iteration_count,
pkcs12_pbe_derive_key_simd_sha1(cur_salt->iteration_count,
MBEDTLS_PKCS12_DERIVE_MAC_KEY, keys,
lens, cur_salt->salt,
cur_salt->saltlen, mackey, mackeylen);
Expand All @@ -242,7 +242,7 @@ static int crypt_all(int *pcount, struct db_salt *salt)
lens[j] = saved_len[index+j];
keys[j] = (const unsigned char*)(saved_key[index+j]);
}
pkcs12_pbe_derive_key_simd(cur_salt->mac_algo, cur_salt->iteration_count,
pkcs12_pbe_derive_key_simd_sha256(cur_salt->iteration_count,
MBEDTLS_PKCS12_DERIVE_MAC_KEY, keys,
lens, cur_salt->salt,
cur_salt->saltlen, mackey, mackeylen);
Expand All @@ -265,7 +265,7 @@ static int crypt_all(int *pcount, struct db_salt *salt)
lens[j] = saved_len[index+j];
keys[j] = (const unsigned char*)(saved_key[index+j]);
}
pkcs12_pbe_derive_key_simd(cur_salt->mac_algo, cur_salt->iteration_count,
pkcs12_pbe_derive_key_simd_sha512(cur_salt->iteration_count,
MBEDTLS_PKCS12_DERIVE_MAC_KEY, keys,
lens, cur_salt->salt,
cur_salt->saltlen, mackey, mackeylen);
Expand Down
4 changes: 2 additions & 2 deletions src/sap_pse_fmt_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ static int crypt_all(int *pcount, struct db_salt *salt)
pout[i] = key[i];
iout[i] = iv[i];
}
pkcs12_pbe_derive_key_simd(1,
pkcs12_pbe_derive_key_simd_sha1(
cur_salt->iterations,
MBEDTLS_PKCS12_DERIVE_KEY, (const unsigned char **)pin, lens,
cur_salt->salt, cur_salt->salt_size, pout, 24);

pkcs12_pbe_derive_key_simd(1,
pkcs12_pbe_derive_key_simd_sha1(
cur_salt->iterations,
MBEDTLS_PKCS12_DERIVE_IV, (const unsigned char **)pin, clens,
cur_salt->salt, cur_salt->salt_size, iout, 8);
Expand Down
12 changes: 8 additions & 4 deletions src/zed_fmt_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,21 @@ static int crypt_all(int *pcount, struct db_salt *salt)
int index;
const int count = *pcount;
int inc = 1;
#if !defined(SIMD_COEF_32)
int algo = 0;
#endif

if (cur_salt->algo == 21) {
algo = 1;
#if defined(SIMD_COEF_32)
inc = SSE_GROUP_SZ_SHA1;
#else
algo = 1;
#endif
} else if (cur_salt->algo == 22) {
algo = 256;
#if defined(SIMD_COEF_32)
inc = SSE_GROUP_SZ_SHA256;
#else
algo = 256;
#endif
}

Expand Down Expand Up @@ -132,7 +136,7 @@ static int crypt_all(int *pcount, struct db_salt *salt)
lens[j] = saved_len[index + j];
keys[j] = (const unsigned char*)(saved_key[index + j]);
}
pkcs12_pbe_derive_key_simd(algo, cur_salt->iteration_count,
pkcs12_pbe_derive_key_simd_sha1(cur_salt->iteration_count,
MBEDTLS_PKCS12_DERIVE_MAC_KEY, keys,
lens, cur_salt->salt,
salt_len, mackey,
Expand All @@ -147,7 +151,7 @@ static int crypt_all(int *pcount, struct db_salt *salt)
lens[j] = saved_len[index + j];
keys[j] = (const unsigned char*)(saved_key[index + j]);
}
pkcs12_pbe_derive_key_simd(algo, cur_salt->iteration_count,
pkcs12_pbe_derive_key_simd_sha256(cur_salt->iteration_count,
MBEDTLS_PKCS12_DERIVE_MAC_KEY, keys,
lens, cur_salt->salt,
salt_len, mackey,
Expand Down

0 comments on commit 7e20cba

Please sign in to comment.