~ubuntu-branches/ubuntu/vivid/samba/vivid

« back to all changes in this revision

Viewing changes to source4/heimdal/lib/gssapi/krb5/verify_mic.c

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
#include "gsskrb5_locl.h"
35
35
 
 
36
#ifdef HEIM_WEAK_CRYPTO
 
37
 
36
38
static OM_uint32
37
39
verify_mic_des
38
40
           (OM_uint32 * minor_status,
46
48
            )
47
49
{
48
50
  u_char *p;
49
 
  MD5_CTX md5;
 
51
  EVP_MD_CTX *md5;
50
52
  u_char hash[16], *seq;
51
53
  DES_key_schedule schedule;
 
54
  EVP_CIPHER_CTX des_ctx;
52
55
  DES_cblock zero;
53
56
  DES_cblock deskey;
54
57
  uint32_t seq_number;
72
75
  p += 16;
73
76
 
74
77
  /* verify checksum */
75
 
  MD5_Init (&md5);
76
 
  MD5_Update (&md5, p - 24, 8);
77
 
  MD5_Update (&md5, message_buffer->value,
78
 
             message_buffer->length);
79
 
  MD5_Final (hash, &md5);
 
78
  md5 = EVP_MD_CTX_create();
 
79
  EVP_DigestInit_ex(md5, EVP_md5(), NULL);
 
80
  EVP_DigestUpdate(md5, p - 24, 8);
 
81
  EVP_DigestUpdate(md5, message_buffer->value, message_buffer->length);
 
82
  EVP_DigestFinal_ex(md5, hash, NULL);
 
83
  EVP_MD_CTX_destroy(md5);
80
84
 
81
85
  memset (&zero, 0, sizeof(zero));
82
86
  memcpy (&deskey, key->keyvalue.data, sizeof(deskey));
84
88
  DES_set_key_unchecked (&deskey, &schedule);
85
89
  DES_cbc_cksum ((void *)hash, (void *)hash, sizeof(hash),
86
90
                 &schedule, &zero);
87
 
  if (memcmp (p - 8, hash, 8) != 0) {
 
91
  if (ct_memcmp (p - 8, hash, 8) != 0) {
88
92
    memset (deskey, 0, sizeof(deskey));
89
93
    memset (&schedule, 0, sizeof(schedule));
90
94
    return GSS_S_BAD_MIC;
95
99
  HEIMDAL_MUTEX_lock(&context_handle->ctx_id_mutex);
96
100
 
97
101
  p -= 16;
98
 
  DES_set_key_unchecked (&deskey, &schedule);
99
 
  DES_cbc_encrypt ((void *)p, (void *)p, 8,
100
 
                   &schedule, (DES_cblock *)hash, DES_DECRYPT);
 
102
 
 
103
  EVP_CIPHER_CTX_init(&des_ctx);
 
104
  EVP_CipherInit_ex(&des_ctx, EVP_des_cbc(), NULL, key->keyvalue.data, hash, 0);
 
105
  EVP_Cipher(&des_ctx, p, p, 8);
 
106
  EVP_CIPHER_CTX_cleanup(&des_ctx);
101
107
 
102
108
  memset (deskey, 0, sizeof(deskey));
103
109
  memset (&schedule, 0, sizeof(schedule));
106
112
  _gsskrb5_decode_om_uint32(seq, &seq_number);
107
113
 
108
114
  if (context_handle->more_flags & LOCAL)
109
 
      cmp = memcmp(&seq[4], "\xff\xff\xff\xff", 4);
 
115
      cmp = ct_memcmp(&seq[4], "\xff\xff\xff\xff", 4);
110
116
  else
111
 
      cmp = memcmp(&seq[4], "\x00\x00\x00\x00", 4);
 
117
      cmp = ct_memcmp(&seq[4], "\x00\x00\x00\x00", 4);
112
118
 
113
119
  if (cmp != 0) {
114
120
    HEIMDAL_MUTEX_unlock(&context_handle->ctx_id_mutex);
125
131
 
126
132
  return GSS_S_COMPLETE;
127
133
}
 
134
#endif
128
135
 
129
136
static OM_uint32
130
137
verify_mic_des3
207
214
  _gsskrb5_decode_om_uint32(seq, &seq_number);
208
215
 
209
216
  if (context_handle->more_flags & LOCAL)
210
 
      cmp = memcmp(&seq[4], "\xff\xff\xff\xff", 4);
 
217
      cmp = ct_memcmp(&seq[4], "\xff\xff\xff\xff", 4);
211
218
  else
212
 
      cmp = memcmp(&seq[4], "\x00\x00\x00\x00", 4);
 
219
      cmp = ct_memcmp(&seq[4], "\x00\x00\x00\x00", 4);
213
220
 
214
221
  krb5_data_free (&seq_data);
215
222
  if (cmp != 0) {
292
299
    krb5_enctype_to_keytype (context, key->keytype, &keytype);
293
300
    switch (keytype) {
294
301
    case KEYTYPE_DES :
 
302
#ifdef HEIM_WEAK_CRYPTO
295
303
        ret = verify_mic_des (minor_status, ctx, context,
296
304
                              message_buffer, token_buffer, qop_state, key,
297
305
                              type);
 
306
#else
 
307
      ret = GSS_S_FAILURE;
 
308
#endif
298
309
        break;
299
310
    case KEYTYPE_DES3 :
300
311
        ret = verify_mic_des3 (minor_status, ctx, context,
316
327
    return ret;
317
328
}
318
329
 
319
 
OM_uint32
 
330
OM_uint32 GSSAPI_CALLCONV
320
331
_gsskrb5_verify_mic
321
332
           (OM_uint32 * minor_status,
322
333
            const gss_ctx_id_t context_handle,