2
0

chacha_ppc.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright 2009-2023 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <openssl/opensslconf.h>
  12. #include "crypto/chacha.h"
  13. #include "crypto/ppc_arch.h"
  14. void ChaCha20_ctr32_int(unsigned char *out, const unsigned char *inp,
  15. size_t len, const unsigned int key[8],
  16. const unsigned int counter[4]);
  17. void ChaCha20_ctr32_vmx(unsigned char *out, const unsigned char *inp,
  18. size_t len, const unsigned int key[8],
  19. const unsigned int counter[4]);
  20. void ChaCha20_ctr32_vsx(unsigned char *out, const unsigned char *inp,
  21. size_t len, const unsigned int key[8],
  22. const unsigned int counter[4]);
  23. void ChaCha20_ctr32_vsx_p10(unsigned char *out, const unsigned char *inp,
  24. size_t len, const unsigned int key[8],
  25. const unsigned int counter[4]);
  26. void ChaCha20_ctr32(unsigned char *out, const unsigned char *inp,
  27. size_t len, const unsigned int key[8],
  28. const unsigned int counter[4])
  29. {
  30. #if !defined(OPENSSL_SYS_AIX) && !defined(OPENSSL_SYS_MACOSX)
  31. OPENSSL_ppccap_P & PPC_BRD31
  32. ? ChaCha20_ctr32_vsx_p10(out, inp, len, key, counter) :
  33. #endif
  34. OPENSSL_ppccap_P & PPC_CRYPTO207
  35. ? ChaCha20_ctr32_vsx(out, inp, len, key, counter)
  36. : OPENSSL_ppccap_P & PPC_ALTIVEC
  37. ? ChaCha20_ctr32_vmx(out, inp, len, key, counter)
  38. : ChaCha20_ctr32_int(out, inp, len, key, counter);
  39. }