def load_pub_key_params(p, q, g, pub):
    """Create a DSA_pub object from parameters and key."""
    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.DSA_pub(dsa, 1)
Example #2
0
def load_pub_key_params(p, q, g, pub):
    """Create a DSA_pub object from parameters and key."""
    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.DSA_pub(dsa, 1)
Example #3
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 #4
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 #5
0
def set_params(p, q, g):
    # type: (bytes, bytes, bytes) -> DSA
    """
    Factory function that instantiates a DSA object with DSA
    parameters.

    @param p: value of p, a "byte string"
    @param q: value of q, a "byte string"
    @param g: value of g, a "byte string"
    @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 #6
0
def set_params(p, q, g):
    # type: (bytes, bytes, bytes) -> DSA
    """
    Factory function that instantiates a DSA object with DSA
    parameters.

    @param p: value of p, a "byte string"
    @param q: value of q, a "byte string"
    @param g: value of g, a "byte string"
    @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 #7
0
def pub_key_from_params(p, q, g, pub):
    # type: (bytes, bytes, bytes, bytes) -> DSA_pub
    """
    Factory function that instantiates a DSA_pub object using
    the parameters and public key specified.

    @param p: value of p
    @param q: value of q
    @param g: value of g
    @param pub: value of the public key
    @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)
Example #8
0
def pub_key_from_params(p, q, g, pub):
    # type: (bytes, bytes, bytes, bytes) -> DSA_pub
    """
    Factory function that instantiates a DSA_pub object using
    the parameters and public key specified.

    @param p: value of p
    @param q: value of q
    @param g: value of g
    @param pub: value of the public key
    @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)
Example #9
0
    def set_params(self, p, q, g):
        # type: (bytes, bytes, bytes) -> None
        """
        Set new parameters.

        @param p: MPI binary representation ... format that consists of
                  the number's length in bytes represented as a 4-byte
                  big-endian number, and the number itself in big-endian
                  format, where the most significant bit signals
                  a negative number (the representation of numbers with
                  the MSB set is prefixed with null byte).
        @param q: ditto
        @param g: ditto
        @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 #10
0
    def set_params(self, p, q, g):
        # type: (bytes, bytes, bytes) -> None
        """
        Set new parameters.

        @param p: MPI binary representation ... format that consists of
                  the number's length in bytes represented as a 4-byte
                  big-endian number, and the number itself in big-endian
                  format, where the most significant bit signals
                  a negative number (the representation of numbers with
                  the MSB set is prefixed with null byte).
        @param q: ditto
        @param g: ditto
        @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 #11
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)
Example #12
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)