Indent.
Fix mem leak on errors.
Этот коммит содержится в:
родитель
a0eda7365e
Коммит
576d37dafd
@ -102,17 +102,18 @@ int _libssh2_dsa_new(libssh2_dsa_ctx **dsactx,
|
||||
const unsigned char *y,
|
||||
unsigned long y_len)
|
||||
{
|
||||
int rc;
|
||||
int rc;
|
||||
|
||||
rc = gcry_sexp_build (dsactx, NULL, "(public-key(dsa(p%b)(q%b)(g%b)(y%b)))",
|
||||
p_len, p, q_len, q, g_len, g, y_len, y);
|
||||
if (rc)
|
||||
{
|
||||
*dsactx = NULL;
|
||||
return -1;
|
||||
}
|
||||
rc = gcry_sexp_build (dsactx, NULL,
|
||||
"(public-key(dsa(p%b)(q%b)(g%b)(y%b)))",
|
||||
p_len, p, q_len, q, g_len, g, y_len, y);
|
||||
if (rc)
|
||||
{
|
||||
*dsactx = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -122,34 +123,34 @@ int _libssh2_dsa_sha1_verify(libssh2_dsa_ctx *dsactx,
|
||||
const unsigned char *m,
|
||||
unsigned long m_len)
|
||||
{
|
||||
unsigned char hash[SHA_DIGEST_LENGTH+1];
|
||||
int ret;
|
||||
gcry_sexp_t s_sig, s_hash;
|
||||
int rc = -1;
|
||||
unsigned char hash[SHA_DIGEST_LENGTH+1];
|
||||
int ret;
|
||||
gcry_sexp_t s_sig, s_hash;
|
||||
int rc = -1;
|
||||
|
||||
libssh2_sha1(m, m_len, hash+1);
|
||||
hash[0] = 0;
|
||||
libssh2_sha1(m, m_len, hash+1);
|
||||
hash[0] = 0;
|
||||
|
||||
rc = gcry_sexp_build (&s_hash, NULL, "(data(flags raw)(value %b))",
|
||||
SHA_DIGEST_LENGTH+1, hash);
|
||||
if (rc != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
rc = gcry_sexp_build (&s_hash, NULL, "(data(flags raw)(value %b))",
|
||||
SHA_DIGEST_LENGTH+1, hash);
|
||||
if (rc != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = gcry_sexp_build (&s_sig, NULL, "(sig-val(dsa(r %b)(s %b)))",
|
||||
20, sig, 20, sig + 20);
|
||||
if (rc != 0)
|
||||
{
|
||||
gcry_sexp_release (s_hash);
|
||||
return -1;
|
||||
}
|
||||
rc = gcry_sexp_build (&s_sig, NULL, "(sig-val(dsa(r %b)(s %b)))",
|
||||
20, sig, 20, sig + 20);
|
||||
if (rc != 0)
|
||||
{
|
||||
gcry_sexp_release (s_hash);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = gcry_pk_verify (s_sig, s_hash, dsactx);
|
||||
gcry_sexp_release (s_sig);
|
||||
gcry_sexp_release (s_hash);
|
||||
rc = gcry_pk_verify (s_sig, s_hash, dsactx);
|
||||
gcry_sexp_release (s_sig);
|
||||
gcry_sexp_release (s_hash);
|
||||
|
||||
return (rc == 0) ? 0 : -1;
|
||||
return (rc == 0) ? 0 : -1;
|
||||
}
|
||||
|
||||
int _libssh2_cipher_init (_libssh2_cipher_ctx *h,
|
||||
@ -158,8 +159,9 @@ int _libssh2_cipher_init (_libssh2_cipher_ctx *h,
|
||||
unsigned char *secret,
|
||||
int encrypt)
|
||||
{
|
||||
int mode = 0, keylen, err;
|
||||
keylen = gcry_cipher_get_algo_keylen (algo);
|
||||
int mode = 0, err;
|
||||
int keylen = gcry_cipher_get_algo_keylen (algo);
|
||||
|
||||
if (algo != GCRY_CIPHER_ARCFOUR)
|
||||
{
|
||||
mode = GCRY_CIPHER_MODE_CBC;
|
||||
@ -174,6 +176,7 @@ int _libssh2_cipher_init (_libssh2_cipher_ctx *h,
|
||||
err = gcry_cipher_setkey (*h, secret, keylen);
|
||||
if (err)
|
||||
{
|
||||
gcry_cipher_close (*h);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -183,6 +186,7 @@ int _libssh2_cipher_init (_libssh2_cipher_ctx *h,
|
||||
err = gcry_cipher_setiv (*h, iv, blklen);
|
||||
if (err)
|
||||
{
|
||||
gcry_cipher_close (*h);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user