The code in the question has a couple of errors, in order of appearance:
- two different versions of SHA512 are imported;
- 64, 64 _ (, base-64-url);
signature_algorithm keytype ;key PSS;m.hexdigest() ;SHA512.new(rsakey);- , , SHA512 ;
PSS. , , , . , , , .
from Crypto.Signature import PKCS1_PSS
from Crypto.Hash import SHA512
from Crypto.PublicKey import RSA
from Crypto import Random
message = 'To be signed'
key = RSA.importKey(open('privkey.der').read())
h = SHA512.new()
h.update(message)
signer = PKCS1_PSS.new(key)
signature = PKCS1_PSS.sign(h)
, PSS , , , , , MGF1 , , ...