Changeset 94082 in vbox for trunk/src/libs/openssl-3.0.1/crypto/ppccap.c
- Timestamp:
- Mar 3, 2022 7:17:34 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 150325
- Location:
- trunk/src/libs/openssl-3.0.1
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/openssl-3.0.1
- Property svn:mergeinfo
-
old new 12 12 /vendor/openssl/1.1.1c:131722-131725 13 13 /vendor/openssl/1.1.1k:145841-145843 14 /vendor/openssl/3.0.1:150323-150324 15 /vendor/openssl/current:147554-150322
-
- Property svn:mergeinfo
-
trunk/src/libs/openssl-3.0.1/crypto/ppccap.c
r91772 r94082 2 2 * Copyright 2009-2021 The OpenSSL Project Authors. All Rights Reserved. 3 3 * 4 * Licensed under the OpenSSL license(the "License"). You may not use4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 5 * this file except in compliance with the License. You can obtain a copy 6 6 * in the file LICENSE in the source distribution or at … … 28 28 #endif 29 29 #include <openssl/crypto.h> 30 #include <openssl/bn.h> 31 #include <internal/cryptlib.h> 32 #include <crypto/chacha.h> 33 #include "bn/bn_local.h" 34 35 #include "ppc_arch.h" 30 #include "internal/cryptlib.h" 31 #include "crypto/ppc_arch.h" 36 32 37 33 unsigned int OPENSSL_ppccap_P = 0; 38 34 39 35 static sigset_t all_masked; 40 41 #ifdef OPENSSL_BN_ASM_MONT42 int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,43 const BN_ULONG *np, const BN_ULONG *n0, int num)44 {45 int bn_mul_mont_int(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,46 const BN_ULONG *np, const BN_ULONG *n0, int num);47 int bn_mul4x_mont_int(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,48 const BN_ULONG *np, const BN_ULONG *n0, int num);49 50 if (num < 4)51 return 0;52 53 if ((num & 3) == 0)54 return bn_mul4x_mont_int(rp, ap, bp, np, n0, num);55 56 /*57 * There used to be [optional] call to bn_mul_mont_fpu64 here,58 * but above subroutine is faster on contemporary processors.59 * Formulation means that there might be old processors where60 * FPU code path would be faster, POWER6 perhaps, but there was61 * no opportunity to figure it out...62 */63 64 return bn_mul_mont_int(rp, ap, bp, np, n0, num);65 }66 #endif67 68 void sha256_block_p8(void *ctx, const void *inp, size_t len);69 void sha256_block_ppc(void *ctx, const void *inp, size_t len);70 void sha256_block_data_order(void *ctx, const void *inp, size_t len);71 void sha256_block_data_order(void *ctx, const void *inp, size_t len)72 {73 OPENSSL_ppccap_P & PPC_CRYPTO207 ? sha256_block_p8(ctx, inp, len) :74 sha256_block_ppc(ctx, inp, len);75 }76 77 void sha512_block_p8(void *ctx, const void *inp, size_t len);78 void sha512_block_ppc(void *ctx, const void *inp, size_t len);79 void sha512_block_data_order(void *ctx, const void *inp, size_t len);80 void sha512_block_data_order(void *ctx, const void *inp, size_t len)81 {82 OPENSSL_ppccap_P & PPC_CRYPTO207 ? sha512_block_p8(ctx, inp, len) :83 sha512_block_ppc(ctx, inp, len);84 }85 86 #ifndef OPENSSL_NO_CHACHA87 void ChaCha20_ctr32_int(unsigned char *out, const unsigned char *inp,88 size_t len, const unsigned int key[8],89 const unsigned int counter[4]);90 void ChaCha20_ctr32_vmx(unsigned char *out, const unsigned char *inp,91 size_t len, const unsigned int key[8],92 const unsigned int counter[4]);93 void ChaCha20_ctr32_vsx(unsigned char *out, const unsigned char *inp,94 size_t len, const unsigned int key[8],95 const unsigned int counter[4]);96 void ChaCha20_ctr32(unsigned char *out, const unsigned char *inp,97 size_t len, const unsigned int key[8],98 const unsigned int counter[4])99 {100 OPENSSL_ppccap_P & PPC_CRYPTO207101 ? ChaCha20_ctr32_vsx(out, inp, len, key, counter)102 : OPENSSL_ppccap_P & PPC_ALTIVEC103 ? ChaCha20_ctr32_vmx(out, inp, len, key, counter)104 : ChaCha20_ctr32_int(out, inp, len, key, counter);105 }106 #endif107 108 #ifndef OPENSSL_NO_POLY1305109 void poly1305_init_int(void *ctx, const unsigned char key[16]);110 void poly1305_blocks(void *ctx, const unsigned char *inp, size_t len,111 unsigned int padbit);112 void poly1305_emit(void *ctx, unsigned char mac[16],113 const unsigned int nonce[4]);114 void poly1305_init_fpu(void *ctx, const unsigned char key[16]);115 void poly1305_blocks_fpu(void *ctx, const unsigned char *inp, size_t len,116 unsigned int padbit);117 void poly1305_emit_fpu(void *ctx, unsigned char mac[16],118 const unsigned int nonce[4]);119 int poly1305_init(void *ctx, const unsigned char key[16], void *func[2]);120 int poly1305_init(void *ctx, const unsigned char key[16], void *func[2])121 {122 if (sizeof(size_t) == 4 && (OPENSSL_ppccap_P & PPC_FPU)) {123 poly1305_init_fpu(ctx, key);124 func[0] = (void*)(uintptr_t)poly1305_blocks_fpu;125 func[1] = (void*)(uintptr_t)poly1305_emit_fpu;126 } else {127 poly1305_init_int(ctx, key);128 func[0] = (void*)(uintptr_t)poly1305_blocks;129 func[1] = (void*)(uintptr_t)poly1305_emit;130 }131 return 1;132 }133 #endif134 135 #ifdef ECP_NISTZ256_ASM136 void ecp_nistz256_mul_mont(unsigned long res[4], const unsigned long a[4],137 const unsigned long b[4]);138 139 void ecp_nistz256_to_mont(unsigned long res[4], const unsigned long in[4]);140 void ecp_nistz256_to_mont(unsigned long res[4], const unsigned long in[4])141 {142 static const unsigned long RR[] = { 0x0000000000000003U,143 0xfffffffbffffffffU,144 0xfffffffffffffffeU,145 0x00000004fffffffdU };146 147 ecp_nistz256_mul_mont(res, in, RR);148 }149 150 void ecp_nistz256_from_mont(unsigned long res[4], const unsigned long in[4]);151 void ecp_nistz256_from_mont(unsigned long res[4], const unsigned long in[4])152 {153 static const unsigned long one[] = { 1, 0, 0, 0 };154 155 ecp_nistz256_mul_mont(res, in, one);156 }157 #endif158 36 159 37 static sigjmp_buf ill_jmp;
Note:
See TracChangeset
for help on using the changeset viewer.