
    TfU:                        d dl Z d dlmZ 	 d dlZn# e$ r d dlZY nw xY wd dlZd dlmZ	 d dl
mZmZ d dlZddlmZ ddlmZmZ ddlmZmZmZmZmZmZmZmZmZmZ  G d d	ej                  Z G d
 dej                  Z  G d dej                  Z! G d dej                  Z" G d dej                  Z# G d dej                  Z$ G d dej                  Z% G d dej                  Z& G d dej                  Z' G d dej                  Z(e	j)        ddz  dfd            Z*i Z+d ej,        v rde+d!<    ed#i e+ e e*                      d"                         Z-dS )$    N)hexlify)givensettings   )str_idx_as_int)NIST256pNIST224p)
remove_integerUnexpectedDERread_lengthencode_bitstringremove_bitstringremove_object
encode_oidremove_constructedremove_octet_stringremove_sequencec                   P    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZdS )TestRemoveIntegerc                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )Ns    assertRaisesr   r
   selfs    @/var/www/html/env/lib/python3.11/site-packages/ecdsa/test_der.pytest_non_minimal_encodingz+TestRemoveInteger.test_non_minimal_encoding!   s    }-- 	0 	0.///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0   8<<c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )Ns   r   r   s    r   test_negative_with_high_bit_setz1TestRemoveInteger.test_negative_with_high_bit_set%   s    }-- 	, 	,?+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,r   c                     t          d          \  }}|                     |d           |                     |d           d S Ns           r
   assertEqualr   valrems      r   test_minimal_with_high_bit_setz0TestRemoveInteger.test_minimal_with_high_bit_set)   sF    !"566Sd###c"""""r#   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )Ns     r   r   s    r   %test_two_zero_bytes_with_high_bit_setz7TestRemoveInteger.test_two_zero_bytes_with_high_bit_set/   s    }-- 	4 	42333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4r   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )Ns    r   r   s    r   test_zero_length_integerz*TestRemoveInteger.test_zero_length_integer3   s    }-- 	( 	(;'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(r   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S Nr#   r   r   s    r   test_empty_stringz#TestRemoveInteger.test_empty_string7   s    }-- 	  	 3	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 r   c                     t          d          \  }}|                     |d           |                     |d           d S )Ns    r   r#   r$   r&   s      r   test_encoding_of_zeroz'TestRemoveInteger.test_encoding_of_zero;   sE    !/22Sa   c"""""r#   c                     t          d          \  }}|                     |d           |                     |d           d S )Ns      r#   r$   r&   s      r   test_encoding_of_127z&TestRemoveInteger.test_encoding_of_127A   sE    !/22Sc"""c"""""r#   c                     t          d          \  }}|                     |d           |                     |d           d S r!   r$   r&   s      r   test_encoding_of_128z&TestRemoveInteger.test_encoding_of_128G   sF    !"566Sc"""c"""""r#   c                     |                      t                    5 }t          d           d d d            n# 1 swxY w Y   |                     dt	          |j                             d S )Ns    zwanted type 'integer'r   r   r
   assertInstr	exceptionr   es     r   test_wrong_tagz TestRemoveInteger.test_wrong_tagM   s    }-- 	0.///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	-s1;/?/?@@@@@   7;;c                     |                      t                    5 }t          d           d d d            n# 1 swxY w Y   |                     dt	          |j                             d S )Ns    Length longerr9   r=   s     r   test_wrong_lengthz#TestRemoveInteger.test_wrong_lengthS   s    }-- 	0.///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	os1;'7'788888r@   N)__name__
