ms_usage=krb5int_arcfour_translate_usage(usage);
if (key->enctype == ENCTYPE_ARCFOUR_HMAC_EXP) {
strncpy(salt.data, krb5int_arcfour_l40, salt.length);
- salt.data[10]=ms_usage & 0xff;
- salt.data[11]=(ms_usage>>8) & 0xff;
- salt.data[12]=(ms_usage>>16) & 0xff;
- salt.data[13]=(ms_usage>>24) & 0xff;
+ store_32_le(ms_usage, salt.data+10);
} else {
salt.length=4;
- salt.data[0]=ms_usage & 0xff;
- salt.data[1]=(ms_usage>>8) & 0xff;
- salt.data[2]=(ms_usage>>16) & 0xff;
- salt.data[3]=(ms_usage>>24) & 0xff;
+ store_32_le(ms_usage, salt.data);
}
ret=krb5_hmac(hash, key, 1, &salt, &d1);
if (ret)
datain.data = (char *) constantdata;
datain.length = K5CLENGTH;
- datain.data[0] = (usage>>24)&0xff;
- datain.data[1] = (usage>>16)&0xff;
- datain.data[2] = (usage>>8)&0xff;
- datain.data[3] = usage&0xff;
+ store_32_be(usage, constantdata);
datain.data[4] = (char) 0x99;
datain.data = (char *) constantdata;
datain.length = K5CLENGTH;
- datain.data[0] = (usage>>24)&0xff;
- datain.data[1] = (usage>>16)&0xff;
- datain.data[2] = (usage>>8)&0xff;
- datain.data[3] = usage&0xff;
+ store_32_be(usage, constantdata);
datain.data[4] = (char) 0x99;
/*
* lib/crypto/dk/dk_aead.c
*
- * Copyright 2008 by the Massachusetts Institute of Technology.
+ * Copyright 2008, 2009 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
d1.data = (char *)constantdata;
d1.length = K5CLENGTH;
- d1.data[0] = (usage >> 24) & 0xFF;
- d1.data[1] = (usage >> 16) & 0xFF;
- d1.data[2] = (usage >> 8 ) & 0xFF;
- d1.data[3] = (usage ) & 0xFF;
+ store_32_be(usage, constantdata);
d1.data[4] = 0xAA;
d1.data = (char *)constantdata;
d1.length = K5CLENGTH;
- d1.data[0] = (usage >> 24) & 0xFF;
- d1.data[1] = (usage >> 16) & 0xFF;
- d1.data[2] = (usage >> 8 ) & 0xFF;
- d1.data[3] = (usage ) & 0xFF;
+ store_32_be(usage, constantdata);
d1.data[4] = 0xAA;
d1.data = (char *) constantdata;
d1.length = K5CLENGTH;
- d1.data[0] = (usage>>24)&0xff;
- d1.data[1] = (usage>>16)&0xff;
- d1.data[2] = (usage>>8)&0xff;
- d1.data[3] = usage&0xff;
+ store_32_be(usage, constantdata);
d1.data[4] = (char) 0xAA;
d1.data = (char *) constantdata;
d1.length = K5CLENGTH;
- d1.data[0] = (usage>>24)&0xff;
- d1.data[1] = (usage>>16)&0xff;
- d1.data[2] = (usage>>8)&0xff;
- d1.data[3] = usage&0xff;
+ store_32_be(usage, constantdata);
d1.data[4] = (char) 0xAA;
d1.data = (char *) constantdata;
d1.length = K5CLENGTH;
- d1.data[0] = (usage>>24)&0xff;
- d1.data[1] = (usage>>16)&0xff;
- d1.data[2] = (usage>>8)&0xff;
- d1.data[3] = usage&0xff;
+ store_32_be(usage, constantdata);
d1.data[4] = (char) 0xAA;
c ^= cn;
}
- output->data[0] = c&0xff;
- output->data[1] = (c>>8)&0xff;
- output->data[2] = (c>>16)&0xff;
- output->data[3] = (c>>24)&0xff;
-
+ store_32_le(c, output->data);
return(0);
}
shsFinal(&ctx);
for (i=0; i<(sizeof(ctx.digest)/sizeof(ctx.digest[0])); i++) {
- output->data[i*4] = (ctx.digest[i]>>24)&0xff;
- output->data[i*4+1] = (ctx.digest[i]>>16)&0xff;
- output->data[i*4+2] = (ctx.digest[i]>>8)&0xff;
- output->data[i*4+3] = ctx.digest[i]&0xff;
+ store_32_be(ctx.digest[i], &output->data[i*4]);
}
return(0);
/*
* lib/crypto/keyhash_provider/hmac_md5.c
*
- * Copyright 2001 by the Massachusetts Institute of Technology.
+ * Copyright 2001, 2009 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
krb5_MD5Init (&ctx);
ms_usage = krb5int_arcfour_translate_usage (usage);
- t[0] = (ms_usage) & 0xff;
- t[1] = (ms_usage>>8) & 0xff;
- t[2] = (ms_usage >>16) & 0xff;
- t[3] = (ms_usage>>24) & 0XFF;
+ store_32_le(ms_usage, t);
krb5_MD5Update (&ctx, (unsigned char * ) &t, 4);
krb5_MD5Update (&ctx, (unsigned char *) input-> data,
(unsigned int) input->length );
krb5_MD5Init (&ctx);
ms_usage = krb5int_arcfour_translate_usage (usage);
- t[0] = (ms_usage) & 0xff;
- t[1] = (ms_usage>>8) & 0xff;
- t[2] = (ms_usage >>16) & 0xff;
- t[3] = (ms_usage>>24) & 0XFF;
+ store_32_le(ms_usage, t);
krb5_MD5Update (&ctx, (unsigned char * ) &t, 4);
for (i = 0; i < num_data; i++) {
const krb5_crypto_iov *iov = &data[i];
k5_hmac_md5_hash_iov,
NULL /*checksum again */
};
-
/*
* lib/crypto/keyhash_provider/md5_hmac.c
*
- * Copyright2001 by the Massachusetts Institute of Technology.
+ * Copyright 2001, 2009 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
krb5_MD5Init(&ctx);
ms_usage = krb5int_arcfour_translate_usage (usage);
- t[0] = (ms_usage >> 0) & 0xff;
- t[1] = (ms_usage >> 8) & 0xff;
- t[2] = (ms_usage >> 16) & 0xff;
- t[3] = (ms_usage >> 24) & 0xff;
-
+ store_32_le(ms_usage, t);
krb5_MD5Update(&ctx, t, sizeof(t));
krb5_MD5Update(&ctx, (unsigned char *)input->data, input->length);
krb5_MD5Final(&ctx);
unsigned char *out2 = (void *)(tdigest); \
HASH_CTX *ctx = (x); \
shsFinal(ctx); \
-for (loopvar=0; loopvar<(sizeof(ctx->digest)/sizeof(ctx->digest[0])); loopvar++) { \
- out2[loopvar*4] = (ctx->digest[loopvar]>>24)&0xff; \
- out2[loopvar*4+1] = (ctx->digest[loopvar]>>16)&0xff; \
- out2[loopvar*4+2] = (ctx->digest[loopvar]>>8)&0xff; \
- out2[loopvar*4+3] = ctx->digest[loopvar]&0xff; \
-} \
+ for (loopvar=0; loopvar<(sizeof(ctx->digest)/sizeof(ctx->digest[0])); loopvar++) \
+ store_32_be(ctx->digest[loopvar], &out2[loopvar*4]); \
} while(0)
things */
#define TWRITE_INT(ptr, num, bigend) \
- (ptr)[0] = (char) ((bigend)?((num)>>24):((num)&0xff)); \
- (ptr)[1] = (char) ((bigend)?(((num)>>16)&0xff):(((num)>>8)&0xff)); \
- (ptr)[2] = (char) ((bigend)?(((num)>>8)&0xff):(((num)>>16)&0xff)); \
- (ptr)[3] = (char) ((bigend)?((num)&0xff):((num)>>24)); \
+ if (bigend) store_32_be(num, ptr); else store_32_le(num, ptr); \
(ptr) += 4;
#define TWRITE_INT16(ptr, num, bigend) \
- (ptr)[0] = (char) ((bigend)?((num)>>24):((num)&0xff)); \
- (ptr)[1] = (char) ((bigend)?(((num)>>16)&0xff):(((num)>>8)&0xff)); \
+ if (bigend) store_16_be((num)>>16, ptr); else store_16_le(num, ptr); \
(ptr) += 2;
-#define TREAD_INT(ptr, num, bigend) \
- (num) = (((ptr)[0]<<((bigend)?24: 0)) | \
- ((ptr)[1]<<((bigend)?16: 8)) | \
- ((ptr)[2]<<((bigend)? 8:16)) | \
- ((ptr)[3]<<((bigend)? 0:24))); \
+#define TREAD_INT(ptr, num, bigend) \
+ (num) = ((bigend) ? load_32_be(ptr) : load_32_le(ptr)); \
(ptr) += 4;
-#define TREAD_INT16(ptr, num, bigend) \
- (num) = (((ptr)[0]<<((bigend)?24: 0)) | \
- ((ptr)[1]<<((bigend)?16: 8))); \
+#define TREAD_INT16(ptr, num, bigend) \
+ (num) = ((bigend) ? (load_16_be(ptr) << 16) : load_16_le(ptr)); \
(ptr) += 2;
#define TWRITE_STR(ptr, str, len) \
g_make_token_header(oid, 14+cksum_size+tmsglen, &ptr, toktype);
/* 0..1 SIGN_ALG */
- ptr[0] = signalg & 0xff;
- ptr[1] = (signalg >> 8) & 0xff;
+ store_16_le(signalg, &ptr[0]);
/* 2..3 SEAL_ALG or Filler */
if ((toktype == KG_TOK_SEAL_MSG) && do_encrypt) {
- ptr[2] = sealalg & 0xff;
- ptr[3] = (sealalg >> 8) & 0xff;
+ store_16_le(sealalg, &ptr[2]);
} else {
/* No seal */
ptr[2] = 0xff;
unsigned char bigend_seqnum[4];
krb5_keyblock *enc_key;
int i;
- bigend_seqnum[0] = (*seqnum>>24) & 0xff;
- bigend_seqnum[1] = (*seqnum>>16) & 0xff;
- bigend_seqnum[2] = (*seqnum>>8) & 0xff;
- bigend_seqnum[3] = *seqnum & 0xff;
+ store_32_be(seqnum, bigend_seqnum);
code = krb5_copy_keyblock (context, enc, &enc_key);
if (code)
{
/*
* lib/gssapi/krb5/k5sealiov.c
*
- * Copyright 2008 by the Massachusetts Institute of Technology.
+ * Copyright 2008, 2009 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
g_make_token_header(ctx->mech_used, 14 + ctx->cksum_size + tmsglen, &ptr, toktype);
/* 0..1 SIGN_ALG */
- ptr[0] = (ctx->signalg ) & 0xFF;
- ptr[1] = (ctx->signalg >> 8) & 0xFF;
+ store_16_le(ctx->signalg, &ptr[0]);
/* 2..3 SEAL_ALG or Filler */
if (toktype == KG_TOK_WRAP_MSG && conf_req_flag) {
- ptr[2] = (ctx->sealalg ) & 0xFF;
- ptr[3] = (ctx->sealalg >> 8) & 0xFF;
+ store_16_le(ctx->sealalg, &ptr[2]);
} else {
/* No seal */
ptr[2] = 0xFF;
krb5_keyblock *enc_key;
size_t i;
- bigend_seqnum[0] = (ctx->seq_send >> 24) & 0xFF;
- bigend_seqnum[1] = (ctx->seq_send >> 16) & 0xFF;
- bigend_seqnum[2] = (ctx->seq_send >> 8 ) & 0xFF;
- bigend_seqnum[3] = (ctx->seq_send ) & 0xFF;
+ store_32_be(ctx->seq_send, bigend_seqnum);
code = krb5_copy_keyblock(context, ctx->enc, &enc_key);
if (code != 0)
unsigned char bigend_seqnum[4];
krb5_keyblock *enc_key;
int i;
- bigend_seqnum[0] = (seqnum>>24) & 0xff;
- bigend_seqnum[1] = (seqnum>>16) & 0xff;
- bigend_seqnum[2] = (seqnum>>8) & 0xff;
- bigend_seqnum[3] = seqnum & 0xff;
+ store_32_be(seqnum, bigend_seqnum);
code = krb5_copy_keyblock (context, ctx->enc, &enc_key);
if (code)
{
/*
* lib/gssapi/krb5/k5unsealiov.c
*
- * Copyright 2008 by the Massachusetts Institute of Technology.
+ * Copyright 2008, 2009 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
krb5_keyblock *enc_key;
size_t i;
- bigend_seqnum[0] = (seqnum >> 24) & 0xFF;
- bigend_seqnum[1] = (seqnum >> 16) & 0xFF;
- bigend_seqnum[2] = (seqnum >> 8 ) & 0xFF;
- bigend_seqnum[3] = (seqnum ) & 0xFF;
+ store_32_be(seqnum, bigend_seqnum);
code = krb5_copy_keyblock(context, ctx->enc, &enc_key);
if (code != 0) {
memcpy(t, kg_arcfour_l40, sizeof(kg_arcfour_l40));
i += sizeof(kg_arcfour_l40);
}
- t[i++] = ms_usage &0xff;
- t[i++] = (ms_usage>>8) & 0xff;
- t[i++] = (ms_usage>>16) & 0xff;
- t[i++] = (ms_usage>>24) & 0xff;
+ store_32_le(ms_usage, &t[i]);
+ i += 4;
input.data = (void *) &t;
input.length = i;
output.data = (void *) usage_key.contents;
memcpy(t, kg_arcfour_l40, sizeof(kg_arcfour_l40));
i += sizeof(kg_arcfour_l40);
}
- t[i++] = ms_usage &0xff;
- t[i++] = (ms_usage>>8) & 0xff;
- t[i++] = (ms_usage>>16) & 0xff;
- t[i++] = (ms_usage>>24) & 0xff;
+ store_32_le(ms_usage, &t[i]);
+ i += 4;
input.data = (void *) &t;
input.length = i;
output.data = (void *) usage_key.contents;
/* -*- mode: c; indent-tabs-mode: nil -*- */
/*
- * Copyright2001 by the Massachusetts Institute of Technology.
+ * Copyright 2001, 2009 by the Massachusetts Institute of Technology.
* Copyright 1993 by OpenVision Technologies, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software
if (key->enctype == ENCTYPE_ARCFOUR_HMAC ||
key->enctype == ENCTYPE_ARCFOUR_HMAC_EXP) {
/* Yes, Microsoft used big-endian sequence number.*/
- plain[0] = (seqnum>>24) & 0xff;
- plain[1] = (seqnum>>16) & 0xff;
- plain[2] = (seqnum>>8) & 0xff;
- plain[3] = seqnum & 0xff;
+ store_32_be(seqnum, plain);
return kg_arcfour_docrypt (key, 0,
cksum, 8,
&plain[0], 8,
}
- plain[0] = (unsigned char) (seqnum&0xff);
- plain[1] = (unsigned char) ((seqnum>>8)&0xff);
- plain[2] = (unsigned char) ((seqnum>>16)&0xff);
- plain[3] = (unsigned char) ((seqnum>>24)&0xff);
-
+ store_32_le(seqnum, plain);
return(kg_encrypt(context, key, KG_USAGE_SEQ, cksum, plain, buf, 8));
}
/* spec allows only 2 bytes for the mech oid length */
mechOidLen = mechOidDERLen + mechOidTagLen + mech_type->length;
- *buf++ = (mechOidLen & 0xFF00) >> 8;
- *buf++ = (mechOidLen & 0x00FF);
+ store_16_be(mechOidLen, buf);
+ buf += 2;
/*
* DER Encoding of mech OID contains OID Tag (0x06), length and
buf += mech_type->length;
/* spec designates the next 4 bytes for the name length */
- *buf++ = (dispName.length & 0xFF000000) >> 24;
- *buf++ = (dispName.length & 0x00FF0000) >> 16;
- *buf++ = (dispName.length & 0x0000FF00) >> 8;
- *buf++ = (dispName.length & 0X000000FF);
+ store_32_be(dispName.length, buf);
+ buf += 4;
/* for the final ingredient - add the name from gss_display_name */
(void) memcpy(buf, dispName.value, dispName.length);
/* length */
- *ptr++ = (packet->length>> 8) & 0xff;
- *ptr++ = packet->length & 0xff;
+ store_16_be(packet->length, ptr);
+ ptr += 2;
/* version == 0x0001 big-endian */
/* ap_req length, big-endian */
- *ptr++ = (ap_req->length>>8) & 0xff;
- *ptr++ = ap_req->length & 0xff;
+ store_16_be(ap_req->length, ptr);
+ ptr += 2;
/* ap-req data */
** build the packet -
*/
/* put in the length */
- *ptr++ = (packet->length>>8) & 0xff;
- *ptr++ = packet->length & 0xff;
+ store_16_be(packet->length, ptr);
+ ptr += 2;
/* put in the version */
*ptr++ = (char)0xff;
*ptr++ = (char)0x80;
/* the ap_req length is big endian */
- *ptr++ = (ap_req->length>>8) & 0xff;
- *ptr++ = ap_req->length & 0xff;
+ store_16_be(ap_req->length, ptr);
+ ptr += 2;
/* put in the request data */
memcpy(ptr, ap_req->data, ap_req->length);
ptr += ap_req->length;
/*
* lib/krb5/os/full_ipadr.c
*
- * Copyright 1995 by the Massachusetts Institute of Technology.
+ * Copyright 1995, 2009 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
tmp16 = kaddr->addrtype;
*marshal++ = 0x00;
*marshal++ = 0x00;
- *marshal++ = (krb5_octet) (tmp16 & 0xff);
- *marshal++ = (krb5_octet) ((tmp16 >> 8) & 0xff);
+ store_16_le(tmp16, marshal);
+ marshal += 2;
tmp32 = kaddr->length;
store_32_le(tmp32, marshal);
#include <gssapi/gssapi_generic.h>
#include "gss-misc.h"
+/* for store_32_be */
+#include "k5-platform.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
}
if (tok->length > 0xffffffffUL)
abort();
- lenbuf[0] = (tok->length >> 24) & 0xff;
- lenbuf[1] = (tok->length >> 16) & 0xff;
- lenbuf[2] = (tok->length >> 8) & 0xff;
- lenbuf[3] = tok->length & 0xff;
-
+ store_32_be(tok->length, lenbuf);
ret = write_all(s, lenbuf, 4);
if (ret < 0) {
perror("sending token length");