This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
+#include "libcli/auth/libcli_auth.h"
/*
encrypt or decrypt a blob of data using the user session key
caller should free the returned string
*/
-char *sess_decrypt_string(DATA_BLOB *blob, const DATA_BLOB *session_key)
+char *sess_decrypt_string(TALLOC_CTX *mem_ctx,
+ DATA_BLOB *blob, const DATA_BLOB *session_key)
{
DATA_BLOB out;
int slen;
return NULL;
}
- out = data_blob(NULL, blob->length);
+ out = data_blob_talloc(mem_ctx, NULL, blob->length);
if (!out.data) {
return NULL;
}
if (IVAL(out.data, 4) != 1) {
DEBUG(0,("Unexpected revision number %d in session crypted string\n",
IVAL(out.data, 4)));
+ data_blob_free(&out);
return NULL;
}
slen = IVAL(out.data, 0);
if (slen > blob->length - 8) {
DEBUG(0,("Invalid crypt length %d\n", slen));
+ data_blob_free(&out);
return NULL;
}
- ret = strndup((const char *)(out.data+8), slen);
+ ret = talloc_strndup(mem_ctx, (const char *)(out.data+8), slen);
data_blob_free(&out);
+ DEBUG(0,("decrypted string '%s' of length %d\n", ret, slen));
+
return ret;
}
return data_blob(NULL, 0);
}
- ret = data_blob(NULL, 8+dlen);
+ ret = data_blob_talloc(mem_ctx, NULL, 8+dlen);
if (!ret.data) {
data_blob_free(&src);
return data_blob(NULL, 0);
if (blob->length < 8) {
DEBUG(0, ("Unexpected length %d in session crypted secret (BLOB)\n",
- blob->length));
+ (int)blob->length));
return NT_STATUS_INVALID_PARAMETER;
}
sess_crypt_blob(&out, blob, session_key, False);
if (IVAL(out.data, 4) != 1) {
- DEBUG(0,("Unexpected revision number %d in session crypted secret (BLOB)\n",
+ DEBUG(2,("Unexpected revision number %d in session crypted secret (BLOB)\n",
IVAL(out.data, 4)));
return NT_STATUS_UNKNOWN_REVISION;
}