Skip to content
Snippets Groups Projects
Select Git revision
  • ade7779c98a5426c7d86c8a01bbd7ad65980c9b9
  • master default protected
  • streebog
  • gost28147
  • master-updates
  • ed448
  • shake256
  • curve448
  • ecc-sqrt
  • gosthash94cp
  • cmac64
  • block16-refactor
  • siv-mode
  • cmac-layout
  • delete-des-compat
  • delete-rsa_blind
  • aes-struct-layout
  • release-3.4-fixes
  • struct-layout
  • attribute-deprecated
  • rename-data-symbols
  • nettle_3.5.1_release_20190627
  • nettle_3.5_release_20190626
  • nettle_3.5rc1
  • nettle_3.4.1_release_20181204
  • nettle_3.4.1rc1
  • nettle_3.4_release_20171119
  • nettle_3.4rc2
  • nettle_3.4rc1
  • nettle_3.3_release_20161001
  • nettle_3.2_release_20160128
  • nettle_3.1.1_release_20150424
  • nettle_3.1_release_20150407
  • nettle_3.1rc3
  • nettle_3.1rc2
  • nettle_3.1rc1
  • nettle_3.0_release_20140607
  • nettle_2.7.1_release_20130528
  • nettle_2.7_release_20130424
  • nettle_2.6_release_20130116
  • nettle_2.5_release_20120707
41 results

aes-decrypt-internal.asm

Blame
  • Forked from Nettle / nettle
    1983 commits behind the upstream repository.
    Niels Möller's avatar
    Niels Möller authored
    Renamed directory armv7 to arm. New subdirectory arm/neon, for files
    using neon instructions. configure.ac hacked to make use of neon
    configurable.
    ade7779c
    History
    aes-decrypt-internal.asm 2.53 KiB
    C nettle, low-level cryptographics library
    C 
    C Copyright (C) 2013 Niels Möller
    C  
    C The nettle library is free software; you can redistribute it and/or modify
    C it under the terms of the GNU Lesser General Public License as published by
    C the Free Software Foundation; either version 2.1 of the License, or (at your
    C option) any later version.
    C 
    C The nettle library is distributed in the hope that it will be useful, but
    C WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    C or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
    C License for more details.
    C 
    C You should have received a copy of the GNU Lesser General Public License
    C along with the nettle library; see the file COPYING.LIB.  If not, write to
    C the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
    C MA 02111-1301, USA.
    
    include_src(<arm/aes.m4>)
    
    C	Benchmarked at at 785, 914, 1051 cycles/block on cortex A9,
    C	for 128, 192 and 256 bit key sizes. Unclear why it is slower
    C	than _aes_encrypt.
    
    define(<CTX>, <r0>)
    define(<TABLE>, <r1>)
    define(<LENGTH>, <r2>)
    define(<DST>, <r3>)
    define(<SRC>, <r12>)
    
    define(<W0>, <r4>)
    define(<W1>, <r5>)
    define(<W2>, <r6>)
    define(<W3>, <r7>)
    define(<T0>, <r8>)
    define(<KEY>, <r10>)
    define(<ROUND>, <r11>)
    
    define(<X0>, <r2>)	C Overlaps LENGTH, SRC, DST
    define(<X1>, <r3>)
    define(<X2>, <r12>)
    define(<X3>, <r14>)	C lr
    
    
    	.file "aes-decrypt-internal.asm"
    	
    	C _aes_decrypt(struct aes_context *ctx, 
    	C	       const struct aes_table *T,
    	C	       unsigned length, uint8_t *dst,
    	C	       uint8_t *src)
    	.text
    	.align 2
    PROLOGUE(_nettle_aes_decrypt)
    	teq	LENGTH, #0
    	beq	.Lend
    	ldr	SRC, [sp]
    
    	push	{r4,r5,r6,r7,r8,r10,r11,lr}
    .Lblock_loop:
    	mov	KEY, CTX
    	AES_LOAD(SRC,KEY,W0)
    	AES_LOAD(SRC,KEY,W1)
    	AES_LOAD(SRC,KEY,W2)
    	AES_LOAD(SRC,KEY,W3)
    
    	push	{LENGTH, DST, SRC}
    	ldr	ROUND, [CTX, #+AES_NROUNDS]
    	add	TABLE, TABLE, #AES_TABLE0
    
    	b	.Lentry
    	.align 2
    .Lround_loop:
    	C	Transform X -> W
    	AES_DECRYPT_ROUND(X0, X1, X2, X3, W0, W1, W2, W3, KEY)
    	
    .Lentry:
    	subs	ROUND, ROUND,#2
    	C	Transform W -> X
    	AES_DECRYPT_ROUND(W0, W1, W2, W3, X0, X1, X2, X3, KEY)
    
    	bne	.Lround_loop
    
    	sub	TABLE, TABLE, #AES_TABLE0
    	C	Final round
    	AES_FINAL_ROUND(X0, X3, X2, X1, KEY, W0)
    	AES_FINAL_ROUND(X1, X0, X3, X2, KEY, W1)
    	AES_FINAL_ROUND(X2, X1, X0, X3, KEY, W2)
    	AES_FINAL_ROUND(X3, X2, X1, X0, KEY, W3)
    
    	pop	{LENGTH, DST, SRC}
    	
    	AES_STORE(DST,W0)
    	AES_STORE(DST,W1)
    	AES_STORE(DST,W2)
    	AES_STORE(DST,W3)
    
    	subs	LENGTH, LENGTH, #16
    	bhi	.Lblock_loop
    
    	pop	{r4,r5,r6,r7,r8,r10,r11,pc}
    	
    .Lend:
    	bx	lr
    EPILOGUE(_nettle_aes_decrypt)