Changeset View
Changeset View
Standalone View
Standalone View
cipher/cipher-gcm.c
| Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | |||||
| ghash_armv7_neon (gcry_cipher_hd_t c, byte *result, const byte *buf, | ghash_armv7_neon (gcry_cipher_hd_t c, byte *result, const byte *buf, | ||||
| size_t nblocks) | size_t nblocks) | ||||
| { | { | ||||
| return _gcry_ghash_armv7_neon(c->u_mode.gcm.u_ghash_key.key, result, buf, | return _gcry_ghash_armv7_neon(c->u_mode.gcm.u_ghash_key.key, result, buf, | ||||
| nblocks); | nblocks); | ||||
| } | } | ||||
| #endif /* GCM_USE_ARM_NEON */ | #endif /* GCM_USE_ARM_NEON */ | ||||
| #ifdef GCM_USE_PPC_VPMSUM | |||||
| extern void _gcry_ghash_setup_ppc_vpmsum (void *gcm_table, void *gcm_key); | |||||
| /* result is 128-bits */ | |||||
| extern unsigned int _gcry_ghash_ppc_vpmsum (byte *result, void *gcm_table, | |||||
| const byte *buf, size_t nblocks); | |||||
| static void | |||||
| ghash_setup_ppc_vpmsum (gcry_cipher_hd_t c) | |||||
| { | |||||
| _gcry_ghash_setup_ppc_vpmsum(c->u_mode.gcm.gcm_table, c->u_mode.gcm.u_ghash_key.key); | |||||
| } | |||||
| static unsigned int | |||||
| ghash_ppc_vpmsum (gcry_cipher_hd_t c, byte *result, const byte *buf, | |||||
| size_t nblocks) | |||||
| { | |||||
| unsigned __int128 *where = (unsigned __int128*)result; | |||||
| _gcry_ghash_ppc_vpmsum(result, c->u_mode.gcm.gcm_table, buf, | |||||
| nblocks); | |||||
| return 0; | |||||
| } | |||||
| #endif /* GCM_USE_PPC_VPMSUM */ | |||||
| #ifdef GCM_USE_TABLES | #ifdef GCM_USE_TABLES | ||||
| static struct | static struct | ||||
| { | { | ||||
| volatile u32 counter_head; | volatile u32 counter_head; | ||||
| u32 cacheline_align[64 / 4 - 1]; | u32 cacheline_align[64 / 4 - 1]; | ||||
| u16 R[256]; | u16 R[256]; | ||||
| volatile u32 counter_tail; | volatile u32 counter_tail; | ||||
| ▲ Show 20 Lines • Show All 417 Lines • ▼ Show 20 Lines | ghash_internal (gcry_cipher_hd_t c, byte *result, const byte *buf, | ||||
| return burn + (burn ? 5*sizeof(void*) : 0); | return burn + (burn ? 5*sizeof(void*) : 0); | ||||
| } | } | ||||
| static void | static void | ||||
| setupM (gcry_cipher_hd_t c) | setupM (gcry_cipher_hd_t c) | ||||
| { | { | ||||
| #if defined(GCM_USE_INTEL_PCLMUL) || defined(GCM_USE_ARM_PMULL) | #if defined(GCM_USE_INTEL_PCLMUL) || defined(GCM_USE_ARM_PMULL) || defined(GCM_USE_PPC_VPMSUM) | ||||
| unsigned int features = _gcry_get_hw_features (); | unsigned int features = _gcry_get_hw_features (); | ||||
| #endif | #endif | ||||
| if (0) | if (0) | ||||
| ; | ; | ||||
| #ifdef GCM_USE_INTEL_PCLMUL | #ifdef GCM_USE_INTEL_PCLMUL | ||||
| else if (features & HWF_INTEL_PCLMUL) | else if (features & HWF_INTEL_PCLMUL) | ||||
| { | { | ||||
| Show All 10 Lines | |||||
| #endif | #endif | ||||
| #ifdef GCM_USE_ARM_NEON | #ifdef GCM_USE_ARM_NEON | ||||
| else if (features & HWF_ARM_NEON) | else if (features & HWF_ARM_NEON) | ||||
| { | { | ||||
| c->u_mode.gcm.ghash_fn = ghash_armv7_neon; | c->u_mode.gcm.ghash_fn = ghash_armv7_neon; | ||||
| ghash_setup_armv7_neon (c); | ghash_setup_armv7_neon (c); | ||||
| } | } | ||||
| #endif | #endif | ||||
| #ifdef GCM_USE_PPC_VPMSUM | |||||
| else if (features & HWF_PPC_VCRYPTO) | |||||
| { | |||||
| c->u_mode.gcm.ghash_fn = ghash_ppc_vpmsum; | |||||
| ghash_setup_ppc_vpmsum (c); | |||||
| } | |||||
| #endif | |||||
| else | else | ||||
| { | { | ||||
| c->u_mode.gcm.ghash_fn = ghash_internal; | c->u_mode.gcm.ghash_fn = ghash_internal; | ||||
| fillM (c); | fillM (c); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 586 Lines • Show Last 20 Lines | |||||