i2d will do allocation for you and we should probably let it.


On 28 April 2014 23:54:06 Paul Kehrer <notifications@github.com> wrote:

> > @@ -474,6 +474,41 @@ def generate_dsa_private_key(self, parameters):
> >              y=self._bn_to_int(ctx.pub_key)
> >          )
> > +    def create_dsa_verification_ctx(self, public_key, signature,
> > +                                    algorithm):
> > +        return _DSAVerificationContext(self, public_key, signature,
> > +                                       algorithm)
> > +
> > +    def dsa_signature_from_components(self, r, s, q):
> > +        dsa_sig = self._lib.DSA_SIG_new()
> > +        assert dsa_sig != self._ffi.NULL
> > +        dsa_sig = self._ffi.gc(dsa_sig, self._lib.DSA_SIG_free)
> > +
> > +        dsa_sig.r = self._int_to_bn(r)
> > +        dsa_sig.s = self._int_to_bn(s)
> > +
> > +        sig_buf = self._ffi.new(
> > +            "unsigned char []", utils.bit_length(q))
>
> Does `i2d_DSA_SIG` not automatically allocate an `unsigned char *` if you 
> pass `unsigned char **` pointing at NULL?
>
> And for my own edification could you explain why creating a buffer of this 
> length is correct?
>
> ---
> Reply to this email directly or view it on GitHub:
> https://github.com/pyca/cryptography/pull/912/files#r12072512