__module____qualname__r   r   r)   r+   r-   r0   r2   r5   r7   r?   rC    r#   r   r   r      s        0 0 0, , ,# # #4 4 4( ( (     # # ## # ## # #A A A9 9 9 9 9r#   r   c                   D    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )TestReadLengthc                 L    |                      dt          d                     d S )N)r   r       r%   r   r   s    r   test_zero_lengthzTestReadLength.test_zero_length^   s&    W!5!566666r#   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )Ns    r   r   r   r   s    r   test_two_byte_zero_lengthz(TestReadLength.test_two_byte_zero_lengtha       }-- 	% 	%$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%r   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )Ns   rO   r   s    r   test_two_byte_small_lengthz)TestReadLength.test_two_byte_small_lengthe   rQ   r   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )N   rO   r   s    r   test_long_form_with_zero_lengthz.TestReadLength.test_long_form_with_zero_lengthi   s    }-- 	! 	!   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!r   c                 L    |                      dt          d                     d S )N)r"      s   rL   r   s    r   test_smallest_two_byte_lengthz,TestReadLength.test_smallest_two_byte_lengthm   s&    ;{#;#;<<<<<r#   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )Ns    rO   r   s    r   test_zero_padded_lengthz&TestReadLength.test_zero_padded_lengthp       }-- 	) 	)(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)r   c                 L    |                      dt          d                     d S )N)      s    rL   r   s    r   test_two_three_byte_lengthz)TestReadLength.test_two_three_byte_lengtht   s&    ;#?#?@@@@@r#   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S r/   rO   r   s    r   r0   z TestReadLength.test_empty_stringw   s    }-- 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )Ns    rO   r   s    r   test_length_overflowz#TestReadLength.test_length_overflow{   r\   r   N)rD   rE   rF   rM   rP   rS   rV   rY   r[   r`   r0   rc   rG   r#   r   rI   rI   Z   s        7 7 7% % %% % %! ! != = =) ) )A A A  ) ) ) ) )r#   rI   c                   >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
TestEncodeBitstringc                 x   t          j        d           t          j        t                    5 }t          d          }ddd           n# 1 swxY w Y   |                     t          |          d           |                     d|d         j	        j
        d                    |                     |d           dS )z(This is the old way to use the function.always    Nr   zunused= needs to be specifiedr       )warningssimplefilterpytestwarnsDeprecationWarningr   r%   lenr:   messageargs)r   rm   ders      r   test_old_call_conventionz,TestEncodeBitstring.test_old_call_convention   s    h'''\,-- 	0";//C	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	UQ'''+U1X-=-B1-E	
 	
 	
 	122222s   A

AAc                     t          j                    5  t          j        d           t          dd          }ddd           n# 1 swxY w Y   |                     |d           dS )z$This is how it should be called now.error   r   Nri   rj   catch_warningsrk   r   r%   r   rr   s     r   test_new_call_conventionz,TestEncodeBitstring.test_new_call_convention   s     $&& 	/ 	/!'***"7A..C	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	122222   %AA	A	c                     t          j                    5  t          j        d           t          dd          }ddd           n# 1 swxY w Y   |                     |d           dS )zU
        Writing bit string with already included the number of unused bits.
        ru   rh   Nri   rw   ry   s     r   test_implicit_unused_bitsz-TestEncodeBitstring.test_implicit_unused_bits   s    
 $&& 	6 	6!'***";55C	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	122222r{   c                 R    t          dd          }|                     |d           d S )Ns      s   )r   r%   ry   s     r   test_explicit_unused_bitsz-TestEncodeBitstring.test_explicit_unused_bits   s.    {A..566666r#   c                 N    |                      t          dd          d           d S )Nr#   r   s    )r%   r   r   s    r   r0   z%TestEncodeBitstring.test_empty_string   s)    )#q11?CCCCCr#   c                     |                      t                    5  t          dd           d d d            d S # 1 swxY w Y   d S )Ns       r   
