Example #1
0
 def set_params(self, p, q, g):
     """
     Set new parameters.
     
     @warning: This does not change the private key, so it may be
               unsafe to use this method. It is better to use
               gen_params function to create a new DSA object.
     """
     m2.dsa_set_p(self.dsa, p)
     m2.dsa_set_q(self.dsa, q)
     m2.dsa_set_g(self.dsa, g)
Example #2
0
    def set_params(self, p, q, g):
        """
        Set new parameters.

        @warning: This does not change the private key, so it may be
                  unsafe to use this method. It is better to use
                  gen_params function to create a new DSA object.
        """
        m2.dsa_set_p(self.dsa, p)
        m2.dsa_set_q(self.dsa, q)
        m2.dsa_set_g(self.dsa, g)
Example #3
0
def set_params(p, q, g):
    """
    Factory function that instantiates a DSA object with DSA
    parameters.

    @type  p: str
    @param p: value of p, a "byte string"
    @type  q: str
    @param q: value of q, a "byte string"
    @type  g: str
    @param g: value of g, a "byte string"
    @rtype:   DSA
    @return:  instance of DSA.
    """
    dsa = m2.dsa_new()
    m2.dsa_set_p(dsa, p)
    m2.dsa_set_q(dsa, q)
    m2.dsa_set_g(dsa, g)
    return DSA(dsa, 1)
Example #4
0
def set_params(p, q, g):
    """
    Factory function that instantiates a DSA object with DSA
    parameters.

    @type  p: str
    @param p: value of p, a "byte string"
    @type  q: str
    @param q: value of q, a "byte string"
    @type  g: str
    @param g: value of g, a "byte string"
    @rtype:   DSA
    @return:  instance of DSA.
    """
    dsa = m2.dsa_new()
    m2.dsa_set_p(dsa, p)
    m2.dsa_set_q(dsa, q)
    m2.dsa_set_g(dsa, g)
    return DSA(dsa, 1)
Example #5
0
def pub_key_from_params(p, q, g, pub):
    """
    Factory function that instantiates a DSA_pub object using
    the parameters and public key specified.

    @type  p: str
    @param p: value of p, a "byte string"
    @type  q: str
    @param q: value of q, a "byte string"
    @type  g: str
    @param g: value of g, a "byte string"
    @type  pub: str
    @param pub: value of the public key, a "byte string"
    @rtype:   DSA_pub
    @return:  instance of DSA_pub.
    """
    dsa = m2.dsa_new()
    m2.dsa_set_p(dsa, p)
    m2.dsa_set_q(dsa, q)
    m2.dsa_set_g(dsa, g)
    m2.dsa_set_pub(dsa, pub)
    return DSA_pub(dsa, 1)