diff options
author | jsing <> | 2022-09-06 06:17:11 +0000 |
---|---|---|
committer | jsing <> | 2022-09-06 06:17:11 +0000 |
commit | f0e3122a21e79caa85eafcc58661cc2e9020a2c3 (patch) | |
tree | b1acc4d2c886c46ea2c94592fad19dbf5af74a4e /src/lib/libcrypto/evp/e_sm4.c | |
parent | 3bcd5b5c64a6028d6e88df34c351cfa5acf3f475 (diff) | |
download | openbsd-f0e3122a21e79caa85eafcc58661cc2e9020a2c3.tar.gz openbsd-f0e3122a21e79caa85eafcc58661cc2e9020a2c3.tar.bz2 openbsd-f0e3122a21e79caa85eafcc58661cc2e9020a2c3.zip |
Stop casting a size_t to a long and then passing it as a size_t.
These cipher implementations take a size_t length argument, so stop
casting it to a long.
Found by Coverity.
ok tb@
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/evp/e_sm4.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/libcrypto/evp/e_sm4.c b/src/lib/libcrypto/evp/e_sm4.c index c4bbe567c5..4fecae9671 100644 --- a/src/lib/libcrypto/evp/e_sm4.c +++ b/src/lib/libcrypto/evp/e_sm4.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: e_sm4.c,v 1.4 2022/09/04 15:56:51 jsing Exp $ */ | 1 | /* $OpenBSD: e_sm4.c,v 1.5 2022/09/06 06:17:11 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2017, 2019 Ribose Inc | 3 | * Copyright (c) 2017, 2019 Ribose Inc |
4 | * | 4 | * |
@@ -78,14 +78,14 @@ static int | |||
78 | sm4_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | 78 | sm4_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) |
79 | { | 79 | { |
80 | while (inl >= EVP_MAXCHUNK) { | 80 | while (inl >= EVP_MAXCHUNK) { |
81 | sm4_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); | 81 | sm4_cbc_encrypt(in, out, EVP_MAXCHUNK, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); |
82 | inl -= EVP_MAXCHUNK; | 82 | inl -= EVP_MAXCHUNK; |
83 | in += EVP_MAXCHUNK; | 83 | in += EVP_MAXCHUNK; |
84 | out += EVP_MAXCHUNK; | 84 | out += EVP_MAXCHUNK; |
85 | } | 85 | } |
86 | 86 | ||
87 | if (inl) | 87 | if (inl) |
88 | sm4_cbc_encrypt(in, out, (long)inl, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); | 88 | sm4_cbc_encrypt(in, out, inl, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); |
89 | 89 | ||
90 | return 1; | 90 | return 1; |
91 | } | 91 | } |
@@ -99,7 +99,7 @@ sm4_cfb128_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char * | |||
99 | chunk = inl; | 99 | chunk = inl; |
100 | 100 | ||
101 | while (inl && inl >= chunk) { | 101 | while (inl && inl >= chunk) { |
102 | sm4_cfb128_encrypt(in, out, (long)inl, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 102 | sm4_cfb128_encrypt(in, out, inl, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); |
103 | inl -= chunk; | 103 | inl -= chunk; |
104 | in += chunk; | 104 | in += chunk; |
105 | out += chunk; | 105 | out += chunk; |
@@ -132,14 +132,14 @@ static int | |||
132 | sm4_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | 132 | sm4_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) |
133 | { | 133 | { |
134 | while (inl >= EVP_MAXCHUNK) { | 134 | while (inl >= EVP_MAXCHUNK) { |
135 | sm4_ofb128_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | 135 | sm4_ofb128_encrypt(in, out, EVP_MAXCHUNK, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); |
136 | inl -= EVP_MAXCHUNK; | 136 | inl -= EVP_MAXCHUNK; |
137 | in += EVP_MAXCHUNK; | 137 | in += EVP_MAXCHUNK; |
138 | out += EVP_MAXCHUNK; | 138 | out += EVP_MAXCHUNK; |
139 | } | 139 | } |
140 | 140 | ||
141 | if (inl) | 141 | if (inl) |
142 | sm4_ofb128_encrypt(in, out, (long)inl, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | 142 | sm4_ofb128_encrypt(in, out, inl, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); |
143 | 143 | ||
144 | return 1; | 144 | return 1; |
145 | } | 145 | } |