コード例 #1
0
    def sign_rsassa_pss(self, digest, algo='sha1', salt_length=20):
        """
        Signs a digest with the private key using RSASSA-PSS

        @requires: OpenSSL 0.9.7h or later.

        @type digest: str
        @param digest: A digest created by using the digest method

        @type salt_length: int
        @param salt_length: The length of the salt to use

        @type algo: str
        @param algo: The hash algorithm to use

        @return: a string which is the signature
        """
        hash = getattr(m2, algo, None)
        if hash is None:
            raise ValueError('not such hash algorithm %s' % algo)

        signature = m2.rsa_padding_add_pkcs1_pss(self.rsa, digest, hash(),
                                                 salt_length)

        return self.private_encrypt(signature, m2.no_padding)
コード例 #2
0
ファイル: RSA.py プロジェクト: rodrigc/m2crypto
    def sign_rsassa_pss(self, digest, algo='sha1', salt_length=20):
        """
        Signs a digest with the private key using RSASSA-PSS

        @requires: OpenSSL 0.9.7h or later.

        @type digest: str
        @param digest: A digest created by using the digest method

        @type salt_length: int
        @param salt_length: The length of the salt to use

        @type algo: str
        @param algo: The hash algorithm to use

        @return: a string which is the signature
        """
        hash = getattr(m2, algo, None)
        if hash is None:
            raise ValueError('not such hash algorithm %s' % algo)

        signature = m2.rsa_padding_add_pkcs1_pss(self.rsa, digest, hash(),
                                                 salt_length)

        return self.private_encrypt(signature, m2.no_padding)
コード例 #3
0
    def sign_rsassa_pss(self, digest, algo='sha1', salt_length=20):
        # type: (bytes, str, int) -> bytes
        """
        Signs a digest with the private key using RSASSA-PSS

        @param digest: A digest created by using the digest method
        @param salt_length: The length of the salt to use
        @param algo: The hash algorithm to use
        Legal values like 'sha1','sha224', 'sha256', 'ripemd160',
        and 'md5'.

        @return: a string which is the signature
        """
        hash = getattr(m2, algo, None)

        if hash is None:
            raise RSAError('not such hash algorithm %s' % algo)

        signature = m2.rsa_padding_add_pkcs1_pss(self.rsa, digest, hash(), salt_length)

        return self.private_encrypt(signature, m2.no_padding)
コード例 #4
0
ファイル: RSA.py プロジェクト: mcepl/M2Crypto
    def sign_rsassa_pss(self, digest, algo='sha1', salt_length=20):
        # type: (bytes, str, int) -> bytes
        """
        Signs a digest with the private key using RSASSA-PSS

        :param digest: A digest created by using the digest method

        :param salt_length: The length of the salt to use

        :param algo: The hash algorithm to use
                     Legal values like 'sha1','sha224', 'sha256',
                     'ripemd160', and 'md5'.

        :return: a string which is the signature
        """
        hash = getattr(m2, algo, None)

        if hash is None:
            raise RSAError('not such hash algorithm %s' % algo)

        signature = m2.rsa_padding_add_pkcs1_pss(self.rsa, digest, hash(), salt_length)

        return self.private_encrypt(signature, m2.no_padding)