sha512_block_ppc(ctx, inp, len);
}
+void ChaCha20_ctr32_int(unsigned char *out, const unsigned char *inp,
+ size_t len, const unsigned int key[8],
+ const unsigned int counter[4]);
+void ChaCha20_ctr32_vmx(unsigned char *out, const unsigned char *inp,
+ size_t len, const unsigned int key[8],
+ const unsigned int counter[4]);
+void ChaCha20_ctr32(unsigned char *out, const unsigned char *inp,
+ size_t len, const unsigned int key[8],
+ const unsigned int counter[4])
+{
+ OPENSSL_ppccap_P & PPC_ALTIVEC
+ ? ChaCha20_ctr32_vmx(out, inp, len, key, counter)
+ : ChaCha20_ctr32_int(out, inp, len, key, counter);
+}
+
+void poly1305_init_int(void *ctx, const unsigned char key[16]);
+void poly1305_blocks(void *ctx, const unsigned char *inp, size_t len,
+ unsigned int padbit);
+void poly1305_emit(void *ctx, unsigned char mac[16],
+ const unsigned int nonce[4]);
+void poly1305_init_fpu(void *ctx, const unsigned char key[16]);
+void poly1305_blocks_fpu(void *ctx, const unsigned char *inp, size_t len,
+ unsigned int padbit);
+void poly1305_emit_fpu(void *ctx, unsigned char mac[16],
+ const unsigned int nonce[4]);
+int poly1305_init(void *ctx, const unsigned char key[16], void *func[2])
+{
+ if (sizeof(size_t) == 4 && (OPENSSL_ppccap_P & PPC_FPU)) {
+ poly1305_init_fpu(ctx,key);
+ func[0] = poly1305_blocks_fpu;
+ func[1] = poly1305_emit_fpu;
+ } else {
+ poly1305_init_int(ctx,key);
+ func[0] = poly1305_blocks;
+ func[1] = poly1305_emit;
+ }
+ return 1;
+}
+
static sigjmp_buf ill_jmp;
static void ill_handler(int sig)
{
#define HWCAP2 26 /* AT_HWCAP2 */
#define HWCAP_VEC_CRYPTO (1U << 25)
+#define HWCAP_ARCH_3_00 (1U << 23)
# if defined(__GNUC__) && __GNUC__>=2
__attribute__ ((constructor))
if (__power_set(0xffffffffU<<16)) /* POWER8 and later */
OPENSSL_ppccap_P |= PPC_CRYPTO207;
+ if (__power_set(0xffffffffU<<17)) /* POWER9 and later */
+ OPENSSL_ppccap_P |= PPC_MADD300;
+
return;
# endif
#endif
OPENSSL_ppccap_P |= PPC_CRYPTO207;
}
+ if (hwcap & HWCAP_ARCH_3_00) {
+ OPENSSL_ppccap_P |= PPC_MADD300;
+ }
+
return;
}
}
}
+ if (sigsetjmp(ill_jmp, 1) == 0) {
+ OPENSSL_madd300_probe();
+ OPENSSL_ppccap_P |= PPC_MADD300;
+ }
+
sigaction(SIGILL, &ill_oact, NULL);
sigprocmask(SIG_SETMASK, &oset, NULL);
}