crypto.cc revision 13169
113168Smatt.horsnell@arm.com/* 213168Smatt.horsnell@arm.com * Copyright (c) 2018 ARM Limited 313168Smatt.horsnell@arm.com * All rights reserved 413168Smatt.horsnell@arm.com * 513168Smatt.horsnell@arm.com * The license below extends only to copyright in the software and shall 613168Smatt.horsnell@arm.com * not be construed as granting a license to any other intellectual 713168Smatt.horsnell@arm.com * property including but not limited to intellectual property relating 813168Smatt.horsnell@arm.com * to a hardware implementation of the functionality of the software 913168Smatt.horsnell@arm.com * licensed hereunder. You may use the software subject to the license 1013168Smatt.horsnell@arm.com * terms below provided that you ensure that this notice is replicated 1113168Smatt.horsnell@arm.com * unmodified and in its entirety in all distributions of the software, 1213168Smatt.horsnell@arm.com * modified or unmodified, in source code or in binary form. 1313168Smatt.horsnell@arm.com * 1413168Smatt.horsnell@arm.com * Redistribution and use in source and binary forms, with or without 1513168Smatt.horsnell@arm.com * modification, are permitted provided that the following conditions are 1613168Smatt.horsnell@arm.com * met: redistributions of source code must retain the above copyright 1713168Smatt.horsnell@arm.com * notice, this list of conditions and the following disclaimer; 1813168Smatt.horsnell@arm.com * redistributions in binary form must reproduce the above copyright 1913168Smatt.horsnell@arm.com * notice, this list of conditions and the following disclaimer in the 2013168Smatt.horsnell@arm.com * documentation and/or other materials provided with the distribution; 2113168Smatt.horsnell@arm.com * neither the name of the copyright holders nor the names of its 2213168Smatt.horsnell@arm.com * contributors may be used to endorse or promote products derived from 2313168Smatt.horsnell@arm.com * this software without specific prior written permission. 2413168Smatt.horsnell@arm.com * 2513168Smatt.horsnell@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2613168Smatt.horsnell@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2713168Smatt.horsnell@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2813168Smatt.horsnell@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2913168Smatt.horsnell@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3013168Smatt.horsnell@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3113168Smatt.horsnell@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3213168Smatt.horsnell@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3313168Smatt.horsnell@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3413168Smatt.horsnell@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3513168Smatt.horsnell@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3613168Smatt.horsnell@arm.com * 3713168Smatt.horsnell@arm.com * Authors: Matt Horsnell 3813168Smatt.horsnell@arm.com * Prakash Ramrakhyani 3913168Smatt.horsnell@arm.com */ 4013168Smatt.horsnell@arm.com 4113168Smatt.horsnell@arm.com#include <cstdio> 4213168Smatt.horsnell@arm.com#include <iostream> 4313168Smatt.horsnell@arm.com#include <string> 4413168Smatt.horsnell@arm.com 4513168Smatt.horsnell@arm.com#include "crypto.hh" 4613168Smatt.horsnell@arm.com 4713168Smatt.horsnell@arm.comnamespace ArmISA { 4813168Smatt.horsnell@arm.com 4913169Smatt.horsnell@arm.comconst uint8_t 5013169Smatt.horsnell@arm.comCrypto::aesSBOX[256] = { 5113169Smatt.horsnell@arm.com 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 5213169Smatt.horsnell@arm.com 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 5313169Smatt.horsnell@arm.com 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 5413169Smatt.horsnell@arm.com 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 5513169Smatt.horsnell@arm.com 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 5613169Smatt.horsnell@arm.com 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 5713169Smatt.horsnell@arm.com 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 5813169Smatt.horsnell@arm.com 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 5913169Smatt.horsnell@arm.com 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 6013169Smatt.horsnell@arm.com 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 6113169Smatt.horsnell@arm.com 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 6213169Smatt.horsnell@arm.com 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 6313169Smatt.horsnell@arm.com 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 6413169Smatt.horsnell@arm.com 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 6513169Smatt.horsnell@arm.com 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 6613169Smatt.horsnell@arm.com 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 6713169Smatt.horsnell@arm.com 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 6813169Smatt.horsnell@arm.com 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 6913169Smatt.horsnell@arm.com 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 7013169Smatt.horsnell@arm.com 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 7113169Smatt.horsnell@arm.com 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 7213169Smatt.horsnell@arm.com 0xb0, 0x54, 0xbb, 0x16 7313169Smatt.horsnell@arm.com}; 7413169Smatt.horsnell@arm.com 7513169Smatt.horsnell@arm.comconst uint8_t 7613169Smatt.horsnell@arm.comCrypto::aesInvSBOX[256] = { 7713169Smatt.horsnell@arm.com 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 7813169Smatt.horsnell@arm.com 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 7913169Smatt.horsnell@arm.com 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 8013169Smatt.horsnell@arm.com 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 8113169Smatt.horsnell@arm.com 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 8213169Smatt.horsnell@arm.com 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 8313169Smatt.horsnell@arm.com 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 8413169Smatt.horsnell@arm.com 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 8513169Smatt.horsnell@arm.com 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 8613169Smatt.horsnell@arm.com 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 8713169Smatt.horsnell@arm.com 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 8813169Smatt.horsnell@arm.com 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 8913169Smatt.horsnell@arm.com 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 9013169Smatt.horsnell@arm.com 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 9113169Smatt.horsnell@arm.com 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 9213169Smatt.horsnell@arm.com 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 9313169Smatt.horsnell@arm.com 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 9413169Smatt.horsnell@arm.com 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 9513169Smatt.horsnell@arm.com 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 9613169Smatt.horsnell@arm.com 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 9713169Smatt.horsnell@arm.com 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 9813169Smatt.horsnell@arm.com 0x55, 0x21, 0x0c, 0x7d 9913169Smatt.horsnell@arm.com}; 10013169Smatt.horsnell@arm.com 10113169Smatt.horsnell@arm.comconst uint8_t 10213169Smatt.horsnell@arm.comCrypto::aesFFLOG[256] = { 10313169Smatt.horsnell@arm.com 0x00, 0x00, 0x19, 0x01, 0x32, 0x02, 0x1a, 0xc6, 0x4b, 0xc7, 0x1b, 0x68, 10413169Smatt.horsnell@arm.com 0x33, 0xee, 0xdf, 0x03, 0x64, 0x04, 0xe0, 0x0e, 0x34, 0x8d, 0x81, 0xef, 10513169Smatt.horsnell@arm.com 0x4c, 0x71, 0x08, 0xc8, 0xf8, 0x69, 0x1c, 0xc1, 0x7d, 0xc2, 0x1d, 0xb5, 10613169Smatt.horsnell@arm.com 0xf9, 0xb9, 0x27, 0x6a, 0x4d, 0xe4, 0xa6, 0x72, 0x9a, 0xc9, 0x09, 0x78, 10713169Smatt.horsnell@arm.com 0x65, 0x2f, 0x8a, 0x05, 0x21, 0x0f, 0xe1, 0x24, 0x12, 0xf0, 0x82, 0x45, 10813169Smatt.horsnell@arm.com 0x35, 0x93, 0xda, 0x8e, 0x96, 0x8f, 0xdb, 0xbd, 0x36, 0xd0, 0xce, 0x94, 10913169Smatt.horsnell@arm.com 0x13, 0x5c, 0xd2, 0xf1, 0x40, 0x46, 0x83, 0x38, 0x66, 0xdd, 0xfd, 0x30, 11013169Smatt.horsnell@arm.com 0xbf, 0x06, 0x8b, 0x62, 0xb3, 0x25, 0xe2, 0x98, 0x22, 0x88, 0x91, 0x10, 11113169Smatt.horsnell@arm.com 0x7e, 0x6e, 0x48, 0xc3, 0xa3, 0xb6, 0x1e, 0x42, 0x3a, 0x6b, 0x28, 0x54, 11213169Smatt.horsnell@arm.com 0xfa, 0x85, 0x3d, 0xba, 0x2b, 0x79, 0x0a, 0x15, 0x9b, 0x9f, 0x5e, 0xca, 11313169Smatt.horsnell@arm.com 0x4e, 0xd4, 0xac, 0xe5, 0xf3, 0x73, 0xa7, 0x57, 0xaf, 0x58, 0xa8, 0x50, 11413169Smatt.horsnell@arm.com 0xf4, 0xea, 0xd6, 0x74, 0x4f, 0xae, 0xe9, 0xd5, 0xe7, 0xe6, 0xad, 0xe8, 11513169Smatt.horsnell@arm.com 0x2c, 0xd7, 0x75, 0x7a, 0xeb, 0x16, 0x0b, 0xf5, 0x59, 0xcb, 0x5f, 0xb0, 11613169Smatt.horsnell@arm.com 0x9c, 0xa9, 0x51, 0xa0, 0x7f, 0x0c, 0xf6, 0x6f, 0x17, 0xc4, 0x49, 0xec, 11713169Smatt.horsnell@arm.com 0xd8, 0x43, 0x1f, 0x2d, 0xa4, 0x76, 0x7b, 0xb7, 0xcc, 0xbb, 0x3e, 0x5a, 11813169Smatt.horsnell@arm.com 0xfb, 0x60, 0xb1, 0x86, 0x3b, 0x52, 0xa1, 0x6c, 0xaa, 0x55, 0x29, 0x9d, 11913169Smatt.horsnell@arm.com 0x97, 0xb2, 0x87, 0x90, 0x61, 0xbe, 0xdc, 0xfc, 0xbc, 0x95, 0xcf, 0xcd, 12013169Smatt.horsnell@arm.com 0x37, 0x3f, 0x5b, 0xd1, 0x53, 0x39, 0x84, 0x3c, 0x41, 0xa2, 0x6d, 0x47, 12113169Smatt.horsnell@arm.com 0x14, 0x2a, 0x9e, 0x5d, 0x56, 0xf2, 0xd3, 0xab, 0x44, 0x11, 0x92, 0xd9, 12213169Smatt.horsnell@arm.com 0x23, 0x20, 0x2e, 0x89, 0xb4, 0x7c, 0xb8, 0x26, 0x77, 0x99, 0xe3, 0xa5, 12313169Smatt.horsnell@arm.com 0x67, 0x4a, 0xed, 0xde, 0xc5, 0x31, 0xfe, 0x18, 0x0d, 0x63, 0x8c, 0x80, 12413169Smatt.horsnell@arm.com 0xc0, 0xf7, 0x70, 0x07 12513169Smatt.horsnell@arm.com}; 12613169Smatt.horsnell@arm.com 12713169Smatt.horsnell@arm.comconst uint8_t 12813169Smatt.horsnell@arm.comCrypto::aesFFEXP[256] = { 12913169Smatt.horsnell@arm.com 0x01, 0x03, 0x05, 0x0f, 0x11, 0x33, 0x55, 0xff, 0x1a, 0x2e, 0x72, 0x96, 13013169Smatt.horsnell@arm.com 0xa1, 0xf8, 0x13, 0x35, 0x5f, 0xe1, 0x38, 0x48, 0xd8, 0x73, 0x95, 0xa4, 13113169Smatt.horsnell@arm.com 0xf7, 0x02, 0x06, 0x0a, 0x1e, 0x22, 0x66, 0xaa, 0xe5, 0x34, 0x5c, 0xe4, 13213169Smatt.horsnell@arm.com 0x37, 0x59, 0xeb, 0x26, 0x6a, 0xbe, 0xd9, 0x70, 0x90, 0xab, 0xe6, 0x31, 13313169Smatt.horsnell@arm.com 0x53, 0xf5, 0x04, 0x0c, 0x14, 0x3c, 0x44, 0xcc, 0x4f, 0xd1, 0x68, 0xb8, 13413169Smatt.horsnell@arm.com 0xd3, 0x6e, 0xb2, 0xcd, 0x4c, 0xd4, 0x67, 0xa9, 0xe0, 0x3b, 0x4d, 0xd7, 13513169Smatt.horsnell@arm.com 0x62, 0xa6, 0xf1, 0x08, 0x18, 0x28, 0x78, 0x88, 0x83, 0x9e, 0xb9, 0xd0, 13613169Smatt.horsnell@arm.com 0x6b, 0xbd, 0xdc, 0x7f, 0x81, 0x98, 0xb3, 0xce, 0x49, 0xdb, 0x76, 0x9a, 13713169Smatt.horsnell@arm.com 0xb5, 0xc4, 0x57, 0xf9, 0x10, 0x30, 0x50, 0xf0, 0x0b, 0x1d, 0x27, 0x69, 13813169Smatt.horsnell@arm.com 0xbb, 0xd6, 0x61, 0xa3, 0xfe, 0x19, 0x2b, 0x7d, 0x87, 0x92, 0xad, 0xec, 13913169Smatt.horsnell@arm.com 0x2f, 0x71, 0x93, 0xae, 0xe9, 0x20, 0x60, 0xa0, 0xfb, 0x16, 0x3a, 0x4e, 14013169Smatt.horsnell@arm.com 0xd2, 0x6d, 0xb7, 0xc2, 0x5d, 0xe7, 0x32, 0x56, 0xfa, 0x15, 0x3f, 0x41, 14113169Smatt.horsnell@arm.com 0xc3, 0x5e, 0xe2, 0x3d, 0x47, 0xc9, 0x40, 0xc0, 0x5b, 0xed, 0x2c, 0x74, 14213169Smatt.horsnell@arm.com 0x9c, 0xbf, 0xda, 0x75, 0x9f, 0xba, 0xd5, 0x64, 0xac, 0xef, 0x2a, 0x7e, 14313169Smatt.horsnell@arm.com 0x82, 0x9d, 0xbc, 0xdf, 0x7a, 0x8e, 0x89, 0x80, 0x9b, 0xb6, 0xc1, 0x58, 14413169Smatt.horsnell@arm.com 0xe8, 0x23, 0x65, 0xaf, 0xea, 0x25, 0x6f, 0xb1, 0xc8, 0x43, 0xc5, 0x54, 14513169Smatt.horsnell@arm.com 0xfc, 0x1f, 0x21, 0x63, 0xa5, 0xf4, 0x07, 0x09, 0x1b, 0x2d, 0x77, 0x99, 14613169Smatt.horsnell@arm.com 0xb0, 0xcb, 0x46, 0xca, 0x45, 0xcf, 0x4a, 0xde, 0x79, 0x8b, 0x86, 0x91, 14713169Smatt.horsnell@arm.com 0xa8, 0xe3, 0x3e, 0x42, 0xc6, 0x51, 0xf3, 0x0e, 0x12, 0x36, 0x5a, 0xee, 14813169Smatt.horsnell@arm.com 0x29, 0x7b, 0x8d, 0x8c, 0x8f, 0x8a, 0x85, 0x94, 0xa7, 0xf2, 0x0d, 0x17, 14913169Smatt.horsnell@arm.com 0x39, 0x4b, 0xdd, 0x7c, 0x84, 0x97, 0xa2, 0xfd, 0x1c, 0x24, 0x6c, 0xb4, 15013169Smatt.horsnell@arm.com 0xc7, 0x52, 0xf6, 0x01 15113169Smatt.horsnell@arm.com}; 15213169Smatt.horsnell@arm.com 15313169Smatt.horsnell@arm.comconst uint8_t 15413169Smatt.horsnell@arm.comCrypto::aesSHIFT[16] = { 15513169Smatt.horsnell@arm.com 0, 5, 10, 15, 4, 9, 14, 3, 15613169Smatt.horsnell@arm.com 8, 13, 2, 7, 12, 1, 6, 11 15713169Smatt.horsnell@arm.com}; 15813169Smatt.horsnell@arm.com 15913169Smatt.horsnell@arm.comconst uint8_t 16013169Smatt.horsnell@arm.comCrypto::aesINVSHIFT[16] = { 16113169Smatt.horsnell@arm.com 0, 13, 10, 7, 4, 1, 14, 11, 16213169Smatt.horsnell@arm.com 8, 5, 2, 15, 12, 9, 6, 3 16313169Smatt.horsnell@arm.com}; 16413169Smatt.horsnell@arm.com 16513169Smatt.horsnell@arm.comuint8_t 16613169Smatt.horsnell@arm.comCrypto::aesFFMul(uint8_t a, uint8_t b) 16713169Smatt.horsnell@arm.com{ 16813169Smatt.horsnell@arm.com unsigned int log_prod; 16913169Smatt.horsnell@arm.com 17013169Smatt.horsnell@arm.com if ((a ==0)|| (b == 0)) return 0; 17113169Smatt.horsnell@arm.com 17213169Smatt.horsnell@arm.com log_prod = (aesFFLOG[a] + aesFFLOG[b]); 17313169Smatt.horsnell@arm.com 17413169Smatt.horsnell@arm.com if(log_prod > 0xff) 17513169Smatt.horsnell@arm.com log_prod = log_prod - 0xff; 17613169Smatt.horsnell@arm.com 17713169Smatt.horsnell@arm.com return aesFFEXP[log_prod]; 17813169Smatt.horsnell@arm.com} 17913169Smatt.horsnell@arm.com 18013169Smatt.horsnell@arm.comvoid 18113169Smatt.horsnell@arm.comCrypto::aesSubBytes(uint8_t *output, uint8_t *input) 18213169Smatt.horsnell@arm.com{ 18313169Smatt.horsnell@arm.com for (int i = 0; i < 16; ++i) { 18413169Smatt.horsnell@arm.com output[i] = aesSBOX[input[i]]; 18513169Smatt.horsnell@arm.com } 18613169Smatt.horsnell@arm.com} 18713169Smatt.horsnell@arm.com 18813169Smatt.horsnell@arm.comvoid 18913169Smatt.horsnell@arm.comCrypto::aesInvSubBytes(uint8_t *output, uint8_t *input) 19013169Smatt.horsnell@arm.com{ 19113169Smatt.horsnell@arm.com for (int i = 0; i < 16; ++i) { 19213169Smatt.horsnell@arm.com output[i] = aesInvSBOX[input[i]]; 19313169Smatt.horsnell@arm.com } 19413169Smatt.horsnell@arm.com} 19513169Smatt.horsnell@arm.com 19613169Smatt.horsnell@arm.comvoid 19713169Smatt.horsnell@arm.comCrypto::aesShiftRows(uint8_t *output, uint8_t *input) 19813169Smatt.horsnell@arm.com{ 19913169Smatt.horsnell@arm.com for (int i = 0; i < 16; ++i) { 20013169Smatt.horsnell@arm.com output[i] = input[aesSHIFT[i]]; 20113169Smatt.horsnell@arm.com } 20213169Smatt.horsnell@arm.com} 20313169Smatt.horsnell@arm.com 20413169Smatt.horsnell@arm.comvoid 20513169Smatt.horsnell@arm.comCrypto::aesInvShiftRows(uint8_t *output, uint8_t *input) 20613169Smatt.horsnell@arm.com{ 20713169Smatt.horsnell@arm.com for (int i = 0; i < 16; ++i) { 20813169Smatt.horsnell@arm.com output[i] = input[aesINVSHIFT[i]]; 20913169Smatt.horsnell@arm.com } 21013169Smatt.horsnell@arm.com} 21113169Smatt.horsnell@arm.com 21213169Smatt.horsnell@arm.comvoid 21313169Smatt.horsnell@arm.comCrypto::aesAddRoundKey(uint8_t *output, uint8_t *input, 21413169Smatt.horsnell@arm.com uint8_t *key) 21513169Smatt.horsnell@arm.com{ 21613169Smatt.horsnell@arm.com for (int i = 0; i < 16; ++i) { 21713169Smatt.horsnell@arm.com output[i] = input[i] ^ key[i]; 21813169Smatt.horsnell@arm.com } 21913169Smatt.horsnell@arm.com} 22013169Smatt.horsnell@arm.com 22113169Smatt.horsnell@arm.comvoid 22213169Smatt.horsnell@arm.comCrypto::aesMixColumns(uint8_t *output, uint8_t *input) 22313169Smatt.horsnell@arm.com{ 22413169Smatt.horsnell@arm.com for (int j = 0; j < 4; ++j) { 22513169Smatt.horsnell@arm.com int row0 = (j * 4); 22613169Smatt.horsnell@arm.com int row1 = row0 + 1; 22713169Smatt.horsnell@arm.com int row2 = row0 + 2; 22813169Smatt.horsnell@arm.com int row3 = row0 + 3; 22913169Smatt.horsnell@arm.com uint8_t t1 = input[row0] ^ input[row1] ^ 23013169Smatt.horsnell@arm.com input[row2] ^ input[row3]; 23113169Smatt.horsnell@arm.com 23213169Smatt.horsnell@arm.com output[row1] = input[row1] ^ t1 ^ aesFFMul2(input[row1] ^ input[row2]); 23313169Smatt.horsnell@arm.com output[row2] = input[row2] ^ t1 ^ aesFFMul2(input[row2] ^ input[row3]); 23413169Smatt.horsnell@arm.com output[row3] = input[row3] ^ t1 ^ aesFFMul2(input[row3] ^ input[row0]); 23513169Smatt.horsnell@arm.com output[row0] = input[row0] ^ t1 ^ aesFFMul2(input[row0] ^ input[row1]); 23613169Smatt.horsnell@arm.com } 23713169Smatt.horsnell@arm.com} 23813169Smatt.horsnell@arm.com 23913169Smatt.horsnell@arm.comvoid 24013169Smatt.horsnell@arm.comCrypto::aesInvMixColumns(uint8_t *output, uint8_t *input) 24113169Smatt.horsnell@arm.com{ 24213169Smatt.horsnell@arm.com for (int j = 0; j < 4; ++j) { 24313169Smatt.horsnell@arm.com for (int i = 0; i < 4; ++i) { 24413169Smatt.horsnell@arm.com int index0 = (j * 4) + i; 24513169Smatt.horsnell@arm.com int index1 = (j * 4) + ((i + 1) % 4); 24613169Smatt.horsnell@arm.com int index2 = (j * 4) + ((i + 2) % 4); 24713169Smatt.horsnell@arm.com int index3 = (j * 4) + ((i + 3) % 4); 24813169Smatt.horsnell@arm.com output [index0] = 24913169Smatt.horsnell@arm.com aesFFMul(0x0e, input[index0]) ^ aesFFMul(0x0b, input[index1]) ^ 25013169Smatt.horsnell@arm.com aesFFMul(0x0d, input[index2]) ^ aesFFMul(0x09, input[index3]); 25113169Smatt.horsnell@arm.com } 25213169Smatt.horsnell@arm.com } 25313169Smatt.horsnell@arm.com} 25413169Smatt.horsnell@arm.com 25513169Smatt.horsnell@arm.comvoid 25613169Smatt.horsnell@arm.comCrypto::aesEncrypt(uint8_t *output, uint8_t *input, 25713169Smatt.horsnell@arm.com uint8_t *key) 25813169Smatt.horsnell@arm.com{ 25913169Smatt.horsnell@arm.com uint8_t temp1[16]; 26013169Smatt.horsnell@arm.com uint8_t temp2[16]; 26113169Smatt.horsnell@arm.com aesAddRoundKey(&temp1[0], input, key); 26213169Smatt.horsnell@arm.com aesShiftRows(&temp2[0], &temp1[0]); 26313169Smatt.horsnell@arm.com aesSubBytes(output, &temp2[0]); 26413169Smatt.horsnell@arm.com} 26513169Smatt.horsnell@arm.com 26613169Smatt.horsnell@arm.comvoid 26713169Smatt.horsnell@arm.comCrypto::aesDecrypt(uint8_t *output, uint8_t *input, 26813169Smatt.horsnell@arm.com uint8_t *key) 26913169Smatt.horsnell@arm.com{ 27013169Smatt.horsnell@arm.com uint8_t temp1[16]; 27113169Smatt.horsnell@arm.com uint8_t temp2[16]; 27213169Smatt.horsnell@arm.com aesAddRoundKey(&temp1[0], input, key); 27313169Smatt.horsnell@arm.com aesInvShiftRows(&temp2[0], &temp1[0]); 27413169Smatt.horsnell@arm.com aesInvSubBytes(output, &temp2[0]); 27513169Smatt.horsnell@arm.com} 27613169Smatt.horsnell@arm.com 27713168Smatt.horsnell@arm.comvoid 27813168Smatt.horsnell@arm.comCrypto::sha256Op( 27913168Smatt.horsnell@arm.com uint32_t *X, 28013168Smatt.horsnell@arm.com uint32_t *Y, 28113168Smatt.horsnell@arm.com uint32_t *Z) 28213168Smatt.horsnell@arm.com{ 28313168Smatt.horsnell@arm.com uint32_t T0, T1, T2, T3; 28413168Smatt.horsnell@arm.com for (int i = 0; i < 4; ++i) { 28513168Smatt.horsnell@arm.com T0 = choose(Y[0], Y[1], Y[2]); 28613168Smatt.horsnell@arm.com T1 = majority(X[0], X[1], X[2]); 28713168Smatt.horsnell@arm.com T2 = Y[3] + sigma1(Y[0]) + T0 + Z[i]; 28813168Smatt.horsnell@arm.com X[3] = T2 + X[3]; 28913168Smatt.horsnell@arm.com Y[3] = T2 + sigma0(X[0]) + T1; 29013168Smatt.horsnell@arm.com // Rotate 29113168Smatt.horsnell@arm.com T3 = Y[3]; 29213168Smatt.horsnell@arm.com Y[3] = Y[2]; Y[2] = Y[1]; Y[1] = Y[0]; Y[0] = X[3]; 29313168Smatt.horsnell@arm.com X[3] = X[2]; X[2] = X[1]; X[1] = X[0]; X[0] = T3; 29413168Smatt.horsnell@arm.com } 29513168Smatt.horsnell@arm.com} 29613168Smatt.horsnell@arm.com 29713168Smatt.horsnell@arm.comvoid 29813168Smatt.horsnell@arm.comCrypto::_sha1Op( 29913168Smatt.horsnell@arm.com uint32_t *X, 30013168Smatt.horsnell@arm.com uint32_t *Y, 30113168Smatt.horsnell@arm.com uint32_t *Z, 30213168Smatt.horsnell@arm.com SHAOp op) 30313168Smatt.horsnell@arm.com{ 30413168Smatt.horsnell@arm.com uint32_t T1, T2; 30513168Smatt.horsnell@arm.com 30613168Smatt.horsnell@arm.com for (int i = 0; i < 4; ++i) { 30713168Smatt.horsnell@arm.com switch (op) { 30813168Smatt.horsnell@arm.com case CHOOSE: T1 = choose(X[1], X[2], X[3]); break; 30913168Smatt.horsnell@arm.com case PARITY: T1 = parity(X[1], X[2], X[3]); break; 31013168Smatt.horsnell@arm.com case MAJORITY: T1 = majority(X[1], X[2], X[3]); break; 31113168Smatt.horsnell@arm.com default: return; 31213168Smatt.horsnell@arm.com } 31313168Smatt.horsnell@arm.com Y[0] += ror(X[0], 27) + T1 + Z[i]; 31413168Smatt.horsnell@arm.com X[1] = ror(X[1], 2); 31513168Smatt.horsnell@arm.com T2 = Y[0]; 31613168Smatt.horsnell@arm.com Y[0] = X[3]; 31713168Smatt.horsnell@arm.com X[3] = X[2]; X[2] = X[1]; X[1] = X[0]; X[0] = T2; 31813168Smatt.horsnell@arm.com } 31913168Smatt.horsnell@arm.com} 32013168Smatt.horsnell@arm.com 32113168Smatt.horsnell@arm.comvoid 32213168Smatt.horsnell@arm.comCrypto::sha256H( 32313168Smatt.horsnell@arm.com uint8_t *output, 32413168Smatt.horsnell@arm.com uint8_t *input, 32513168Smatt.horsnell@arm.com uint8_t *input2) 32613168Smatt.horsnell@arm.com{ 32713168Smatt.horsnell@arm.com uint32_t X[4], Y[4], Z[4]; 32813168Smatt.horsnell@arm.com load3Reg(&X[0], &Y[0], &Z[0], output, input, input2); 32913168Smatt.horsnell@arm.com sha256Op(&X[0], &Y[0], &Z[0]); 33013168Smatt.horsnell@arm.com store1Reg(output, &X[0]); 33113168Smatt.horsnell@arm.com} 33213168Smatt.horsnell@arm.com 33313168Smatt.horsnell@arm.comvoid 33413168Smatt.horsnell@arm.comCrypto::sha256H2( 33513168Smatt.horsnell@arm.com uint8_t *output, 33613168Smatt.horsnell@arm.com uint8_t *input, 33713168Smatt.horsnell@arm.com uint8_t *input2) 33813168Smatt.horsnell@arm.com{ 33913168Smatt.horsnell@arm.com uint32_t X[4], Y[4], Z[4]; 34013168Smatt.horsnell@arm.com load3Reg(&X[0], &Y[0], &Z[0], output, input, input2); 34113168Smatt.horsnell@arm.com sha256Op(&Y[0], &X[0], &Z[0]); 34213168Smatt.horsnell@arm.com store1Reg(output, &X[0]); 34313168Smatt.horsnell@arm.com} 34413168Smatt.horsnell@arm.com 34513168Smatt.horsnell@arm.comvoid 34613168Smatt.horsnell@arm.comCrypto::sha256Su0(uint8_t *output, uint8_t *input) 34713168Smatt.horsnell@arm.com{ 34813168Smatt.horsnell@arm.com uint32_t X[4], Y[4]; 34913168Smatt.horsnell@arm.com uint32_t T[4]; 35013168Smatt.horsnell@arm.com 35113168Smatt.horsnell@arm.com load2Reg(&X[0], &Y[0], output, input); 35213168Smatt.horsnell@arm.com 35313168Smatt.horsnell@arm.com T[3] = Y[0]; T[2] = X[3]; T[1] = X[2]; T[0] = X[1]; 35413168Smatt.horsnell@arm.com 35513168Smatt.horsnell@arm.com T[3] = ror(T[3], 7) ^ ror(T[3], 18) ^ (T[3] >> 3); 35613168Smatt.horsnell@arm.com T[2] = ror(T[2], 7) ^ ror(T[2], 18) ^ (T[2] >> 3); 35713168Smatt.horsnell@arm.com T[1] = ror(T[1], 7) ^ ror(T[1], 18) ^ (T[1] >> 3); 35813168Smatt.horsnell@arm.com T[0] = ror(T[0], 7) ^ ror(T[0], 18) ^ (T[0] >> 3); 35913168Smatt.horsnell@arm.com 36013168Smatt.horsnell@arm.com X[3] += T[3]; 36113168Smatt.horsnell@arm.com X[2] += T[2]; 36213168Smatt.horsnell@arm.com X[1] += T[1]; 36313168Smatt.horsnell@arm.com X[0] += T[0]; 36413168Smatt.horsnell@arm.com 36513168Smatt.horsnell@arm.com store1Reg(output, &X[0]); 36613168Smatt.horsnell@arm.com} 36713168Smatt.horsnell@arm.com 36813168Smatt.horsnell@arm.comvoid 36913168Smatt.horsnell@arm.comCrypto::sha256Su1( 37013168Smatt.horsnell@arm.com uint8_t *output, 37113168Smatt.horsnell@arm.com uint8_t *input, 37213168Smatt.horsnell@arm.com uint8_t *input2) 37313168Smatt.horsnell@arm.com{ 37413168Smatt.horsnell@arm.com uint32_t X[4], Y[4], Z[4]; 37513168Smatt.horsnell@arm.com uint32_t T0[4], T1[4], T2[4], T3[4]; 37613168Smatt.horsnell@arm.com 37713168Smatt.horsnell@arm.com load3Reg(&X[0], &Y[0], &Z[0], output, input, input2); 37813168Smatt.horsnell@arm.com 37913168Smatt.horsnell@arm.com T0[3] = Z[0]; T0[2] = Y[3]; T0[1] = Y[2]; T0[0] = Y[1]; 38013168Smatt.horsnell@arm.com T1[1] = Z[3]; T1[0] = Z[2]; 38113168Smatt.horsnell@arm.com T1[1] = ror(T1[1], 17) ^ ror(T1[1], 19) ^ (T1[1] >> 10); 38213168Smatt.horsnell@arm.com T1[0] = ror(T1[0], 17) ^ ror(T1[0], 19) ^ (T1[0] >> 10); 38313168Smatt.horsnell@arm.com T3[1] = X[1] + T0[1]; T3[0] = X[0] + T0[0]; 38413168Smatt.horsnell@arm.com T1[1] = T3[1] + T1[1]; T1[0] = T3[0] + T1[0]; 38513168Smatt.horsnell@arm.com T2[1] = ror(T1[1], 17) ^ ror(T1[1], 19) ^ (T1[1] >> 10); 38613168Smatt.horsnell@arm.com T2[0] = ror(T1[0], 17) ^ ror(T1[0], 19) ^ (T1[0] >> 10); 38713168Smatt.horsnell@arm.com T3[1] = X[3] + T0[3]; T3[0] = X[2] + T0[2]; 38813168Smatt.horsnell@arm.com X[3] = T3[1] + T2[1]; 38913168Smatt.horsnell@arm.com X[2] = T3[0] + T2[0]; 39013168Smatt.horsnell@arm.com X[1] = T1[1]; X[0] = T1[0]; 39113168Smatt.horsnell@arm.com 39213168Smatt.horsnell@arm.com store1Reg(output, &X[0]); 39313168Smatt.horsnell@arm.com} 39413168Smatt.horsnell@arm.com 39513168Smatt.horsnell@arm.comvoid 39613168Smatt.horsnell@arm.comCrypto::sha1Op( 39713168Smatt.horsnell@arm.com uint8_t *output, 39813168Smatt.horsnell@arm.com uint8_t *input, 39913168Smatt.horsnell@arm.com uint8_t *input2, 40013168Smatt.horsnell@arm.com SHAOp op) 40113168Smatt.horsnell@arm.com{ 40213168Smatt.horsnell@arm.com uint32_t X[4], Y[4], Z[4]; 40313168Smatt.horsnell@arm.com load3Reg(&X[0], &Y[0], &Z[0], output, input, input2); 40413168Smatt.horsnell@arm.com _sha1Op(&X[0], &Y[0], &Z[0], op); 40513168Smatt.horsnell@arm.com store1Reg(output, &X[0]); 40613168Smatt.horsnell@arm.com} 40713168Smatt.horsnell@arm.com 40813168Smatt.horsnell@arm.comvoid 40913168Smatt.horsnell@arm.comCrypto::sha1C( 41013168Smatt.horsnell@arm.com uint8_t *output, 41113168Smatt.horsnell@arm.com uint8_t *input, 41213168Smatt.horsnell@arm.com uint8_t *input2) 41313168Smatt.horsnell@arm.com{ 41413168Smatt.horsnell@arm.com sha1Op(output, input, input2, CHOOSE); 41513168Smatt.horsnell@arm.com} 41613168Smatt.horsnell@arm.com 41713168Smatt.horsnell@arm.comvoid 41813168Smatt.horsnell@arm.comCrypto::sha1P( 41913168Smatt.horsnell@arm.com uint8_t *output, 42013168Smatt.horsnell@arm.com uint8_t *input, 42113168Smatt.horsnell@arm.com uint8_t *input2) 42213168Smatt.horsnell@arm.com{ 42313168Smatt.horsnell@arm.com sha1Op(output, input, input2, PARITY); 42413168Smatt.horsnell@arm.com} 42513168Smatt.horsnell@arm.com 42613168Smatt.horsnell@arm.comvoid 42713168Smatt.horsnell@arm.comCrypto::sha1M( 42813168Smatt.horsnell@arm.com uint8_t *output, 42913168Smatt.horsnell@arm.com uint8_t *input, 43013168Smatt.horsnell@arm.com uint8_t *input2) 43113168Smatt.horsnell@arm.com{ 43213168Smatt.horsnell@arm.com sha1Op(output, input, input2, MAJORITY); 43313168Smatt.horsnell@arm.com} 43413168Smatt.horsnell@arm.com 43513168Smatt.horsnell@arm.comvoid 43613168Smatt.horsnell@arm.comCrypto::sha1H(uint8_t *output, uint8_t *input) 43713168Smatt.horsnell@arm.com{ 43813168Smatt.horsnell@arm.com uint32_t X[4], Y[4]; 43913168Smatt.horsnell@arm.com load2Reg(&X[0], &Y[0], output, input); 44013168Smatt.horsnell@arm.com X[0] = ror(Y[0], 2); 44113168Smatt.horsnell@arm.com store1Reg(output, &X[0]); 44213168Smatt.horsnell@arm.com} 44313168Smatt.horsnell@arm.com 44413168Smatt.horsnell@arm.comvoid 44513168Smatt.horsnell@arm.comCrypto::sha1Su0( 44613168Smatt.horsnell@arm.com uint8_t *output, 44713168Smatt.horsnell@arm.com uint8_t *input, 44813168Smatt.horsnell@arm.com uint8_t *input2) 44913168Smatt.horsnell@arm.com{ 45013168Smatt.horsnell@arm.com uint32_t X[4], Y[4], Z[4], T[4]; 45113168Smatt.horsnell@arm.com load3Reg(&X[0], &Y[0], &Z[0], output, input, input2); 45213168Smatt.horsnell@arm.com 45313168Smatt.horsnell@arm.com T[3] = Y[1]; T[2] = Y[0]; T[1] = X[3]; T[0] = X[2]; 45413168Smatt.horsnell@arm.com X[3] = T[3] ^ X[3] ^ Z[3]; 45513168Smatt.horsnell@arm.com X[2] = T[2] ^ X[2] ^ Z[2]; 45613168Smatt.horsnell@arm.com X[1] = T[1] ^ X[1] ^ Z[1]; 45713168Smatt.horsnell@arm.com X[0] = T[0] ^ X[0] ^ Z[0]; 45813168Smatt.horsnell@arm.com 45913168Smatt.horsnell@arm.com store1Reg(output, &X[0]); 46013168Smatt.horsnell@arm.com} 46113168Smatt.horsnell@arm.com 46213168Smatt.horsnell@arm.comvoid 46313168Smatt.horsnell@arm.comCrypto::sha1Su1(uint8_t *output, uint8_t *input) 46413168Smatt.horsnell@arm.com{ 46513168Smatt.horsnell@arm.com uint32_t X[4], Y[4], T[4]; 46613168Smatt.horsnell@arm.com load2Reg(&X[0], &Y[0], output, input); 46713168Smatt.horsnell@arm.com 46813168Smatt.horsnell@arm.com T[3] = X[3] ^ 0x0; 46913168Smatt.horsnell@arm.com T[2] = X[2] ^ Y[3]; 47013168Smatt.horsnell@arm.com T[1] = X[1] ^ Y[2]; 47113168Smatt.horsnell@arm.com T[0] = X[0] ^ Y[1]; 47213168Smatt.horsnell@arm.com X[2] = ror(T[2], 31); X[1] = ror(T[1], 31); X[0] = ror(T[0], 31); 47313168Smatt.horsnell@arm.com X[3] = ror(T[3], 31) ^ ror(T[0], 30); 47413168Smatt.horsnell@arm.com 47513168Smatt.horsnell@arm.com store1Reg(output, &X[0]); 47613168Smatt.horsnell@arm.com} 47713168Smatt.horsnell@arm.com 47813168Smatt.horsnell@arm.comvoid 47913168Smatt.horsnell@arm.comCrypto::load2Reg( 48013168Smatt.horsnell@arm.com uint32_t *X, 48113168Smatt.horsnell@arm.com uint32_t *Y, 48213168Smatt.horsnell@arm.com uint8_t *output, 48313168Smatt.horsnell@arm.com uint8_t *input) 48413168Smatt.horsnell@arm.com{ 48513168Smatt.horsnell@arm.com for (int i = 0; i < 4; ++i) { 48613168Smatt.horsnell@arm.com X[i] = *((uint32_t *)&output[i*4]); 48713168Smatt.horsnell@arm.com Y[i] = *((uint32_t *)&input[i*4]); 48813168Smatt.horsnell@arm.com } 48913168Smatt.horsnell@arm.com} 49013168Smatt.horsnell@arm.com 49113168Smatt.horsnell@arm.comvoid 49213168Smatt.horsnell@arm.comCrypto::load3Reg( 49313168Smatt.horsnell@arm.com uint32_t *X, 49413168Smatt.horsnell@arm.com uint32_t *Y, 49513168Smatt.horsnell@arm.com uint32_t *Z, 49613168Smatt.horsnell@arm.com uint8_t *output, 49713168Smatt.horsnell@arm.com uint8_t *input, 49813168Smatt.horsnell@arm.com uint8_t *input2) 49913168Smatt.horsnell@arm.com{ 50013168Smatt.horsnell@arm.com for (int i = 0; i < 4; ++i) { 50113168Smatt.horsnell@arm.com X[i] = *((uint32_t *)&output[i*4]); 50213168Smatt.horsnell@arm.com Y[i] = *((uint32_t *)&input[i*4]); 50313168Smatt.horsnell@arm.com Z[i] = *((uint32_t *)&input2[i*4]); 50413168Smatt.horsnell@arm.com } 50513168Smatt.horsnell@arm.com} 50613168Smatt.horsnell@arm.com 50713168Smatt.horsnell@arm.comvoid 50813168Smatt.horsnell@arm.comCrypto::store1Reg(uint8_t *output, uint32_t *X) 50913168Smatt.horsnell@arm.com{ 51013168Smatt.horsnell@arm.com for (int i = 0; i < 4; ++i) { 51113168Smatt.horsnell@arm.com output[i*4] = (uint8_t)(X[i]); 51213168Smatt.horsnell@arm.com output[i*4+1] = (uint8_t)(X[i] >> 8); 51313168Smatt.horsnell@arm.com output[i*4+2] = (uint8_t)(X[i] >> 16); 51413168Smatt.horsnell@arm.com output[i*4+3] = (uint8_t)(X[i] >> 24); 51513168Smatt.horsnell@arm.com } 51613168Smatt.horsnell@arm.com} 51713168Smatt.horsnell@arm.com 51813168Smatt.horsnell@arm.com} // namespace ArmISA 519