@@ -64,6 +64,7 @@ typedef struct {
6464
6565
6666static ssize_t fr_der_encode_oid_and_value (fr_dbuff_t * dbuff , fr_dcursor_t * cursor , fr_der_encode_ctx_t * encode_ctx ) CC_HINT (nonnull );
67+ static ssize_t fr_der_encode_choice (fr_dbuff_t * dbuff , fr_dcursor_t * cursor , fr_der_encode_ctx_t * encode_ctx ) CC_HINT (nonnull );
6768
6869/*
6970 * We have per-type function names to make it clear that different types have different encoders.
@@ -721,12 +722,7 @@ static ssize_t fr_der_encode_oid(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, UNUSED
721722
722723static ssize_t fr_der_encode_sequence (fr_dbuff_t * dbuff , fr_dcursor_t * cursor , fr_der_encode_ctx_t * encode_ctx )
723724{
724- fr_dbuff_t our_dbuff = FR_DBUFF (dbuff );
725- fr_pair_t const * vp ;
726- fr_da_stack_t da_stack ;
727- fr_dcursor_t child_cursor ;
728- ssize_t slen = 0 ;
729- unsigned int depth = 0 ;
725+ fr_pair_t * vp ;
730726
731727 vp = fr_dcursor_current (cursor );
732728 PAIR_VERIFY (vp );
@@ -751,26 +747,10 @@ static ssize_t fr_der_encode_sequence(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, f
751747 * value which is equal to its default value.
752748 */
753749 if (fr_type_is_group (vp -> vp_type ) && fr_der_flag_is_oid_and_value (vp -> da )) {
754- slen = fr_der_encode_oid_and_value (& our_dbuff , cursor , encode_ctx );
755- if (slen < 0 ) {
756- fr_strerror_printf ("Failed to encode OID value pair: %s" , fr_strerror ());
757- return -1 ;
758- }
759-
760- return fr_dbuff_set (dbuff , & our_dbuff );
750+ return fr_der_encode_oid_and_value (dbuff , cursor , encode_ctx );
761751 }
762752
763- fr_proto_da_stack_build (& da_stack , vp -> da );
764-
765- FR_PROTO_STACK_PRINT (& da_stack , depth );
766-
767- fr_pair_dcursor_child_iter_init (& child_cursor , & vp -> children , cursor );
768-
769- slen = fr_pair_cursor_to_network (& our_dbuff , & da_stack , depth , & child_cursor ,
770- encode_ctx , encode_pair );
771- if (slen < 0 ) return -1 ;
772-
773- return fr_dbuff_set (dbuff , & our_dbuff );
753+ return fr_der_encode_choice (dbuff , cursor , encode_ctx );
774754}
775755
776756typedef struct {
@@ -918,21 +898,12 @@ static ssize_t fr_der_encode_set(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, fr_der
918898 }
919899
920900 /*
921- * @todo - this gives a partial order. It does NOT sort by comparing the encoded data.
901+ * Children of a set are ordered by tag. However, as each tag can only be used once, this is a
902+ * unique order.
922903 */
923904 fr_pair_list_sort (& vp -> children , fr_der_pair_cmp_by_da_tag );
924905
925- fr_proto_da_stack_build (& da_stack , vp -> da );
926-
927- FR_PROTO_STACK_PRINT (& da_stack , depth );
928-
929- fr_pair_dcursor_child_iter_init (& child_cursor , & vp -> children , cursor );
930-
931- slen = fr_pair_cursor_to_network (& our_dbuff , & da_stack , depth , & child_cursor , encode_ctx ,
932- encode_pair );
933- if (slen < 0 ) return -1 ;
934-
935- return fr_dbuff_set (dbuff , & our_dbuff );
906+ return fr_der_encode_choice (dbuff , cursor , encode_ctx );
936907}
937908
938909static ssize_t fr_der_encode_utc_time (fr_dbuff_t * dbuff , fr_dcursor_t * cursor , UNUSED fr_der_encode_ctx_t * encode_ctx )
0 commit comments