Skip to content

Commit fa58c67

Browse files
committed
Make all those ops inline
Signed-off-by: Steffen Jaeckel <[email protected]>
1 parent d660001 commit fa58c67

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/ciphers/sm4.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static const sm4_u8_t sbox_table[16][16] = {
6767
* S-box
6868
* defined in section 2.6 S-box
6969
*/
70-
static sm4_u8_t sbox(sm4_u8_t a)
70+
static LTC_INLINE sm4_u8_t sbox(sm4_u8_t a)
7171
{
7272
return sbox_table[(a >> 4) & 0x0f][a & 0x0f];
7373
}
@@ -80,7 +80,7 @@ static sm4_u8_t sbox(sm4_u8_t a)
8080
* But we just convert a 32bit word byte by byte.
8181
* So it's OK if we don't convert the endian order
8282
*/
83-
static sm4_u32_t t(sm4_u32_t A)
83+
static LTC_INLINE sm4_u32_t t(sm4_u32_t A)
8484
{
8585
sm4_u8_t a[4];
8686
sm4_u8_t b[4];
@@ -98,15 +98,15 @@ static sm4_u32_t t(sm4_u32_t A)
9898
/*
9999
* defined in section 6.2 (2) Linear transformation L
100100
*/
101-
static sm4_u32_t L(sm4_u32_t B)
101+
static LTC_INLINE sm4_u32_t L(sm4_u32_t B)
102102
{
103103
return B ^ ROLc(B, 2) ^ ROLc(B, 10) ^ ROLc(B, 18) ^ ROLc(B, 24);
104104
}
105105

106106
/*
107107
* defined in section 6.2 Permutation T
108108
*/
109-
static sm4_u32_t T(sm4_u32_t Z)
109+
static LTC_INLINE sm4_u32_t T(sm4_u32_t Z)
110110
{
111111
return L(t(Z));
112112
}
@@ -137,23 +137,23 @@ static const sm4_u32_t CK[32] =
137137
/*
138138
* defined in section 7.3 (1) L'
139139
*/
140-
static sm4_u32_t _L(sm4_u32_t B)
140+
static LTC_INLINE sm4_u32_t _L(sm4_u32_t B)
141141
{
142142
return B ^ ROLc(B, 13) ^ ROLc(B, 23);
143143
}
144144

145145
/*
146146
* defined in section 7.3 (1) T'
147147
*/
148-
static sm4_u32_t _T(sm4_u32_t Z)
148+
static LTC_INLINE sm4_u32_t _T(sm4_u32_t Z)
149149
{
150150
return _L(t(Z));
151151
}
152152

153153
/*
154154
* defined in section 7.3 Key Expansion
155155
*/
156-
static void mk2rk(sm4_u32_t rk[32], sm4_u8_t mk[16])
156+
static void LTC_INLINE mk2rk(sm4_u32_t rk[32], sm4_u8_t mk[16])
157157
{
158158
sm4_u32_t MK[4] = { 0 };
159159
sm4_u32_t K[4+32] = { 0 };
@@ -175,15 +175,15 @@ static void mk2rk(sm4_u32_t rk[32], sm4_u8_t mk[16])
175175
/*
176176
* defined in section 6 Round Function F
177177
*/
178-
static sm4_u32_t F(sm4_u32_t X[4], sm4_u32_t rk)
178+
static LTC_INLINE sm4_u32_t F(sm4_u32_t X[4], sm4_u32_t rk)
179179
{
180180
return X[0] ^ T(X[1] ^ X[2] ^ X[3] ^ rk);
181181
}
182182

183183
/*
184184
* defined in section 7.1 (2) The reverse transformation
185185
*/
186-
static void R(sm4_u32_t Y[4], sm4_u32_t X[32+4])
186+
static LTC_INLINE void R(sm4_u32_t Y[4], sm4_u32_t X[32+4])
187187
{
188188
Y[0] = X[35];
189189
Y[1] = X[34];
@@ -194,7 +194,7 @@ static void R(sm4_u32_t Y[4], sm4_u32_t X[32+4])
194194
/*
195195
* defined in section 7.1 Encryption
196196
*/
197-
static void encrypt(sm4_u32_t Y[4], sm4_u32_t X[4+32], const sm4_u32_t rk[32])
197+
static LTC_INLINE void encrypt(sm4_u32_t Y[4], sm4_u32_t X[4+32], const sm4_u32_t rk[32])
198198
{
199199
int i;
200200

@@ -203,7 +203,7 @@ static void encrypt(sm4_u32_t Y[4], sm4_u32_t X[4+32], const sm4_u32_t rk[32])
203203
R(Y, X);
204204
}
205205

206-
static void sm4_setkey(struct sm4_key *sm4, const unsigned char *key)
206+
static LTC_INLINE void sm4_setkey(struct sm4_key *sm4, const unsigned char *key)
207207
{
208208
int i;
209209

@@ -229,7 +229,7 @@ int sm4_setup(const unsigned char *key, int keylen,
229229
/*
230230
* SM4 encryption.
231231
*/
232-
static void sm4_do(void *output, const void *input, const sm4_u32_t rk[32])
232+
static LTC_INLINE void sm4_do(void *output, const void *input, const sm4_u32_t rk[32])
233233
{
234234
sm4_u32_t Y[4];
235235
sm4_u32_t X[32+4];

0 commit comments

Comments
 (0)