/opt/alt/python27/lib64/python2.7/site-packages/Crypto/Signature
Edit: /opt/alt/python27/lib64/python2.7/site-packages/Crypto/Signature/PKCS1_PSS.pyc (11571B)
Ñò
Bd\Rc @ sá d Z d d k l Z d Z d d g Z d d k Te i d d j o" e i d d j o d d k Tn d d
k Z
d d k l Z l Z l
Z
d d k l 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( ( sM /opt/alt/python27/lib64/python2.7/site-packages/Crypto/Signature/PKCS1_PSS.pyt __init__O s
c C s
| i i ƒ S( sC Return True if this cipher object can be used for signing messages.( R t has_private( R ( ( sM /opt/alt/python27/lib64/python2.7/site-packages/Crypto/Signature/PKCS1_PSS.pyt can_sign` s c
sÒ | i i } | i d j o
ˆ i } n
| i } | i o
| i } n ‡ f d † } t i i i | i i
ƒ } t | d ƒ } t ˆ | d | | | ƒ } | i i
| ƒ } t d ƒ | t | ƒ | } | S( sB Produce the PKCS#1 PSS signature of a message.
This function is named ``RSASSA-PSS-SIGN``, and is specified in
section 8.1.1 of RFC3447.
:Parameters:
mhash : hash object
The hash that was carried out over the message. This is an object
belonging to the `Crypto.Hash` module.
:Return: The PSS signature encoded as a string.
:Raise ValueError:
If the RSA key length is not sufficiently long to deal with the given
hash algorithm.
:Raise TypeError:
If the RSA key has no private half.
:attention: Modify the salt length and the mask generation function only
if you know what you are doing.
The receiver must use the same parameters too.
c s t | | ˆ ƒ S( ( t MGF1( t xt y( t mhash( sM /opt/alt/python27/lib64/python2.7/site-packages/Crypto/Signature/PKCS1_PSS.pyt
† s i i i N( R t _randfuncR t Nonet digest_sizeR
t Cryptot Utilt numbert sizet nR t EMSA_PSS_ENCODEt decryptt bchrt len(
R R t randfunct sLent mgft modBitst kt emt mt S( ( R sM /opt/alt/python27/lib64/python2.7/site-packages/Crypto/Signature/PKCS1_PSS.pyt signd s
c
s | i d j o
ˆ i } n
| i } | i o
| i } n ‡ f d † } t i i i | i i ƒ } t
| d ƒ } t | ƒ | j o t S| i i
| d ƒ d } t
| d d ƒ } t d ƒ | t | ƒ | } y t ˆ | | d | | ƒ } Wn t j
o t SX| S( s Verify that a certain PKCS#1 PSS signature is authentic.
This function checks if the party holding the private half of the given
RSA key has really signed the message.
This function is called ``RSASSA-PSS-VERIFY``, and is specified in section
8.1.2 of RFC3447.
:Parameters:
mhash : hash object
The hash that was carried out over the message. This is an object
belonging to the `Crypto.Hash` module.
S : string
The signature that needs to be validated.
:Return: True if verification is correct. False otherwise.
c s t | | ˆ ƒ S( ( R ( R R ( R ( sM /opt/alt/python27/lib64/python2.7/site-packages/Crypto/Signature/PKCS1_PSS.pyR ° s i i i N( R R R R
R R R R R R R R" t Falset encryptR! t EMSA_PSS_VERIFYt
ValueError(
R R R* R$ R% R&