@@ -226,7 +226,7 @@ def __init__(self, alg=None, sign_cert=None, private_key=None, ta_url=None):
226226 private_key: The private key as a string
227227 ta_url: The timestamp authority URL as bytes
228228 """
229- # Handle alg parameter - can be C2paSigningAlg enum or string
229+ # Handle alg parameter: can be C2paSigningAlg enum or string (or bytes), convert as needed
230230 if alg is not None :
231231 if isinstance (alg , C2paSigningAlg ):
232232 # Convert enum to string representation
@@ -235,23 +235,23 @@ def __init__(self, alg=None, sign_cert=None, private_key=None, ta_url=None):
235235 raise ValueError (f"Unsupported signing algorithm: { alg } " )
236236 alg = alg_str
237237 elif isinstance (alg , str ):
238- # Convert string to bytes
238+ # String to bytes, as requested by native lib
239239 alg = alg .encode ('utf-8' )
240240 elif isinstance (alg , bytes ):
241- # Already in bytes format
241+ # In bytes already
242242 pass
243243 else :
244244 raise TypeError (f"alg must be C2paSigningAlg enum, string, or bytes, got { type (alg )} " )
245245 else :
246246 alg = None
247247
248- # Handle ta_url parameter - convert string to bytes if needed
248+ # Handle ta_url parameter: convert string to bytes as needed
249249 if ta_url is not None :
250250 if isinstance (ta_url , str ):
251- # Convert string to bytes
251+ # String to bytes, as requested by native lib
252252 ta_url = ta_url .encode ('utf-8' )
253253 elif isinstance (ta_url , bytes ):
254- # Already in bytes format
254+ # In bytes already
255255 pass
256256 else :
257257 raise TypeError (f"ta_url must be string or bytes, got { type (ta_url )} " )
0 commit comments