ValueErrorr   r   s    r   test_invalid_unused_countz-TestEncodeBitstring.test_invalid_unused_count   s    z** 	- 	-[!,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-   9= =c                     |                      t                    5  t          dd           d d d            d S # 1 swxY w Y   d S )Nr#   r   r   r   s    r   %test_invalid_unused_with_empty_stringz9TestEncodeBitstring.test_invalid_unused_with_empty_string   s    z** 	% 	%S!$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%r   c                     |                      t                    5  t          dd           d d d            d S # 1 swxY w Y   d S )Nrv   rX   r   r   s    r   test_non_zero_padding_bitsz.TestEncodeBitstring.test_non_zero_padding_bits   s    z** 	) 	)Wa(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)r   N)rD   rE   rF   rs   rz   r}   r   r0   r   r   r   rG   r#   r   re   re      s        3 3 33 3 3	3 	3 	37 7 7
D D D- - -% % %) ) ) ) )r#   re   c                   V    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd ZdS )TestRemoveBitstringc                    t          j        d           t          j        t                    5 }t          d          \  }}ddd           n# 1 swxY w Y   |                     t          |          d           |                     d|d         j	        j
        d                    |                     |d           |                     |d           dS )	z)This is the old way to call the function.rg   ri   Nr   z$expect_unused= needs to be specifiedr   rh   r#   )rj   rk   rl   rm   rn   r   r%   ro   r:   rp   rq   )r   rm   bitsrests       r   rs   z,TestRemoveBitstring.test_old_call_convention   s   h'''\,-- 	?)*=>>JD$	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	UQ'''2E!H4D4I!4L	
 	
 	
 	{+++s#####s   AAAc                    t          j                    5  t          j        d           t          dd          \  }}d d d            n# 1 swxY w Y   |                     |d           |                     |d           d S )Nru   ri   r   rv   r#   rj   rx   rk   r   r%   r   r   r   s      r   rz   z,TestRemoveBitstring.test_new_call_convention   s    $&& 	B 	B!'***)*=qAAJD$	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	w'''s#####   (AAAc                    t          j                    5  t          j        d           t          dd           \  }}d d d            n# 1 swxY w Y   |                     |d           |                     |d           d S )Nru   ri   )rv   r   r#   r   r   s      r   test_implicit_unexpected_unusedz3TestRemoveBitstring.test_implicit_unexpected_unused   s    $&& 	E 	E!'***)*=tDDJD$	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	|,,,s#####r   c                     t          dd           \  }}|                     |d           |                     |d           d S )Ns   )   r   r#   )r   r%   )r   retr   s      r   test_with_paddingz%TestRemoveBitstring.test_with_padding   sH    $%8$??	Tl+++s#####r#   c                     |                      t                    5  t          dd            d d d            d S # 1 swxY w Y   d S )Ns    r   r   r   r   s    r   test_not_a_bitstringz(TestRemoveBitstring.test_not_a_bitstring       }-- 	8 	80$777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8r   c                     |                      t                    5  t          dd            d d d            d S # 1 swxY w Y   d S )Ns    r   r   s    r   test_empty_encodingz'TestRemoveBitstring.test_empty_encoding   s    }-- 	0 	0[$///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0r   c                     |                      t                    5  t          dd            d d d            d S # 1 swxY w Y   d S r/   r   r   s    r   r0   z%TestRemoveBitstring.test_empty_string   s    }-- 	( 	(S$'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(r   c                     |                      t                    5  t          dd            d d d            d S # 1 swxY w Y   d S )N   r   r   s    r   test_no_lengthz"TestRemoveBitstring.test_no_length   s    }-- 	, 	,Wd+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,r   c                     |                      t                    5  t          dd           d d d            d S # 1 swxY w Y   d S )Nri   r   r   r   s    r   %test_unexpected_number_of_unused_bitsz9TestRemoveBitstring.test_unexpected_number_of_unused_bits   s    }-- 	5 	50!444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5r   c                     |                      t                    5  t          dd            d d d            d S # 1 swxY w Y   d S )Ns    r   r   s    r   $test_invalid_encoding_of_unused_bitsz8TestRemoveBitstring.test_invalid_encoding_of_unused_bits   s    }-- 	< 	<4d;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<r   c                     |                      t                    5  t          dd            d d d            d S # 1 swxY w Y   d S )Ns   r   r   s    r   %test_invalid_encoding_of_empty_stringz9TestRemoveBitstring.test_invalid_encoding_of_empty_string   s    }-- 	4 	4_d333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4r   c                     |                      t                    5  t          dd            d d d            d S # 1 swxY w Y   d S )Ns   r   r   s    r   test_invalid_padding_bitsz-TestRemoveBitstring.test_invalid_padding_bits   r   r   N)rD   rE   rF   rs   rz   r   r   r   r   r0   r   r   r   r   r   rG   r#   r   r   r      s        $ $ $$ $ $$ $ $$ $ $8 8 80 0 0( ( (, , ,5 5 5< < <4 4 48 8 8 8 8r#   r   c                        e Zd Zd Zd Zd ZdS )TestStrIdxAsIntc                 N    |                      dt          dd                     d S )Ns   r;   r   r%   r   r   s    r   test_strzTestStrIdxAsInt.test_str  s(    nUA6677777r#   c                 N    |                      dt          dd                     d S Nr   s   strr   r   r   s    r   
test_byteszTestStrIdxAsInt.test_bytes  s(    nVQ7788888r#   c                 h    |                      dt          t          d          d                     d S r   )r%   r   	bytearrayr   s    r   test_bytearrayzTestStrIdxAsInt.test_bytearray	  s0    nYv->->BBCCCCCr#   N)rD   rE   rF   r   r   r   rG   r#   r   r   r     sF        8 8 89 9 9D D D D Dr#   r   c                   J    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )TestEncodeOidc                 t    t          dddddd          }|                     t          |          d           d S )Nr   rX   H  ='  s   06072a8648ce3d0201)r   r%   r   )r   oid_ecPublicKeys     r   test_pub_key_oidzTestEncodeOid.test_pub_key_oid  s>    $Q3q!<<113HIIIIIr#   c                 `    |                      t          t          j                  d           d S )Ns   06052b81040021)r%   r   r	   encoded_oidr   s    r   test_nist224p_oidzTestEncodeOid.test_nist224p_oid  s*    !5668IJJJJJr#   c                 `    |                      t          t          j                  d           d S )Ns   06082a8648ce3d030107)r%   r   r   r   r   s    r   test_nist256p_oidzTestEncodeOid.test_nist256p_oid  s5    H())+B	
 	
 	
 	
 	
r#   c                 T    t          ddd          }|                     |d           d S )NrX     r_      7r   r%   r   oids     r   test_large_second_subidz%TestEncodeOid.test_large_second_subid  s0    C##566666r#   c                 R    t          dd          }|                     |d           d S )NrX   r      7r   r   s     r   test_with_two_subidsz"TestEncodeOid.test_with_two_subids  s.    C  122222r#   c                 R    t          dd          }|                     |d           d S )Nr       r   r   s     r   test_zero_zerozTestEncodeOid.test_zero_zero#  s-    Ao.....r#   c                     |                      t          t          f          5  t          dd            d d d            d S # 1 swxY w Y   d S )Nr   )r   	TypeErrorAssertionErrorr   r   s    r   test_with_wrong_typesz#TestEncodeOid.test_with_wrong_types'  s    	>:;; 	  	 q$	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   A  AAc                     |                      t                    5  t          dd           d d d            d S # 1 swxY w Y   d S )Nr   (   r   r   r   r   s    r   "test_with_small_first_large_secondz0TestEncodeOid.test_with_small_first_large_second+      ~.. 	 	q"	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r   c                 R    t          dd          }|                     |d           d S )Nr   '   s   Or   r   s     r   test_small_first_max_secondz)TestEncodeOid.test_small_first_max_second/  s-    Bo.....r#   c                     |                      t                    5  t          dd           d d d            d S # 1 swxY w Y   d S )Nr_   r   r   r   s    r   test_with_invalid_firstz%TestEncodeOid.test_with_invalid_first3  r   r   N)rD   rE   rF   r   r   r   r   r   r   r   r   r   r   rG   r#   r   r   r     s        J J JK K K
 
 

7 7 7
3 3 3/ / /       / / /    r#   r   c                   x    e Zd Zed             Zd Zd Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zd ZdS )TestRemoveObjectc                 8    t          dddddd          | _        d S )Nr   rX   r   r   )r   r   )clss    r   
setUpClasszTestRemoveObject.setUpClass9  s"    (AsE1a@@r#   c                     t          | j                  \  }}|                     |d           |                     |d           d S )Nr#   r   rX   r   r   rX   r   r   r   r%   r   r   r   s      r   r   z!TestRemoveObject.test_pub_key_oid=  sI    !$"677	Ts###677777r#   c                     t          | j        dz             \  }}|                     |d           |                     |d           d S )Ns   morer   r   r   s      r   test_with_extra_bytesz&TestRemoveObject.test_with_extra_bytesB  sN    !$"6"@AA	Tw'''677777r#   c                     t          d          \  }}|                     |d           |                     |d           d S )Nr   r#   )rX   r   r_   r   r%   r   s      r   test_with_large_second_subidz-TestRemoveObject.test_with_large_second_subidG  sF    !"9::	Ts###k*****r#   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )Ns    r   r   r   r   s    r   test_with_padded_first_subidz-TestRemoveObject.test_with_padded_first_subidM      }-- 	/ 	/-...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/r   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )Ns   7r   r   s    r   test_with_padded_second_subidz.TestRemoveObject.test_with_padded_second_subidQ  s    }-- 	7 	75666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7r   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )Ns   7r   r   s    r   )test_with_missing_last_byte_of_multi_bytez:TestRemoveObject.test_with_missing_last_byte_of_multi_byteU  s    }-- 	3 	31222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3r   c                     t          d          \  }}|                     |d           |                     |d           d S )Nr   r#   )rX   r   r   r   s      r   r   z%TestRemoveObject.test_with_two_subidsY  sF    !"566	Ts###h'''''r#   c                     t          d          \  }}|                     |d           |                     |d           d S )Nr   r#   )r   r   r   r   s      r   r   zTestRemoveObject.test_zero_zero^  sE    !/22	Ts###f%%%%%r#   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S r/   r   r   s    r   r0   z"TestRemoveObject.test_empty_stringc  s    }-- 	 	#	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )N   r   r   s    r   test_missing_lengthz$TestRemoveObject.test_missing_lengthg  s    }-- 	# 	#'"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#r   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )Ns    r   r   s    r   test_empty_oidzTestRemoveObject.test_empty_oidk      }-- 	' 	'+&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'r   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )Ns   r   r   s    r   test_empty_oid_overflowz(TestRemoveObject.test_empty_oid_overflowo  r   r   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )Ns   7r   r   s    r   test_with_wrong_typez%TestRemoveObject.test_with_wrong_types  r   r   c                     |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )Ns   7r   r   s    r   test_with_too_long_lengthz*TestRemoveObject.test_with_too_long_lengthw  r   r   N)rD   rE   rF   classmethodr   r   r   r   r   r   r   r   r   r0   r   r   r   r  r  rG   r#   r   r   r   8  s       A A [A8 8 8
8 8 8
+ + +/ / /7 7 73 3 3( ( (
& & &
  # # #' ' '' ' '/ / // / / / /r#   r   c                       e Zd Zd Zd ZdS )TestRemoveConstructedc                     d}t          |          \  }}}|                     |d           |                     |d           |                     |d           d S )Ns   r      r#   )r   r%   )r   datatagbodyr   s        r   test_simplez!TestRemoveConstructed.test_simple}  sb    ",T22T4d###{+++s#####r#   c                     d}|                      t                    5 }t          |           d d d            n# 1 swxY w Y   |                     dt	          |j                             d S )Ns   zconstructed tag)r   r   r   r:   r;   r<   r   r
  r>   s      r   test_with_malformed_tagz-TestRemoveConstructed.test_with_malformed_tag  s    "}-- 	%t$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	'Q[)9)9:::::   9= =NrD   rE   rF   r  r  rG   r#   r   r  r  |  s2        $ $ $; ; ; ; ;r#   r  c                       e Zd Zd Zd ZdS )TestRemoveOctetStringc                     d}t          |          \  }}|                     |d           |                     |d           d S )Ns   s   r#   )r   r%   r   r
  r  r   s       r   r  z!TestRemoveOctetString.test_simple  sJ    &(..
d///s#####r#   c                     d}|                      t                    5 }t          |           d d d            n# 1 swxY w Y   |                     dt	          |j                             d S )Ns   octetstring)r   r   r   r:   r;   r<   r  s      r   r  z-TestRemoveOctetString.test_with_malformed_tag  s    &}-- 	&%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	mS%5%566666r  Nr  rG   r#   r   r  r    s2        $ $ $7 7 7 7 7r#   r  c                   &    e Zd Zd Zd Zd Zd ZdS )TestRemoveSequencec                     d}t          |          \  }}|                     |d           |                     |d           d S )Ns   0r	  r#   )r   r%   r  s       r   r  zTestRemoveSequence.test_simple  sJ    "$T**
d{+++s#####r#   c                     |                      t                    5 }t          d           d d d            n# 1 swxY w Y   |                     dt	          |j                             d S )Nr#   zEmpty stringr   r   r   r:   r;   r<   r=   s     r   test_with_empty_stringz)TestRemoveSequence.test_with_empty_string  s    }-- 	!C   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	nc!+&6&677777r@   c                     d}|                      t                    5 }t          |           d d d            n# 1 swxY w Y   |                     dt	          |j                             d S )Ns    zwanted type 'sequence'r  r  s      r   test_with_wrong_tagz&TestRemoveSequence.test_with_wrong_tag  s    "}-- 	"D!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	.AK0@0@AAAAAr  c                     d}|                      t                    5 }t          |           d d d            n# 1 swxY w Y   |                     dt	          |j                             d S )Ns   0rB   r  r  s      r   test_with_wrong_lengthz)TestRemoveSequence.test_with_wrong_length  s    "}-- 	"D!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	os1;'7'788888r  N)rD   rE   rF   r  r  r   r"  rG   r#   r   r  r    sS        $ $ $8 8 8B B B9 9 9 9 9r#   r  rX   i   2   c                 X    | t          j        dd                    }|dk     r  | t          j        dd                    }n | t          j        d|                    } | t          j        t          j        d|          |                    }||ft          |          z   S )z
    Hypothesis strategy that returns valid OBJECT IDENTIFIERs as tuples

    :param max_value: maximum value of any single sub-identifier
    :param max_size: maximum length of the generated OID
    r   rX   )	min_value	max_valuer   )max_size)stintegersliststuple)drawr&  r'  firstsecondr   s         r   st_oidr/    s     DqA66677EqyybkA<<<==bkACCCDD4
K!y999H	
 	
 	
 D
 6?U4[[((r#   z--fastmax_examplesc                 \    t          |  }t          |          \  }}|dk    sJ || k    sJ d S r/   )r   r   )idsr   decoded_oidr   s       r   	test_oidsr4    sD     c"K%k22K3;;;;#r#   rG   ).rj   binasciir   	unittest2unittestImportErrorsyshypothesis.strategies
strategiesr(  
hypothesisr   r   rl   _compatr   curvesr   r	   rr   r
   r   r   r   r   r   r   r   r   r   TestCaser   rI   re   r   r   r   r   r  r  r  	compositer/  HYP_SETTINGSargvr4  rG   r#   r   <module>rC     s                 OOOOO 



 " " " " " " & & & & & & & &  # # # # # # & & & & & & & &                       99 99 99 99 99) 99 99 99x#) #) #) #) #)X& #) #) #)L7) 7) 7) 7) 7)(+ 7) 7) 7)tE8 E8 E8 E8 E8(+ E8 E8 E8PD D D D Dh' D D D( ( ( ( (H% ( ( (VA/ A/ A/ A/ A/x( A/ A/ A/H; ; ; ; ;H- ; ; ;&7 7 7 7 7H- 7 7 79 9 9 9 9* 9 9 9< c6B ) ) ) )(  sx#$L  
Lvvxx     s    	