Commit 4a0ac184 authored by Benjamin Beurdouche's avatar Benjamin Beurdouche

Bug 1613235 - Clang-format for: POWER ChaCha20 stream cipher vector acceleration r=beurdouche

Depends on D107221

Differential Revision: https://phabricator.services.mozilla.com/D107788

--HG--
extra : moz-landing-system : lando
parent 983a0148
......@@ -803,7 +803,7 @@ struct bltestCipherInfoStr {
PRBool
is_symmkeyCipher(bltestCipherMode mode)
{
/* change as needed! */
/* change as needed! */
if (mode >= bltestDES_ECB && mode <= bltestCHACHA20_CTR)
return PR_TRUE;
return PR_FALSE;
......@@ -1153,8 +1153,8 @@ aes_Decrypt(void *cx, unsigned char *output, unsigned int *outputLen,
SECStatus
chacha20_Encrypt(void *cx, unsigned char *output, unsigned int *outputLen,
unsigned int maxOutputLen, const unsigned char *input,
unsigned int inputLen)
unsigned int maxOutputLen, const unsigned char *input,
unsigned int inputLen)
{
if (maxOutputLen < inputLen) {
PORT_SetError(SEC_ERROR_OUTPUT_LEN);
......@@ -1164,7 +1164,6 @@ chacha20_Encrypt(void *cx, unsigned char *output, unsigned int *outputLen,
*outputLen = inputLen;
return ChaCha20_Xor(output, input, inputLen, ctx->key, ctx->nonce,
ctx->counter);
}
SECStatus
......@@ -1681,7 +1680,7 @@ bltest_chacha20_ctr_init(bltestCipherInfo *cipherInfo, PRBool encrypt)
sk->iv.buf.data, sk->iv.buf.len,
counter);
if (cipherInfo->cx == NULL){
if (cipherInfo->cx == NULL) {
PR_fprintf(PR_STDERR, "ChaCha20_CreateContext() returned NULL\n"
"key must be 32 bytes, iv must be 12 bytes\n");
return SECFailure;
......@@ -2749,10 +2748,10 @@ getHighUnitBytes(PRInt64 res)
}
}
if (i==0)
if (i == 0)
return PR_smprintf("%d%s", spl[i], marks[i]);
else
return PR_smprintf("%d%s %d%s", spl[i], marks[i], spl[i-1], marks[i-1]);
return PR_smprintf("%d%s %d%s", spl[i], marks[i], spl[i - 1], marks[i - 1]);
}
static void
......
......@@ -1061,7 +1061,6 @@ extern ChaCha20Context *ChaCha20_CreateContext(const unsigned char *key,
extern void ChaCha20_DestroyContext(ChaCha20Context *ctx, PRBool freeit);
/******************************************/
/*
** ChaCha20+Poly1305 AEAD
......
......@@ -25,7 +25,7 @@
/* Forward declaration from chacha20-ppc64le.S */
void chacha20vsx(uint32_t len, uint8_t *output, uint8_t *block, uint8_t *k,
uint8_t *nonce, uint32_t ctr);
uint8_t *nonce, uint32_t ctr);
static inline void
poly1305_padded_32(uint64_t *ctx, uint32_t len, uint8_t *text)
......
......@@ -71,7 +71,7 @@ Hacl_Chacha20Poly1305_32_aead_decrypt(uint8_t *k, uint8_t *n1, uint32_t aadlen,
// Forward declaration from chacha20-ppc64le.S
void chacha20vsx(uint32_t len, uint8_t *output, uint8_t *block, uint8_t *k,
uint8_t *nonce, uint32_t ctr);
uint8_t *nonce, uint32_t ctr);
// Forward declaration from chacha20poly1305-ppc.c
extern void
......@@ -219,8 +219,8 @@ ChaCha20Xor(uint8_t *output, uint8_t *block, uint32_t len, uint8_t *k,
#endif
} else
#elif defined(__powerpc64__) && defined(__LITTLE_ENDIAN__) && \
!defined(NSS_DISABLE_ALTIVEC) && !defined(NSS_DISABLE_CRYPTO_VSX)
if (__builtin_cpu_supports ("vsx")) {
!defined(NSS_DISABLE_ALTIVEC) && !defined(NSS_DISABLE_CRYPTO_VSX)
if (__builtin_cpu_supports("vsx")) {
chacha20vsx(len, output, block, k, nonce, ctr);
} else
#endif
......@@ -292,8 +292,8 @@ ChaCha20Poly1305_Seal(const ChaCha20Poly1305Context *ctx, unsigned char *output,
#endif
} else
#elif defined(__powerpc64__) && defined(__LITTLE_ENDIAN__) && \
!defined(NSS_DISABLE_ALTIVEC) && !defined(NSS_DISABLE_CRYPTO_VSX)
if (__builtin_cpu_supports ("vsx")) {
!defined(NSS_DISABLE_ALTIVEC) && !defined(NSS_DISABLE_CRYPTO_VSX)
if (__builtin_cpu_supports("vsx")) {
Chacha20Poly1305_vsx_aead_encrypt(
(uint8_t *)ctx->key, (uint8_t *)nonce, adLen, (uint8_t *)ad, inputLen,
(uint8_t *)input, output, output + inputLen);
......@@ -361,8 +361,8 @@ ChaCha20Poly1305_Open(const ChaCha20Poly1305Context *ctx, unsigned char *output,
#endif
} else
#elif defined(__powerpc64__) && defined(__LITTLE_ENDIAN__) && \
!defined(NSS_DISABLE_ALTIVEC) && !defined(NSS_DISABLE_CRYPTO_VSX)
if (__builtin_cpu_supports ("vsx")) {
!defined(NSS_DISABLE_ALTIVEC) && !defined(NSS_DISABLE_CRYPTO_VSX)
if (__builtin_cpu_supports("vsx")) {
res = Chacha20Poly1305_vsx_aead_decrypt(
(uint8_t *)ctx->key, (uint8_t *)nonce, adLen, (uint8_t *)ad, ciphertextLen,
(uint8_t *)output, (uint8_t *)input, (uint8_t *)input + ciphertextLen);
......@@ -417,8 +417,8 @@ ChaCha20Poly1305_Encrypt(const ChaCha20Poly1305Context *ctx,
(uint8_t *)input, output, outTag);
} else
#elif defined(__powerpc64__) && defined(__LITTLE_ENDIAN__) && \
!defined(NSS_DISABLE_ALTIVEC) && !defined(NSS_DISABLE_CRYPTO_VSX)
if (__builtin_cpu_supports ("vsx")) {
!defined(NSS_DISABLE_ALTIVEC) && !defined(NSS_DISABLE_CRYPTO_VSX)
if (__builtin_cpu_supports("vsx")) {
Chacha20Poly1305_vsx_aead_encrypt(
(uint8_t *)ctx->key, (uint8_t *)nonce, adLen, (uint8_t *)ad, inputLen,
(uint8_t *)input, output, outTag);
......@@ -471,8 +471,8 @@ ChaCha20Poly1305_Decrypt(const ChaCha20Poly1305Context *ctx,
(uint8_t *)output, (uint8_t *)input, (uint8_t *)tagIn);
} else
#elif defined(__powerpc64__) && defined(__LITTLE_ENDIAN__) && \
!defined(NSS_DISABLE_ALTIVEC) && !defined(NSS_DISABLE_CRYPTO_VSX)
if (__builtin_cpu_supports ("vsx")) {
!defined(NSS_DISABLE_ALTIVEC) && !defined(NSS_DISABLE_CRYPTO_VSX)
if (__builtin_cpu_supports("vsx")) {
res = Chacha20Poly1305_vsx_aead_decrypt(
(uint8_t *)ctx->key, (uint8_t *)nonce, adLen, (uint8_t *)ad, ciphertextLen,
(uint8_t *)output, (uint8_t *)input, (uint8_t *)tagIn);
......
......@@ -2160,10 +2160,10 @@ ChaCha20_Xor(unsigned char *output, const unsigned char *block, unsigned int len
SECStatus
ChaCha20_InitContext(ChaCha20Context *ctx, const unsigned char *key,
unsigned int keyLen,
const unsigned char *nonce,
unsigned int nonceLen,
PRUint32 ctr)
unsigned int keyLen,
const unsigned char *nonce,
unsigned int nonceLen,
PRUint32 ctr)
{
if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
return SECFailure;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment