Changeset 105949 in vbox for trunk/src/libs/openssl-3.1.7/crypto/evp/pmeth_lib.c
- Timestamp:
- Sep 4, 2024 12:53:14 PM (6 months ago)
- svn:sync-xref-src-repo-rev:
- 164683
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/openssl-3.1.7/crypto/evp/pmeth_lib.c
r105945 r105949 1 1 /* 2 * Copyright 2006-202 4The OpenSSL Project Authors. All Rights Reserved.2 * Copyright 2006-2023 The OpenSSL Project Authors. All Rights Reserved. 3 3 * 4 4 * Licensed under the Apache License 2.0 (the "License"). You may not use … … 1029 1029 } 1030 1030 1031 static int evp_pkey_ctx_add1_octet_string(EVP_PKEY_CTX *ctx, int fallback,1032 const char *param, int op, int ctrl,1033 const unsigned char *data,1034 int datalen)1035 {1036 OSSL_PARAM os_params[2];1037 const OSSL_PARAM *gettables;1038 unsigned char *info = NULL;1039 size_t info_len = 0;1040 size_t info_alloc = 0;1041 int ret = 0;1042 1043 if (ctx == NULL || (ctx->operation & op) == 0) {1044 ERR_raise(ERR_LIB_EVP, EVP_R_COMMAND_NOT_SUPPORTED);1045 /* Uses the same return values as EVP_PKEY_CTX_ctrl */1046 return -2;1047 }1048 1049 /* Code below to be removed when legacy support is dropped. */1050 if (fallback)1051 return EVP_PKEY_CTX_ctrl(ctx, -1, op, ctrl, datalen, (void *)(data));1052 /* end of legacy support */1053 1054 if (datalen < 0) {1055 ERR_raise(ERR_LIB_EVP, EVP_R_INVALID_LENGTH);1056 return 0;1057 } else if (datalen == 0) {1058 return 1;1059 }1060 1061 /* Check for older provider that doesn't support getting this parameter */1062 gettables = EVP_PKEY_CTX_gettable_params(ctx);1063 if (gettables == NULL || OSSL_PARAM_locate_const(gettables, param) == NULL)1064 return evp_pkey_ctx_set1_octet_string(ctx, fallback, param, op, ctrl,1065 data, datalen);1066 1067 /* Get the original value length */1068 os_params[0] = OSSL_PARAM_construct_octet_string(param, NULL, 0);1069 os_params[1] = OSSL_PARAM_construct_end();1070 1071 if (!EVP_PKEY_CTX_get_params(ctx, os_params))1072 return 0;1073 1074 /* This should not happen but check to be sure. */1075 if (os_params[0].return_size == OSSL_PARAM_UNMODIFIED)1076 return 0;1077 1078 info_alloc = os_params[0].return_size + datalen;1079 if (info_alloc == 0)1080 return 0;1081 info = OPENSSL_zalloc(info_alloc);1082 if (info == NULL)1083 return 0;1084 info_len = os_params[0].return_size;1085 1086 os_params[0] = OSSL_PARAM_construct_octet_string(param, info, info_alloc);1087 1088 /* if we have data, then go get it */1089 if (info_len > 0) {1090 if (!EVP_PKEY_CTX_get_params(ctx, os_params))1091 goto error;1092 }1093 1094 /* Copy the input data */1095 memcpy(&info[info_len], data, datalen);1096 ret = EVP_PKEY_CTX_set_params(ctx, os_params);1097 1098 error:1099 OPENSSL_clear_free(info, info_alloc);1100 return ret;1101 }1102 1103 1031 int EVP_PKEY_CTX_set1_tls1_prf_secret(EVP_PKEY_CTX *ctx, 1104 1032 const unsigned char *sec, int seclen) … … 1151 1079 const unsigned char *info, int infolen) 1152 1080 { 1153 return evp_pkey_ctx_ add1_octet_string(ctx, ctx->op.kex.algctx == NULL,1081 return evp_pkey_ctx_set1_octet_string(ctx, ctx->op.kex.algctx == NULL, 1154 1082 OSSL_KDF_PARAM_INFO, 1155 1083 EVP_PKEY_OP_DERIVE,
Note:
See TracChangeset
for help on using the changeset viewer.