Lines Matching refs:p
53 OSSL_PARAM *OSSL_PARAM_locate(OSSL_PARAM *p, const char *key) in OSSL_PARAM_locate() argument
55 if (p != NULL && key != NULL) in OSSL_PARAM_locate()
56 for (; p->key != NULL; p++) in OSSL_PARAM_locate()
57 if (strcmp(key, p->key) == 0) in OSSL_PARAM_locate()
58 return p; in OSSL_PARAM_locate()
62 const OSSL_PARAM *OSSL_PARAM_locate_const(const OSSL_PARAM *p, const char *key) in OSSL_PARAM_locate_const() argument
64 return OSSL_PARAM_locate((OSSL_PARAM *)p, key); in OSSL_PARAM_locate_const()
80 int OSSL_PARAM_modified(const OSSL_PARAM *p) in OSSL_PARAM_modified() argument
82 return p != NULL && p->return_size != OSSL_PARAM_UNMODIFIED; in OSSL_PARAM_modified()
85 void OSSL_PARAM_set_all_unmodified(OSSL_PARAM *p) in OSSL_PARAM_set_all_unmodified() argument
87 if (p != NULL) in OSSL_PARAM_set_all_unmodified()
88 while (p->key != NULL) in OSSL_PARAM_set_all_unmodified()
89 p++->return_size = OSSL_PARAM_UNMODIFIED; in OSSL_PARAM_set_all_unmodified()
102 static int check_sign_bytes(const unsigned char *p, size_t n, unsigned char s) in check_sign_bytes() argument
107 if (p[i] != s) in check_sign_bytes()
198 static int general_get_int(const OSSL_PARAM *p, void *val, size_t val_size) in general_get_int() argument
200 if (p->data == NULL) { in general_get_int()
204 if (p->data_type == OSSL_PARAM_INTEGER) in general_get_int()
205 return signed_from_signed(val, val_size, p->data, p->data_size); in general_get_int()
206 if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER) 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
217 p->return_size = val_size; /* Expected size */ in general_set_int()
218 if (p->data == NULL) in general_set_int()
220 if (p->data_type == OSSL_PARAM_INTEGER) in general_set_int()
221 r = signed_from_signed(p->data, p->data_size, val, val_size); in general_set_int()
222 else if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER) in general_set_int()
223 r = unsigned_from_signed(p->data, p->data_size, val, val_size); in general_set_int()
226 p->return_size = r ? p->data_size : 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
234 if (p->data == NULL) { in general_get_uint()
238 if (p->data_type == OSSL_PARAM_INTEGER) in general_get_uint()
239 return unsigned_from_signed(val, val_size, p->data, p->data_size); in general_get_uint()
240 if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER) 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
251 p->return_size = val_size; /* Expected size */ in general_set_uint()
252 if (p->data == NULL) in general_set_uint()
254 if (p->data_type == OSSL_PARAM_INTEGER) in general_set_uint()
255 r = signed_from_unsigned(p->data, p->data_size, val, val_size); in general_set_uint()
256 else if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER) in general_set_uint()
257 r = unsigned_from_unsigned(p->data, p->data_size, val, val_size); in general_set_uint()
260 p->return_size = r ? p->data_size : 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()
397 if (p->data == NULL) { in OSSL_PARAM_get_int32()
402 if (p->data_type == OSSL_PARAM_INTEGER) { in OSSL_PARAM_get_int32()
406 switch (p->data_size) { in OSSL_PARAM_get_int32()
408 *val = *(const int32_t *)p->data; in OSSL_PARAM_get_int32()
411 i64 = *(const int64_t *)p->data; in OSSL_PARAM_get_int32()
420 return general_get_int(p, val, sizeof(*val)); in OSSL_PARAM_get_int32()
422 } else if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER) { in OSSL_PARAM_get_int32()
427 switch (p->data_size) { in OSSL_PARAM_get_int32()
429 u32 = *(const uint32_t *)p->data; in OSSL_PARAM_get_int32()
437 u64 = *(const uint64_t *)p->data; in OSSL_PARAM_get_int32()
446 return general_get_int(p, val, sizeof(*val)); in OSSL_PARAM_get_int32()
448 } else if (p->data_type == OSSL_PARAM_REAL) { in OSSL_PARAM_get_int32()
452 switch (p->data_size) { in OSSL_PARAM_get_int32()
454 d = *(const double *)p->data; in OSSL_PARAM_get_int32()
470 int OSSL_PARAM_set_int32(OSSL_PARAM *p, int32_t val) in OSSL_PARAM_set_int32() argument
472 if (p == NULL) { in OSSL_PARAM_set_int32()
476 p->return_size = 0; in OSSL_PARAM_set_int32()
477 if (p->data_type == OSSL_PARAM_INTEGER) { in OSSL_PARAM_set_int32()
479 p->return_size = sizeof(int32_t); /* Minimum expected size */ in OSSL_PARAM_set_int32()
480 if (p->data == NULL) in OSSL_PARAM_set_int32()
482 switch (p->data_size) { in OSSL_PARAM_set_int32()
484 *(int32_t *)p->data = val; in OSSL_PARAM_set_int32()
487 p->return_size = sizeof(int64_t); 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()
495 p->return_size = sizeof(uint32_t); /* Minimum expected size */ in OSSL_PARAM_set_int32()
496 if (p->data == NULL) in OSSL_PARAM_set_int32()
498 switch (p->data_size) { in OSSL_PARAM_set_int32()
500 *(uint32_t *)p->data = (uint32_t)val; in OSSL_PARAM_set_int32()
503 p->return_size = sizeof(uint64_t); 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()
509 } else if (p->data_type == OSSL_PARAM_REAL) { in OSSL_PARAM_set_int32()
514 p->return_size = sizeof(double); in OSSL_PARAM_set_int32()
515 if (p->data == NULL) in OSSL_PARAM_set_int32()
517 switch (p->data_size) { 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()
551 if (p->data == NULL) { in OSSL_PARAM_get_uint32()
556 if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER) { in OSSL_PARAM_get_uint32()
560 switch (p->data_size) { in OSSL_PARAM_get_uint32()
562 *val = *(const uint32_t *)p->data; in OSSL_PARAM_get_uint32()
565 u64 = *(const uint64_t *)p->data; in OSSL_PARAM_get_uint32()
574 return general_get_uint(p, val, sizeof(*val)); in OSSL_PARAM_get_uint32()
575 } else if (p->data_type == OSSL_PARAM_INTEGER) { in OSSL_PARAM_get_uint32()
580 switch (p->data_size) { in OSSL_PARAM_get_uint32()
582 i32 = *(const int32_t *)p->data; in OSSL_PARAM_get_uint32()
590 i64 = *(const int64_t *)p->data; in OSSL_PARAM_get_uint32()
602 return general_get_uint(p, val, sizeof(*val)); in OSSL_PARAM_get_uint32()
603 } else if (p->data_type == OSSL_PARAM_REAL) { in OSSL_PARAM_get_uint32()
607 switch (p->data_size) { in OSSL_PARAM_get_uint32()
609 d = *(const double *)p->data; in OSSL_PARAM_get_uint32()
625 int OSSL_PARAM_set_uint32(OSSL_PARAM *p, uint32_t val) in OSSL_PARAM_set_uint32() argument
627 if (p == NULL) { in OSSL_PARAM_set_uint32()
631 p->return_size = 0; in OSSL_PARAM_set_uint32()
633 if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER) { in OSSL_PARAM_set_uint32()
635 p->return_size = sizeof(uint32_t); /* Minimum expected size */ in OSSL_PARAM_set_uint32()
636 if (p->data == NULL) in OSSL_PARAM_set_uint32()
638 switch (p->data_size) { in OSSL_PARAM_set_uint32()
640 *(uint32_t *)p->data = val; in OSSL_PARAM_set_uint32()
643 p->return_size = sizeof(uint64_t); 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()
649 } else if (p->data_type == OSSL_PARAM_INTEGER) { in OSSL_PARAM_set_uint32()
651 p->return_size = sizeof(int32_t); /* Minimum expected size */ in OSSL_PARAM_set_uint32()
652 if (p->data == NULL) in OSSL_PARAM_set_uint32()
654 switch (p->data_size) { in OSSL_PARAM_set_uint32()
657 *(int32_t *)p->data = (int32_t)val; in OSSL_PARAM_set_uint32()
663 p->return_size = sizeof(int64_t); 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()
669 } else if (p->data_type == OSSL_PARAM_REAL) { in OSSL_PARAM_set_uint32()
673 p->return_size = sizeof(double); in OSSL_PARAM_set_uint32()
674 if (p->data == NULL) in OSSL_PARAM_set_uint32()
676 switch (p->data_size) { 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()
707 if (p->data == NULL) { in OSSL_PARAM_get_int64()
712 if (p->data_type == OSSL_PARAM_INTEGER) { in OSSL_PARAM_get_int64()
714 switch (p->data_size) { 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()
724 } else if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER) { in OSSL_PARAM_get_int64()
728 switch (p->data_size) { in OSSL_PARAM_get_int64()
730 *val = *(const uint32_t *)p->data; in OSSL_PARAM_get_int64()
733 u64 = *(const uint64_t *)p->data; in OSSL_PARAM_get_int64()
742 return general_get_int(p, val, sizeof(*val)); in OSSL_PARAM_get_int64()
743 } else if (p->data_type == OSSL_PARAM_REAL) { in OSSL_PARAM_get_int64()
747 switch (p->data_size) { in OSSL_PARAM_get_int64()
749 d = *(const double *)p->data; in OSSL_PARAM_get_int64()
772 int OSSL_PARAM_set_int64(OSSL_PARAM *p, int64_t val) in OSSL_PARAM_set_int64() argument
774 if (p == NULL) { in OSSL_PARAM_set_int64()
778 p->return_size = 0; in OSSL_PARAM_set_int64()
779 if (p->data_type == OSSL_PARAM_INTEGER) { in OSSL_PARAM_set_int64()
781 p->return_size = sizeof(int64_t); /* Expected size */ in OSSL_PARAM_set_int64()
782 if (p->data == NULL) in OSSL_PARAM_set_int64()
784 switch (p->data_size) { in OSSL_PARAM_set_int64()
787 p->return_size = sizeof(int32_t); 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()
801 p->return_size = sizeof(uint64_t); /* Expected size */ in OSSL_PARAM_set_int64()
802 if (p->data == NULL) in OSSL_PARAM_set_int64()
804 switch (p->data_size) { in OSSL_PARAM_set_int64()
807 p->return_size = sizeof(uint32_t); 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()
819 } else if (p->data_type == OSSL_PARAM_REAL) { in OSSL_PARAM_set_int64()
823 p->return_size = sizeof(double); in OSSL_PARAM_set_int64()
824 if (p->data == NULL) in OSSL_PARAM_set_int64()
826 switch (p->data_size) { 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()
856 if (p->data == NULL) { in OSSL_PARAM_get_uint64()
861 if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER) { in OSSL_PARAM_get_uint64()
863 switch (p->data_size) { 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()
873 } else if (p->data_type == OSSL_PARAM_INTEGER) { in OSSL_PARAM_get_uint64()
878 switch (p->data_size) { in OSSL_PARAM_get_uint64()
880 i32 = *(const int32_t *)p->data; in OSSL_PARAM_get_uint64()
888 i64 = *(const int64_t *)p->data; in OSSL_PARAM_get_uint64()
897 return general_get_uint(p, val, sizeof(*val)); in OSSL_PARAM_get_uint64()
898 } else if (p->data_type == OSSL_PARAM_REAL) { in OSSL_PARAM_get_uint64()
902 switch (p->data_size) { in OSSL_PARAM_get_uint64()
904 d = *(const double *)p->data; in OSSL_PARAM_get_uint64()
927 int OSSL_PARAM_set_uint64(OSSL_PARAM *p, uint64_t val) in OSSL_PARAM_set_uint64() argument
929 if (p == NULL) { in OSSL_PARAM_set_uint64()
933 p->return_size = 0; in OSSL_PARAM_set_uint64()
935 if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER) { in OSSL_PARAM_set_uint64()
937 p->return_size = sizeof(uint64_t); /* Expected size */ in OSSL_PARAM_set_uint64()
938 if (p->data == NULL) in OSSL_PARAM_set_uint64()
940 switch (p->data_size) { in OSSL_PARAM_set_uint64()
943 p->return_size = sizeof(uint32_t); 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()
955 } else if (p->data_type == OSSL_PARAM_INTEGER) { in OSSL_PARAM_set_uint64()
957 p->return_size = sizeof(int64_t); /* Expected size */ in OSSL_PARAM_set_uint64()
958 if (p->data == NULL) in OSSL_PARAM_set_uint64()
960 switch (p->data_size) { in OSSL_PARAM_set_uint64()
963 p->return_size = sizeof(int32_t); in OSSL_PARAM_set_uint64()
964 *(int32_t *)p->data = (int32_t)val; 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()
979 } else if (p->data_type == OSSL_PARAM_REAL) { in OSSL_PARAM_set_uint64()
981 p->return_size = sizeof(double); in OSSL_PARAM_set_uint64()
982 switch (p->data_size) { 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()
1077 switch (p->data_type) { 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()
1098 int OSSL_PARAM_set_BN(OSSL_PARAM *p, const BIGNUM *val) in OSSL_PARAM_set_BN() argument
1102 if (p == NULL) { in OSSL_PARAM_set_BN()
1106 p->return_size = 0; in OSSL_PARAM_set_BN()
1111 if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER && BN_is_negative(val)) { in OSSL_PARAM_set_BN()
1118 if (p->data_type == OSSL_PARAM_INTEGER) in OSSL_PARAM_set_BN()
1124 p->return_size = bytes; in OSSL_PARAM_set_BN()
1125 if (p->data == NULL) in OSSL_PARAM_set_BN()
1127 if (p->data_size >= bytes) { in OSSL_PARAM_set_BN()
1128 p->return_size = p->data_size; in OSSL_PARAM_set_BN()
1130 switch (p->data_type) { 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()
1169 if (p->data_type == OSSL_PARAM_REAL) { in OSSL_PARAM_get_double()
1170 switch (p->data_size) { in OSSL_PARAM_get_double()
1172 *val = *(const double *)p->data; in OSSL_PARAM_get_double()
1177 } else if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER) { in OSSL_PARAM_get_double()
1178 switch (p->data_size) { in OSSL_PARAM_get_double()
1180 *val = *(const uint32_t *)p->data; in OSSL_PARAM_get_double()
1183 u64 = *(const uint64_t *)p->data; in OSSL_PARAM_get_double()
1191 } else if (p->data_type == OSSL_PARAM_INTEGER) { in OSSL_PARAM_get_double()
1192 switch (p->data_size) { in OSSL_PARAM_get_double()
1194 *val = *(const int32_t *)p->data; in OSSL_PARAM_get_double()
1197 i64 = *(const int64_t *)p->data; in OSSL_PARAM_get_double()
1211 int OSSL_PARAM_set_double(OSSL_PARAM *p, double val) in OSSL_PARAM_set_double() argument
1213 if (p == NULL) { in OSSL_PARAM_set_double()
1217 p->return_size = 0; in OSSL_PARAM_set_double()
1219 if (p->data_type == OSSL_PARAM_REAL) { in OSSL_PARAM_set_double()
1220 p->return_size = sizeof(double); in OSSL_PARAM_set_double()
1221 if (p->data == NULL) in OSSL_PARAM_set_double()
1223 switch (p->data_size) { in OSSL_PARAM_set_double()
1225 *(double *)p->data = val; in OSSL_PARAM_set_double()
1230 } else if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER) { in OSSL_PARAM_set_double()
1231 p->return_size = sizeof(double); in OSSL_PARAM_set_double()
1232 if (p->data == NULL) in OSSL_PARAM_set_double()
1238 switch (p->data_size) { in OSSL_PARAM_set_double()
1241 p->return_size = sizeof(uint32_t); in OSSL_PARAM_set_double()
1242 *(uint32_t *)p->data = (uint32_t)val; in OSSL_PARAM_set_double()
1255 p->return_size = sizeof(uint64_t); in OSSL_PARAM_set_double()
1256 *(uint64_t *)p->data = (uint64_t)val; in OSSL_PARAM_set_double()
1262 } else if (p->data_type == OSSL_PARAM_INTEGER) { in OSSL_PARAM_set_double()
1263 p->return_size = sizeof(double); in OSSL_PARAM_set_double()
1264 if (p->data == NULL) in OSSL_PARAM_set_double()
1270 switch (p->data_size) { in OSSL_PARAM_set_double()
1273 p->return_size = sizeof(int32_t); in OSSL_PARAM_set_double()
1274 *(int32_t *)p->data = (int32_t)val; in OSSL_PARAM_set_double()
1287 p->return_size = sizeof(int64_t); 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()
1315 if (p->data_type != type) { in get_string_internal()
1320 sz = p->data_size; in get_string_internal()
1330 if (p->data == NULL) { 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()
1371 size_t data_length = p->data_size; in OSSL_PARAM_get_utf8_string()
1376 data_length = OPENSSL_strnlen(p->data, data_length); 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
1396 p->return_size = len; in set_string_internal()
1397 if (p->data == NULL) in set_string_internal()
1399 if (p->data_type != type) { in set_string_internal()
1403 if (p->data_size < len) { in set_string_internal()
1408 memcpy(p->data, val, len); in set_string_internal()
1410 if (type == OSSL_PARAM_UTF8_STRING && p->data_size > len) in set_string_internal()
1411 ((char *)p->data)[len] = '\0'; in set_string_internal()
1415 int OSSL_PARAM_set_utf8_string(OSSL_PARAM *p, const char *val) in OSSL_PARAM_set_utf8_string() argument
1417 if (p == NULL) { in OSSL_PARAM_set_utf8_string()
1422 p->return_size = 0; 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
1433 if (p == NULL) { in OSSL_PARAM_set_octet_string()
1438 p->return_size = 0; 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()
1467 if (p->data_type != type) { in get_ptr_internal()
1472 *used_len = p->data_size; 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
1491 p->return_size = len; in set_ptr_internal()
1492 if (p->data_type != type) { in set_ptr_internal()
1496 if (p->data != NULL) in set_ptr_internal()
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
1503 if (p == NULL) { in OSSL_PARAM_set_utf8_ptr()
1507 p->return_size = 0; in OSSL_PARAM_set_utf8_ptr()
1508 return set_ptr_internal(p, val, OSSL_PARAM_UTF8_PTR, 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
1515 if (p == NULL) { in OSSL_PARAM_set_octet_ptr()
1519 p->return_size = 0; in OSSL_PARAM_set_octet_ptr()
1520 return set_ptr_internal(p, val, OSSL_PARAM_OCTET_PTR, used_len); in OSSL_PARAM_set_octet_ptr()
1547 const OSSL_PARAM *p = OSSL_PARAM_locate_const(params, name); in ossl_param_get1_octet_string() local
1551 if (p == NULL) in ossl_param_get1_octet_string()
1554 if (p->data != NULL in ossl_param_get1_octet_string()
1555 && p->data_size > 0 in ossl_param_get1_octet_string()
1556 && !OSSL_PARAM_get_octet_string(p, &buf, 0, &len)) in ossl_param_get1_octet_string()
1565 static int setbuf_fromparams(const OSSL_PARAM *p, const char *name, in setbuf_fromparams() argument
1579 for (; p != NULL; p = OSSL_PARAM_locate_const(p + 1, name)) { in setbuf_fromparams()
1580 if (p->data_type != OSSL_PARAM_OCTET_STRING) in setbuf_fromparams()
1582 if (p->data != NULL in setbuf_fromparams()
1583 && p->data_size != 0 in setbuf_fromparams()
1584 && !WPACKET_memcpy(&pkt, p->data, p->data_size)) in setbuf_fromparams()
1600 const OSSL_PARAM *p = OSSL_PARAM_locate_const(params, name); in ossl_param_get1_concat_octet_string() local
1604 if (p == NULL) in ossl_param_get1_concat_octet_string()
1608 if (!setbuf_fromparams(p, name, NULL, &sz)) in ossl_param_get1_concat_octet_string()
1628 if (!setbuf_fromparams(p, name, res, &sz)) { in ossl_param_get1_concat_octet_string()
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()
1654 if (p->data_type != type) { in get_string_ptr_internal()
1659 *used_len = p->data_size; 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()