Commit 5b7171f
Make some more half-empty EVP_PKEY states impossible
EVP_PKEY_{assign,set1}_FOO would check for NULL, return an error, but
still leave the EVP_PKEY assigned to that type on failure. Check for
NULL first, so that we don't leave it in that state.
I originally did this with a slightly more ambitious goal of also
banning EVP_PKEY_set1_EC_KEY if the EC_KEY has no parameters. That was
so that, in the happy future where we have EVP_PKEY_ALGs for P-256 and
P-384, EVP_PKEY_ASN1_METHOD would simply be renamed EVP_PKEY_ALG and
every key would have an associated EVP_PKEY_ALG.
For that to work, EVP_PKEY_set1_EC_KEY must never be ambiguous about
which EVP_PKEY_ALG to associate with the EVP_PKEY.
However, the existence of custom EC_GROUPs throws a spanner in that.
We need to support EVP_PKEY_set1_EC_KEY with an custom EC_GROUP (at
least until we manage to get Conscrypt to stop using this function). So,
at least for now, I'm thinking we say that EVP_PKEY_ALGs point to
EVP_PKEY_ASN1_METHODs but you can't go from EVP_PKEY back to
EVP_PKEY_ALG, and we'll see how irksome of an API that becomes.
(We can always go back to this idea later. The custom EC_GROUPs thing
isn't fatal if EC_KEYs with funny EC_GROUPs map to some goofy private
EVP_PKEY_ALG that can't parse anything.)
Still, half-empty states are generally bad, so I'm going to keep this
change on the branch and see if we can get it to stick.
Update-Note: Some half-empty, invalid EVP_PKEY states are now
impossible. Running through tests, no callers were tripping this. There
seems to be no legitimate reason to do this.
Bug: 42290409
Change-Id: I0211a38ab62268a05e3ff1d138a092e4feec10b1
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/81549
Reviewed-by: Lily Chen <chlily@google.com>
Commit-Queue: David Benjamin <davidben@google.com>1 parent 9b602f2 commit 5b7171f
File tree
5 files changed
+24
-4
lines changed- crypto/evp
5 files changed
+24
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1253 | 1253 | | |
1254 | 1254 | | |
1255 | 1255 | | |
| 1256 | + | |
| 1257 | + | |
1256 | 1258 | | |
1257 | 1259 | | |
1258 | 1260 | | |
| 1261 | + | |
| 1262 | + | |
1259 | 1263 | | |
1260 | 1264 | | |
1261 | 1265 | | |
| 1266 | + | |
| 1267 | + | |
1262 | 1268 | | |
1263 | 1269 | | |
1264 | 1270 | | |
| 1271 | + | |
| 1272 | + | |
1265 | 1273 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
123 | 126 | | |
124 | 127 | | |
125 | | - | |
| 128 | + | |
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
254 | 257 | | |
255 | 258 | | |
256 | | - | |
| 259 | + | |
257 | 260 | | |
258 | 261 | | |
259 | 262 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
268 | 271 | | |
269 | 272 | | |
270 | | - | |
| 273 | + | |
271 | 274 | | |
272 | 275 | | |
273 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
179 | 182 | | |
180 | 183 | | |
181 | | - | |
| 184 | + | |
182 | 185 | | |
183 | 186 | | |
184 | 187 | | |
| |||
0 commit comments