Lines Matching refs:val
198 static int general_get_int(const OSSL_PARAM *p, void *val, size_t val_size) in general_get_int() argument
205 return signed_from_signed(val, val_size, p->data, p->data_size); in general_get_int()
207 return signed_from_unsigned(val, val_size, p->data, p->data_size); in general_get_int()
213 static int general_set_int(OSSL_PARAM *p, void *val, size_t val_size) in general_set_int() argument
221 r = signed_from_signed(p->data, p->data_size, val, val_size); in general_set_int()
223 r = unsigned_from_signed(p->data, p->data_size, val, val_size); in general_set_int()
231 static int general_get_uint(const OSSL_PARAM *p, void *val, size_t val_size) in general_get_uint() argument
239 return unsigned_from_signed(val, val_size, p->data, p->data_size); in general_get_uint()
241 return unsigned_from_unsigned(val, val_size, p->data, p->data_size); in general_get_uint()
247 static int general_set_uint(OSSL_PARAM *p, void *val, size_t val_size) in general_set_uint() argument
255 r = signed_from_unsigned(p->data, p->data_size, val, val_size); in general_set_uint()
257 r = unsigned_from_unsigned(p->data, p->data_size, val, val_size); in general_set_uint()
264 int OSSL_PARAM_get_int(const OSSL_PARAM *p, int *val) in OSSL_PARAM_get_int() argument
269 return OSSL_PARAM_get_int32(p, (int32_t *)val); in OSSL_PARAM_get_int()
271 return OSSL_PARAM_get_int64(p, (int64_t *)val); in OSSL_PARAM_get_int()
274 return general_get_int(p, val, sizeof(*val)); in OSSL_PARAM_get_int()
277 int OSSL_PARAM_set_int(OSSL_PARAM *p, int val) in OSSL_PARAM_set_int() argument
282 return OSSL_PARAM_set_int32(p, (int32_t)val); in OSSL_PARAM_set_int()
284 return OSSL_PARAM_set_int64(p, (int64_t)val); in OSSL_PARAM_set_int()
287 return general_set_int(p, &val, sizeof(val)); in OSSL_PARAM_set_int()
295 int OSSL_PARAM_get_uint(const OSSL_PARAM *p, unsigned int *val) in OSSL_PARAM_get_uint() argument
300 return OSSL_PARAM_get_uint32(p, (uint32_t *)val); in OSSL_PARAM_get_uint()
302 return OSSL_PARAM_get_uint64(p, (uint64_t *)val); in OSSL_PARAM_get_uint()
305 return general_get_uint(p, val, sizeof(*val)); in OSSL_PARAM_get_uint()
308 int OSSL_PARAM_set_uint(OSSL_PARAM *p, unsigned int val) in OSSL_PARAM_set_uint() argument
313 return OSSL_PARAM_set_uint32(p, (uint32_t)val); in OSSL_PARAM_set_uint()
315 return OSSL_PARAM_set_uint64(p, (uint64_t)val); in OSSL_PARAM_set_uint()
318 return general_set_uint(p, &val, sizeof(val)); in OSSL_PARAM_set_uint()
327 int OSSL_PARAM_get_long(const OSSL_PARAM *p, long int *val) in OSSL_PARAM_get_long() argument
332 return OSSL_PARAM_get_int32(p, (int32_t *)val); in OSSL_PARAM_get_long()
334 return OSSL_PARAM_get_int64(p, (int64_t *)val); in OSSL_PARAM_get_long()
337 return general_get_int(p, val, sizeof(*val)); in OSSL_PARAM_get_long()
340 int OSSL_PARAM_set_long(OSSL_PARAM *p, long int val) in OSSL_PARAM_set_long() argument
345 return OSSL_PARAM_set_int32(p, (int32_t)val); in OSSL_PARAM_set_long()
347 return OSSL_PARAM_set_int64(p, (int64_t)val); in OSSL_PARAM_set_long()
350 return general_set_int(p, &val, sizeof(val)); in OSSL_PARAM_set_long()
358 int OSSL_PARAM_get_ulong(const OSSL_PARAM *p, unsigned long int *val) in OSSL_PARAM_get_ulong() argument
363 return OSSL_PARAM_get_uint32(p, (uint32_t *)val); in OSSL_PARAM_get_ulong()
365 return OSSL_PARAM_get_uint64(p, (uint64_t *)val); in OSSL_PARAM_get_ulong()
368 return general_get_uint(p, val, sizeof(*val)); in OSSL_PARAM_get_ulong()
371 int OSSL_PARAM_set_ulong(OSSL_PARAM *p, unsigned long int val) in OSSL_PARAM_set_ulong() argument
376 return OSSL_PARAM_set_uint32(p, (uint32_t)val); in OSSL_PARAM_set_ulong()
378 return OSSL_PARAM_set_uint64(p, (uint64_t)val); in OSSL_PARAM_set_ulong()
381 return general_set_uint(p, &val, sizeof(val)); in OSSL_PARAM_set_ulong()
390 int OSSL_PARAM_get_int32(const OSSL_PARAM *p, int32_t *val) in OSSL_PARAM_get_int32() argument
392 if (val == NULL || p == NULL) { in OSSL_PARAM_get_int32()
408 *val = *(const int32_t *)p->data; in OSSL_PARAM_get_int32()
413 *val = (int32_t)i64; in OSSL_PARAM_get_int32()
420 return general_get_int(p, val, sizeof(*val)); in OSSL_PARAM_get_int32()
431 *val = (int32_t)u32; in OSSL_PARAM_get_int32()
439 *val = (int32_t)u64; in OSSL_PARAM_get_int32()
446 return general_get_int(p, val, sizeof(*val)); in OSSL_PARAM_get_int32()
456 *val = (int32_t)d; in OSSL_PARAM_get_int32()
470 int OSSL_PARAM_set_int32(OSSL_PARAM *p, int32_t val) in OSSL_PARAM_set_int32() argument
484 *(int32_t *)p->data = val; in OSSL_PARAM_set_int32()
488 *(int64_t *)p->data = (int64_t)val; in OSSL_PARAM_set_int32()
492 return general_set_int(p, &val, sizeof(val)); in OSSL_PARAM_set_int32()
493 } else if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER && val >= 0) { in OSSL_PARAM_set_int32()
500 *(uint32_t *)p->data = (uint32_t)val; in OSSL_PARAM_set_int32()
504 *(uint64_t *)p->data = (uint64_t)val; in OSSL_PARAM_set_int32()
508 return general_set_int(p, &val, sizeof(val)); in OSSL_PARAM_set_int32()
520 if (shift < 8 * sizeof(val) - 1) { in OSSL_PARAM_set_int32()
521 u32 = val < 0 ? -val : val; in OSSL_PARAM_set_int32()
527 *(double *)p->data = (double)val; in OSSL_PARAM_set_int32()
544 int OSSL_PARAM_get_uint32(const OSSL_PARAM *p, uint32_t *val) in OSSL_PARAM_get_uint32() argument
546 if (val == NULL || p == NULL) { in OSSL_PARAM_get_uint32()
562 *val = *(const uint32_t *)p->data; in OSSL_PARAM_get_uint32()
567 *val = (uint32_t)u64; in OSSL_PARAM_get_uint32()
574 return general_get_uint(p, val, sizeof(*val)); in OSSL_PARAM_get_uint32()
584 *val = i32; in OSSL_PARAM_get_uint32()
592 *val = (uint32_t)i64; in OSSL_PARAM_get_uint32()
602 return general_get_uint(p, val, sizeof(*val)); in OSSL_PARAM_get_uint32()
611 *val = (uint32_t)d; in OSSL_PARAM_get_uint32()
625 int OSSL_PARAM_set_uint32(OSSL_PARAM *p, uint32_t val) in OSSL_PARAM_set_uint32() argument
640 *(uint32_t *)p->data = val; in OSSL_PARAM_set_uint32()
644 *(uint64_t *)p->data = val; in OSSL_PARAM_set_uint32()
648 return general_set_uint(p, &val, sizeof(val)); in OSSL_PARAM_set_uint32()
656 if (val <= INT32_MAX) { in OSSL_PARAM_set_uint32()
657 *(int32_t *)p->data = (int32_t)val; in OSSL_PARAM_set_uint32()
664 *(int64_t *)p->data = (int64_t)val; in OSSL_PARAM_set_uint32()
668 return general_set_uint(p, &val, sizeof(val)); in OSSL_PARAM_set_uint32()
679 if (shift < 8 * sizeof(val) && (val >> shift) != 0) { in OSSL_PARAM_set_uint32()
683 *(double *)p->data = (double)val; in OSSL_PARAM_set_uint32()
700 int OSSL_PARAM_get_int64(const OSSL_PARAM *p, int64_t *val) in OSSL_PARAM_get_int64() argument
702 if (val == NULL || p == NULL) { in OSSL_PARAM_get_int64()
716 *val = *(const int32_t *)p->data; in OSSL_PARAM_get_int64()
719 *val = *(const int64_t *)p->data; in OSSL_PARAM_get_int64()
723 return general_get_int(p, val, sizeof(*val)); in OSSL_PARAM_get_int64()
730 *val = *(const uint32_t *)p->data; in OSSL_PARAM_get_int64()
735 *val = (int64_t)u64; in OSSL_PARAM_get_int64()
742 return general_get_int(p, val, sizeof(*val)); in OSSL_PARAM_get_int64()
758 *val = (int64_t)d; in OSSL_PARAM_get_int64()
772 int OSSL_PARAM_set_int64(OSSL_PARAM *p, int64_t val) in OSSL_PARAM_set_int64() argument
786 if (val >= INT32_MIN && val <= INT32_MAX) { in OSSL_PARAM_set_int64()
788 *(int32_t *)p->data = (int32_t)val; in OSSL_PARAM_set_int64()
794 *(int64_t *)p->data = val; in OSSL_PARAM_set_int64()
798 return general_set_int(p, &val, sizeof(val)); in OSSL_PARAM_set_int64()
799 } else if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER && val >= 0) { in OSSL_PARAM_set_int64()
806 if (val <= UINT32_MAX) { in OSSL_PARAM_set_int64()
808 *(uint32_t *)p->data = (uint32_t)val; in OSSL_PARAM_set_int64()
814 *(uint64_t *)p->data = (uint64_t)val; in OSSL_PARAM_set_int64()
818 return general_set_int(p, &val, sizeof(val)); in OSSL_PARAM_set_int64()
828 u64 = val < 0 ? -val : val; in OSSL_PARAM_set_int64()
830 *(double *)p->data = (double)val; in OSSL_PARAM_set_int64()
849 int OSSL_PARAM_get_uint64(const OSSL_PARAM *p, uint64_t *val) in OSSL_PARAM_get_uint64() argument
851 if (val == NULL || p == NULL) { in OSSL_PARAM_get_uint64()
865 *val = *(const uint32_t *)p->data; in OSSL_PARAM_get_uint64()
868 *val = *(const uint64_t *)p->data; in OSSL_PARAM_get_uint64()
872 return general_get_uint(p, val, sizeof(*val)); in OSSL_PARAM_get_uint64()
882 *val = (uint64_t)i32; in OSSL_PARAM_get_uint64()
890 *val = (uint64_t)i64; in OSSL_PARAM_get_uint64()
897 return general_get_uint(p, val, sizeof(*val)); in OSSL_PARAM_get_uint64()
913 *val = (uint64_t)d; in OSSL_PARAM_get_uint64()
927 int OSSL_PARAM_set_uint64(OSSL_PARAM *p, uint64_t val) in OSSL_PARAM_set_uint64() argument
942 if (val <= UINT32_MAX) { in OSSL_PARAM_set_uint64()
944 *(uint32_t *)p->data = (uint32_t)val; in OSSL_PARAM_set_uint64()
950 *(uint64_t *)p->data = val; in OSSL_PARAM_set_uint64()
954 return general_set_uint(p, &val, sizeof(val)); in OSSL_PARAM_set_uint64()
962 if (val <= INT32_MAX) { in OSSL_PARAM_set_uint64()
964 *(int32_t *)p->data = (int32_t)val; in OSSL_PARAM_set_uint64()
970 if (val <= INT64_MAX) { in OSSL_PARAM_set_uint64()
971 *(int64_t *)p->data = (int64_t)val; in OSSL_PARAM_set_uint64()
978 return general_set_uint(p, &val, sizeof(val)); in OSSL_PARAM_set_uint64()
984 if ((val >> real_shift()) == 0) { in OSSL_PARAM_set_uint64()
985 *(double *)p->data = (double)val; in OSSL_PARAM_set_uint64()
1005 int OSSL_PARAM_get_size_t(const OSSL_PARAM *p, size_t *val) in OSSL_PARAM_get_size_t() argument
1010 return OSSL_PARAM_get_uint32(p, (uint32_t *)val); in OSSL_PARAM_get_size_t()
1012 return OSSL_PARAM_get_uint64(p, (uint64_t *)val); in OSSL_PARAM_get_size_t()
1015 return general_get_uint(p, val, sizeof(*val)); in OSSL_PARAM_get_size_t()
1018 int OSSL_PARAM_set_size_t(OSSL_PARAM *p, size_t val) in OSSL_PARAM_set_size_t() argument
1023 return OSSL_PARAM_set_uint32(p, (uint32_t)val); in OSSL_PARAM_set_size_t()
1025 return OSSL_PARAM_set_uint64(p, (uint64_t)val); in OSSL_PARAM_set_size_t()
1028 return general_set_uint(p, &val, sizeof(val)); in OSSL_PARAM_set_size_t()
1037 int OSSL_PARAM_get_time_t(const OSSL_PARAM *p, time_t *val) in OSSL_PARAM_get_time_t() argument
1042 return OSSL_PARAM_get_int32(p, (int32_t *)val); in OSSL_PARAM_get_time_t()
1044 return OSSL_PARAM_get_int64(p, (int64_t *)val); in OSSL_PARAM_get_time_t()
1047 return general_get_int(p, val, sizeof(*val)); in OSSL_PARAM_get_time_t()
1050 int OSSL_PARAM_set_time_t(OSSL_PARAM *p, time_t val) in OSSL_PARAM_set_time_t() argument
1055 return OSSL_PARAM_set_int32(p, (int32_t)val); in OSSL_PARAM_set_time_t()
1057 return OSSL_PARAM_set_int64(p, (int64_t)val); in OSSL_PARAM_set_time_t()
1060 return general_set_int(p, &val, sizeof(val)); in OSSL_PARAM_set_time_t()
1068 int OSSL_PARAM_get_BN(const OSSL_PARAM *p, BIGNUM **val) in OSSL_PARAM_get_BN() argument
1072 if (val == NULL || p == NULL || p->data == NULL) { in OSSL_PARAM_get_BN()
1079 b = BN_native2bn(p->data, (int)p->data_size, *val); in OSSL_PARAM_get_BN()
1082 b = BN_signed_native2bn(p->data, (int)p->data_size, *val); in OSSL_PARAM_get_BN()
1094 *val = b; in OSSL_PARAM_get_BN()
1098 int OSSL_PARAM_set_BN(OSSL_PARAM *p, const BIGNUM *val) in OSSL_PARAM_set_BN() argument
1107 if (val == NULL) { in OSSL_PARAM_set_BN()
1111 if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER && BN_is_negative(val)) { in OSSL_PARAM_set_BN()
1116 bytes = (size_t)BN_num_bytes(val); in OSSL_PARAM_set_BN()
1132 if (BN_bn2nativepad(val, p->data, p->data_size) >= 0) in OSSL_PARAM_set_BN()
1137 if (BN_signed_bn2native(val, p->data, p->data_size) >= 0) in OSSL_PARAM_set_BN()
1159 int OSSL_PARAM_get_double(const OSSL_PARAM *p, double *val) in OSSL_PARAM_get_double() argument
1164 if (val == NULL || p == NULL || p->data == NULL) { in OSSL_PARAM_get_double()
1172 *val = *(const double *)p->data; in OSSL_PARAM_get_double()
1180 *val = *(const uint32_t *)p->data; in OSSL_PARAM_get_double()
1185 *val = (double)u64; in OSSL_PARAM_get_double()
1194 *val = *(const int32_t *)p->data; in OSSL_PARAM_get_double()
1200 *val = 0.0 + i64; in OSSL_PARAM_get_double()
1211 int OSSL_PARAM_set_double(OSSL_PARAM *p, double val) in OSSL_PARAM_set_double() argument
1225 *(double *)p->data = val; in OSSL_PARAM_set_double()
1234 if (val != (uint64_t)val) { in OSSL_PARAM_set_double()
1240 if (val >= 0 && val <= UINT32_MAX) { in OSSL_PARAM_set_double()
1242 *(uint32_t *)p->data = (uint32_t)val; in OSSL_PARAM_set_double()
1248 if (val >= 0 in OSSL_PARAM_set_double()
1254 && val < (double)(UINT64_MAX - 65535) + 65536.0) { in OSSL_PARAM_set_double()
1256 *(uint64_t *)p->data = (uint64_t)val; in OSSL_PARAM_set_double()
1266 if (val != (int64_t)val) { in OSSL_PARAM_set_double()
1272 if (val >= INT32_MIN && val <= INT32_MAX) { in OSSL_PARAM_set_double()
1274 *(int32_t *)p->data = (int32_t)val; in OSSL_PARAM_set_double()
1280 if (val >= INT64_MIN in OSSL_PARAM_set_double()
1286 && val < (double)(INT64_MAX - 65535) + 65536.0) { in OSSL_PARAM_set_double()
1288 *(int64_t *)p->data = (int64_t)val; in OSSL_PARAM_set_double()
1305 static int get_string_internal(const OSSL_PARAM *p, void **val, in get_string_internal() argument
1311 if ((val == NULL && used_len == NULL) || p == NULL) { in get_string_internal()
1335 if (val == NULL) in get_string_internal()
1338 if (*val == NULL) { in get_string_internal()
1343 *val = q; in get_string_internal()
1351 memcpy(*val, p->data, sz); in get_string_internal()
1355 int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val, size_t max_len) in OSSL_PARAM_get_utf8_string() argument
1357 int ret = get_string_internal(p, (void **)val, &max_len, NULL, in OSSL_PARAM_get_utf8_string()
1381 (*val)[data_length] = '\0'; in OSSL_PARAM_get_utf8_string()
1386 int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val, size_t max_len, in OSSL_PARAM_get_octet_string() argument
1389 return get_string_internal(p, val, &max_len, used_len, in OSSL_PARAM_get_octet_string()
1393 static int set_string_internal(OSSL_PARAM *p, const void *val, size_t len, in set_string_internal() argument
1408 memcpy(p->data, val, len); in set_string_internal()
1415 int OSSL_PARAM_set_utf8_string(OSSL_PARAM *p, const char *val) in OSSL_PARAM_set_utf8_string() argument
1423 if (val == NULL) { in OSSL_PARAM_set_utf8_string()
1427 return set_string_internal(p, val, strlen(val), OSSL_PARAM_UTF8_STRING); in OSSL_PARAM_set_utf8_string()
1430 int OSSL_PARAM_set_octet_string(OSSL_PARAM *p, const void *val, in OSSL_PARAM_set_octet_string() argument
1439 if (val == NULL) { in OSSL_PARAM_set_octet_string()
1443 return set_string_internal(p, val, len, OSSL_PARAM_OCTET_STRING); in OSSL_PARAM_set_octet_string()
1460 static int get_ptr_internal(const OSSL_PARAM *p, const void **val, in get_ptr_internal() argument
1463 if (val == NULL || p == NULL) { in get_ptr_internal()
1473 *val = *(const void **)p->data; in get_ptr_internal()
1477 int OSSL_PARAM_get_utf8_ptr(const OSSL_PARAM *p, const char **val) in OSSL_PARAM_get_utf8_ptr() argument
1479 return get_ptr_internal(p, (const void **)val, NULL, OSSL_PARAM_UTF8_PTR); in OSSL_PARAM_get_utf8_ptr()
1482 int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, const void **val, in OSSL_PARAM_get_octet_ptr() argument
1485 return get_ptr_internal(p, val, used_len, OSSL_PARAM_OCTET_PTR); in OSSL_PARAM_get_octet_ptr()
1488 static int set_ptr_internal(OSSL_PARAM *p, const void *val, in set_ptr_internal() argument
1497 *(const void **)p->data = val; in set_ptr_internal()
1501 int OSSL_PARAM_set_utf8_ptr(OSSL_PARAM *p, const char *val) in OSSL_PARAM_set_utf8_ptr() argument
1508 return set_ptr_internal(p, val, OSSL_PARAM_UTF8_PTR, in OSSL_PARAM_set_utf8_ptr()
1509 val == NULL ? 0 : strlen(val)); in OSSL_PARAM_set_utf8_ptr()
1512 int OSSL_PARAM_set_octet_ptr(OSSL_PARAM *p, const void *val, in OSSL_PARAM_set_octet_ptr() argument
1520 return set_ptr_internal(p, val, OSSL_PARAM_OCTET_PTR, used_len); in OSSL_PARAM_set_octet_ptr()
1647 static int get_string_ptr_internal(const OSSL_PARAM *p, const void **val, in get_string_ptr_internal() argument
1650 if (val == NULL || p == NULL) { in get_string_ptr_internal()
1660 *val = p->data; in get_string_ptr_internal()
1664 int OSSL_PARAM_get_utf8_string_ptr(const OSSL_PARAM *p, const char **val) in OSSL_PARAM_get_utf8_string_ptr() argument
1669 rv = OSSL_PARAM_get_utf8_ptr(p, val); in OSSL_PARAM_get_utf8_string_ptr()
1672 return rv || get_string_ptr_internal(p, (const void **)val, NULL, in OSSL_PARAM_get_utf8_string_ptr()
1676 int OSSL_PARAM_get_octet_string_ptr(const OSSL_PARAM *p, const void **val, in OSSL_PARAM_get_octet_string_ptr() argument
1682 rv = OSSL_PARAM_get_octet_ptr(p, val, used_len); in OSSL_PARAM_get_octet_string_ptr()
1685 return rv || get_string_ptr_internal(p, val, used_len, in OSSL_PARAM_get_octet_string_ptr()