~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to fs/cifs/cifsencrypt.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
                server->session_key.response, server->session_key.len);
61
61
 
62
62
        crypto_shash_update(&server->secmech.sdescmd5->shash,
63
 
                cifs_pdu->Protocol, cifs_pdu->smb_buf_length);
 
63
                cifs_pdu->Protocol, be32_to_cpu(cifs_pdu->smb_buf_length));
64
64
 
65
65
        rc = crypto_shash_final(&server->secmech.sdescmd5->shash, signature);
66
66
 
184
184
        if (cifs_pdu == NULL || server == NULL)
185
185
                return -EINVAL;
186
186
 
187
 
        if (cifs_pdu->Command == SMB_COM_NEGOTIATE)
 
187
        if (!server->session_estab)
188
188
                return 0;
189
189
 
190
190
        if (cifs_pdu->Command == SMB_COM_LOCKING_ANDX) {
229
229
}
230
230
 
231
231
/* first calculate 24 bytes ntlm response and then 16 byte session key */
232
 
int setup_ntlm_response(struct cifsSesInfo *ses)
 
232
int setup_ntlm_response(struct cifs_ses *ses)
233
233
{
234
234
        int rc = 0;
235
235
        unsigned int temp_len = CIFS_SESS_KEY_SIZE + CIFS_AUTH_RESP_SIZE;
268
268
}
269
269
 
270
270
#ifdef CONFIG_CIFS_WEAK_PW_HASH
271
 
void calc_lanman_hash(const char *password, const char *cryptkey, bool encrypt,
 
271
int calc_lanman_hash(const char *password, const char *cryptkey, bool encrypt,
272
272
                        char *lnm_session_key)
273
273
{
274
274
        int i;
 
275
        int rc;
275
276
        char password_with_pad[CIFS_ENCPWD_SIZE];
276
277
 
277
278
        memset(password_with_pad, 0, CIFS_ENCPWD_SIZE);
282
283
                memset(lnm_session_key, 0, CIFS_SESS_KEY_SIZE);
283
284
                memcpy(lnm_session_key, password_with_pad,
284
285
                        CIFS_ENCPWD_SIZE);
285
 
                return;
 
286
                return 0;
286
287
        }
287
288
 
288
289
        /* calculate old style session key */
299
300
        for (i = 0; i < CIFS_ENCPWD_SIZE; i++)
300
301
                password_with_pad[i] = toupper(password_with_pad[i]);
301
302
 
302
 
        SMBencrypt(password_with_pad, cryptkey, lnm_session_key);
 
303
        rc = SMBencrypt(password_with_pad, cryptkey, lnm_session_key);
303
304
 
304
 
        /* clear password before we return/free memory */
305
 
        memset(password_with_pad, 0, CIFS_ENCPWD_SIZE);
 
305
        return rc;
306
306
}
307
307
#endif /* CIFS_WEAK_PW_HASH */
308
308
 
312
312
 * Allocate domain name which gets freed when session struct is deallocated.
313
313
 */
314
314
static int
315
 
build_avpair_blob(struct cifsSesInfo *ses, const struct nls_table *nls_cp)
 
315
build_avpair_blob(struct cifs_ses *ses, const struct nls_table *nls_cp)
316
316
{
317
317
        unsigned int dlen;
318
318
        unsigned int wlen;
400
400
 * about target string i.e. for some, just user name might suffice.
401
401
 */
402
402
static int
403
 
find_domain_name(struct cifsSesInfo *ses, const struct nls_table *nls_cp)
 
403
find_domain_name(struct cifs_ses *ses, const struct nls_table *nls_cp)
404
404
{
405
405
        unsigned int attrsize;
406
406
        unsigned int type;
445
445
        return 0;
446
446
}
447
447
 
448
 
static int calc_ntlmv2_hash(struct cifsSesInfo *ses, char *ntlmv2_hash,
 
448
static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
449
449
                            const struct nls_table *nls_cp)
450
450
{
451
451
        int rc = 0;
472
472
                return rc;
473
473
        }
474
474
 
475
 
        /* convert ses->userName to unicode and uppercase */
476
 
        len = strlen(ses->userName);
 
475
        /* convert ses->user_name to unicode and uppercase */
 
476
        len = strlen(ses->user_name);
477
477
        user = kmalloc(2 + (len * 2), GFP_KERNEL);
478
478
        if (user == NULL) {
479
479
                cERROR(1, "calc_ntlmv2_hash: user mem alloc failure\n");
480
480
                rc = -ENOMEM;
481
481
                goto calc_exit_2;
482
482
        }
483
 
        len = cifs_strtoUCS((__le16 *)user, ses->userName, len, nls_cp);
 
483
        len = cifs_strtoUCS((__le16 *)user, ses->user_name, len, nls_cp);
484
484
        UniStrupr(user);
485
485
 
486
486
        crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash,
527
527
}
528
528
 
529
529
static int
530
 
CalcNTLMv2_response(const struct cifsSesInfo *ses, char *ntlmv2_hash)
 
530
CalcNTLMv2_response(const struct cifs_ses *ses, char *ntlmv2_hash)
531
531
{
532
532
        int rc;
533
533
        unsigned int offset = CIFS_SESS_KEY_SIZE + 8;
563
563
 
564
564
 
565
565
int
566
 
setup_ntlmv2_rsp(struct cifsSesInfo *ses, const struct nls_table *nls_cp)
 
566
setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
567
567
{
568
568
        int rc;
569
569
        int baselen;
649
649
}
650
650
 
651
651
int
652
 
calc_seckey(struct cifsSesInfo *ses)
 
652
calc_seckey(struct cifs_ses *ses)
653
653
{
654
654
        int rc;
655
655
        struct crypto_blkcipher *tfm_arc4;