@@ -725,7 +725,6 @@ static ssize_t fr_der_encode_sequence(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, f
725725 fr_pair_t const * vp ;
726726 fr_da_stack_t da_stack ;
727727 fr_dcursor_t child_cursor ;
728- fr_dict_attr_t const * ref = NULL ;
729728 ssize_t slen = 0 ;
730729 unsigned int depth = 0 ;
731730
@@ -751,28 +750,14 @@ static ssize_t fr_der_encode_sequence(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, f
751750 * The encoding of a set value or sequence value shall not include an encoding for any component
752751 * value which is equal to its default value.
753752 */
754- if (fr_type_is_group (vp -> vp_type )) {
755- /*
756- * Groups could be also be a pair, so we need to check for that.
757- */
758- if (fr_der_flag_is_oid_and_value (vp -> da )) {
759- slen = fr_der_encode_oid_and_value (& our_dbuff , cursor , encode_ctx );
760- if (slen < 0 ) {
761- fr_strerror_printf ("Failed to encode OID value pair: %s" , fr_strerror ());
762- return -1 ;
763- }
764-
765- return fr_dbuff_set (dbuff , & our_dbuff );
766- }
767-
768- /*
769- * The group can also change it's root, but having a ref.
770- */
771- ref = fr_dict_attr_ref (vp -> da );
772- if (ref && (ref -> dict != dict_der )) {
773- fr_strerror_printf ("Group %s is not a DER group" , ref -> name );
753+ 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 ());
774757 return -1 ;
775758 }
759+
760+ return fr_dbuff_set (dbuff , & our_dbuff );
776761 }
777762
778763 fr_proto_da_stack_build (& da_stack , vp -> da );
@@ -781,14 +766,9 @@ static ssize_t fr_der_encode_sequence(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, f
781766
782767 fr_pair_dcursor_child_iter_init (& child_cursor , & vp -> children , cursor );
783768
784- while (fr_dcursor_current (& child_cursor )) {
785- slen = fr_pair_cursor_to_network (& our_dbuff , & da_stack , depth , & child_cursor ,
786- encode_ctx , encode_pair );
787- if (slen < 0 ) {
788- fr_strerror_printf ("Failed to encode pair: %s" , fr_strerror ());
789- return -1 ;
790- }
791- }
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 ;
792772
793773 return fr_dbuff_set (dbuff , & our_dbuff );
794774}
@@ -948,14 +928,9 @@ static ssize_t fr_der_encode_set(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, fr_der
948928
949929 fr_pair_dcursor_child_iter_init (& child_cursor , & vp -> children , cursor );
950930
951- while (fr_dcursor_current (& child_cursor )) {
952- slen = fr_pair_cursor_to_network (& our_dbuff , & da_stack , depth , & child_cursor , encode_ctx ,
931+ slen = fr_pair_cursor_to_network (& our_dbuff , & da_stack , depth , & child_cursor , encode_ctx ,
953932 encode_pair );
954- if (slen < 0 ) {
955- fr_strerror_printf ("Failed to encode pair: %s" , fr_strerror ());
956- return -1 ;
957- }
958- }
933+ if (slen < 0 ) return -1 ;
959934
960935 return fr_dbuff_set (dbuff , & our_dbuff );
961936}
@@ -1177,14 +1152,9 @@ static ssize_t fr_der_encode_choice(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, fr_
11771152
11781153 fr_pair_dcursor_child_iter_init (& child_cursor , & vp -> children , cursor );
11791154
1180- do {
1181- slen = fr_pair_cursor_to_network (& our_dbuff , & da_stack , depth , & child_cursor , encode_ctx ,
1182- encode_pair );
1183- if (unlikely (slen < 0 )) {
1184- fr_strerror_printf ("Failed to encode pair: %s" , fr_strerror ());
1185- return slen ;
1186- }
1187- } while (fr_dcursor_next (& child_cursor ));
1155+ slen = fr_pair_cursor_to_network (& our_dbuff , & da_stack , depth , & child_cursor , encode_ctx ,
1156+ encode_pair );
1157+ if (slen < 0 ) return -1 ;
11881158
11891159 return fr_dbuff_set (dbuff , & our_dbuff );
11901160}
0 commit comments