Current File : //usr/lib64/python2.7/site-packages/Crypto/Signature/PKCS1_PSS.pyc |
�
Bd\Rc @ s� d Z d d l m Z d Z d d g Z d d l Te j d d k re e j d d k re d d l Tn d d
l Z
d d l m Z m Z m
Z
d d l m Z d d d
� � YZ d � Z d � Z d � Z d
d
d � Z d
S( s� RSA digital signature protocol with appendix according to PKCS#1 PSS.
See RFC3447__ or the `original RSA Labs specification`__.
This scheme is more properly called ``RSASSA-PSS``.
For example, a sender may authenticate a message using SHA-1 and PSS like
this:
>>> from Crypto.Signature import PKCS1_PSS
>>> from Crypto.Hash import SHA
>>> from Crypto.PublicKey import RSA
>>> from Crypto import Random
>>>
>>> message = 'To be signed'
>>> key = RSA.importKey(open('privkey.der').read())
>>> h = SHA.new()
>>> h.update(message)
>>> signer = PKCS1_PSS.new(key)
>>> signature = PKCS1_PSS.sign(key)
At the receiver side, verification can be done like using the public part of
the RSA key:
>>> key = RSA.importKey(open('pubkey.der').read())
>>> h = SHA.new()
>>> h.update(message)
>>> verifier = PKCS1_PSS.new(key)
>>> if verifier.verify(h, signature):
>>> print "The signature is authentic."
>>> else:
>>> print "The signature is not authentic."
:undocumented: __revision__, __package__
.. __: http://www.ietf.org/rfc/rfc3447.txt
.. __: http://www.rsa.com/rsalabs/node.asp?id=2125
i����( t
nested_scopess $Id$t newt
PSS_SigScheme( t *i i i N( t
ceil_shiftt ceil_divt
long_to_bytes( t strxorc B s2 e Z d Z d � Z d � Z d � Z d � Z RS( sK This signature scheme can perform PKCS#1 PSS RSA signature or verification.c C s | | _ | | _ | | _ d S( s! Initialize this PKCS#1 PSS signature scheme object.
:Parameters:
key : an RSA key object
If a private half is given, both signature and verification are possible.
If a public half is given, only verification is possible.
mgfunc : callable
A mask generation function that accepts two parameters: a string to
use as seed, and the lenth of the mask to generate, in bytes.
saltLen : int
Length of the salt, in bytes.
N( t _keyt _saltLent _mgfunc( t selft keyt mgfunct saltLen( ( s@ /usr/lib64/python2.7/site-packages/Crypto/Signature/PKCS1_PSS.pyt __init__O s
c C s
| j j � S( sC Return True if this cipher object can be used for signing messages.( R t has_private( R ( ( s@ /usr/lib64/python2.7/site-packages/Crypto/Signature/PKCS1_PSS.pyt can_sign` s c
s� | j j } | j d k r'