Print this page
first pass
@@ -40,12 +40,10 @@
#if defined(__i386) || defined(__amd64)
#include <sys/byteorder.h>
#define UNALIGNED_POINTERS_PERMITTED
#endif
-/* EXPORT DELETE START */
-
typedef struct keysched_s {
uint64_t ksch_encrypt[16];
uint64_t ksch_decrypt[16];
} keysched_t;
@@ -499,17 +497,14 @@
return (des_fp(l, r));
}
#endif /* !sun4u */
-/* EXPORT DELETE END */
-
int
des3_crunch_block(const void *cookie, const uint8_t block[DES_BLOCK_LEN],
uint8_t out_block[DES_BLOCK_LEN], boolean_t decrypt)
{
-/* EXPORT DELETE START */
keysched3_t *ksch = (keysched3_t *)cookie;
/*
* The code below, that is always executed on LITTLE_ENDIAN machines,
* reverses bytes in the block. On BIG_ENDIAN, the same code
@@ -558,19 +553,17 @@
out_block[5] = tmp >> 16;
out_block[6] = tmp >> 8;
out_block[7] = (uint8_t)tmp;
#endif /* UNALIGNED_POINTERS_PERMITTED */
}
-/* EXPORT DELETE END */
return (CRYPTO_SUCCESS);
}
int
des_crunch_block(const void *cookie, const uint8_t block[DES_BLOCK_LEN],
uint8_t out_block[DES_BLOCK_LEN], boolean_t decrypt)
{
-/* EXPORT DELETE START */
keysched_t *ksch = (keysched_t *)cookie;
/*
* The code below, that is always executed on LITTLE_ENDIAN machines,
* reverses bytes in the block. On BIG_ENDIAN, the same code
@@ -621,18 +614,16 @@
out_block[5] = tmp >> 16;
out_block[6] = tmp >> 8;
out_block[7] = (uint8_t)tmp;
#endif /* UNALIGNED_POINTERS_PERMITTED */
}
-/* EXPORT DELETE END */
return (CRYPTO_SUCCESS);
}
static boolean_t
keycheck(uint8_t *key, uint8_t *corrected_key)
{
-/* EXPORT DELETE START */
uint64_t key_so_far;
uint_t i;
/*
* Table of weak and semi-weak keys. Fortunately, weak keys are
* endian-independent, and some semi-weak keys can be paired up in
@@ -714,18 +705,16 @@
corrected_key[5] = key_so_far >> 16;
corrected_key[6] = key_so_far >> 8;
corrected_key[7] = (uint8_t)key_so_far;
#endif /* UNALIGNED_POINTERS_PERMITTED */
}
-/* EXPORT DELETE END */
return (B_TRUE);
}
static boolean_t
des23_keycheck(uint8_t *key, uint8_t *corrected_key, boolean_t des3)
{
-/* EXPORT DELETE START */
uint64_t aligned_key[DES3_KEYSIZE / sizeof (uint64_t)];
uint64_t key_so_far, scratch, *currentkey;
uint_t j, num_weakkeys = 0;
uint8_t keysize = DES3_KEYSIZE;
uint8_t checks = 3;
@@ -779,11 +768,10 @@
if (corrected_key != NULL) {
bcopy(currentkey, corrected_key, keysize);
}
-/* EXPORT DELETE END */
return (B_TRUE);
}
boolean_t
des_keycheck(uint8_t *key, des_strength_t strength, uint8_t *corrected_key)
@@ -800,11 +788,10 @@
}
void
des_parity_fix(uint8_t *key, des_strength_t strength, uint8_t *corrected_key)
{
-/* EXPORT DELETE START */
uint64_t aligned_key[DES3_KEYSIZE / sizeof (uint64_t)];
uint8_t *paritied_key;
uint64_t key_so_far;
int i = 0, offset = 0;
@@ -846,21 +833,19 @@
i++;
}
bcopy(paritied_key, corrected_key, DES_KEYSIZE * strength);
-/* EXPORT DELETE END */
}
/*
* Initialize key schedule for DES, DES2, and DES3
*/
void
des_init_keysched(uint8_t *cipherKey, des_strength_t strength, void *ks)
{
-/* EXPORT DELETE START */
uint64_t *encryption_ks;
uint64_t *decryption_ks;
uint64_t keysched[48];
uint64_t key_uint64[3];
uint64_t tmp;
@@ -945,11 +930,10 @@
keysched[2 * keysize -1 -i] = tmp;
}
/* save the decryption keyschedule */
bcopy(keysched, decryption_ks, keysize * 16);
-/* EXPORT DELETE END */
}
/*
* Allocate key schedule.
*/
@@ -957,12 +941,10 @@
void *
des_alloc_keysched(size_t *keysched_size, des_strength_t strength, int kmflag)
{
void *keysched;
-/* EXPORT DELETE START */
-
size_t size;
switch (strength) {
case DES:
size = sizeof (keysched_t);
@@ -982,12 +964,10 @@
return (NULL);
if (keysched_size != NULL)
*keysched_size = size;
-/* EXPORT DELETE END */
-
return (keysched);
}
/*
* Replace the LSB of each byte by the xor of the other
@@ -995,18 +975,16 @@
* are nullified by including them twice in the xor computation.
*/
static void
fix_des_parity(uint64_t *keyp)
{
-/* EXPORT DELETE START */
uint64_t k = *keyp;
k ^= k >> 1;
k ^= k >> 2;
k ^= k >> 4;
*keyp ^= (k & 0x0101010101010101ULL);
*keyp ^= 0x0101010101010101ULL;
-/* EXPORT DELETE END */
}
void
des_copy_block(uint8_t *in, uint8_t *out)
{