diff options
| author | Steve Langasek <steve.langasek@canonical.com> | 2014-10-06 15:39:48 -0700 |
|---|---|---|
| committer | Steve Langasek <steve.langasek@canonical.com> | 2014-10-06 15:39:48 -0700 |
| commit | 72bb39c0237f8bcc3afa8b623e8b097eec6d69cd (patch) | |
| tree | ab49a0f8e82cdee502fd556ad7ccca3242f40f05 /Cryptlib/Cipher | |
| parent | bfab8d6791bccc38a8604cbc933048319c920780 (diff) | |
| download | efi-boot-shim-72bb39c0237f8bcc3afa8b623e8b097eec6d69cd.tar.gz efi-boot-shim-72bb39c0237f8bcc3afa8b623e8b097eec6d69cd.zip | |
Import upstream version 0.7
Diffstat (limited to 'Cryptlib/Cipher')
| -rw-r--r-- | Cryptlib/Cipher/CryptAes.c | 14 | ||||
| -rw-r--r-- | Cryptlib/Cipher/CryptArc4.c | 12 | ||||
| -rw-r--r-- | Cryptlib/Cipher/CryptTdes.c | 22 |
3 files changed, 32 insertions, 16 deletions
diff --git a/Cryptlib/Cipher/CryptAes.c b/Cryptlib/Cipher/CryptAes.c index 45e4a439..753d7981 100644 --- a/Cryptlib/Cipher/CryptAes.c +++ b/Cryptlib/Cipher/CryptAes.c @@ -38,7 +38,7 @@ AesGetContextSize ( Initializes user-supplied memory as AES context for subsequent use.
This function initializes user-supplied memory pointed by AesContext as AES context.
- In addtion, it sets up all AES key materials for subsequent encryption and decryption
+ In addition, it sets up all AES key materials for subsequent encryption and decryption
operations.
There are 3 options for key length, 128 bits, 192 bits, and 256 bits.
@@ -241,7 +241,11 @@ AesCbcEncrypt ( //
// Check input parameters.
//
- if (AesContext == NULL || Input == NULL || (InputSize % AES_BLOCK_SIZE) != 0 || Ivec == NULL || Output == NULL) {
+ if (AesContext == NULL || Input == NULL || (InputSize % AES_BLOCK_SIZE) != 0) {
+ return FALSE;
+ }
+
+ if (Ivec == NULL || Output == NULL || InputSize > INT_MAX) {
return FALSE;
}
@@ -299,7 +303,11 @@ AesCbcDecrypt ( //
// Check input parameters.
//
- if (AesContext == NULL || Input == NULL || (InputSize % AES_BLOCK_SIZE) != 0 || Ivec == NULL || Output == NULL) {
+ if (AesContext == NULL || Input == NULL || (InputSize % AES_BLOCK_SIZE) != 0) {
+ return FALSE;
+ }
+
+ if (Ivec == NULL || Output == NULL || InputSize > INT_MAX) {
return FALSE;
}
diff --git a/Cryptlib/Cipher/CryptArc4.c b/Cryptlib/Cipher/CryptArc4.c index 69214181..f3c4d31a 100644 --- a/Cryptlib/Cipher/CryptArc4.c +++ b/Cryptlib/Cipher/CryptArc4.c @@ -32,14 +32,14 @@ Arc4GetContextSize ( // for backup copy. When Arc4Reset() is called, we can use the backup copy to restore
// the working copy to the initial state.
//
- return (UINTN) (2 * sizeof(RC4_KEY));
+ return (UINTN) (2 * sizeof (RC4_KEY));
}
/**
Initializes user-supplied memory as ARC4 context for subsequent use.
This function initializes user-supplied memory pointed by Arc4Context as ARC4 context.
- In addtion, it sets up all ARC4 key materials for subsequent encryption and decryption
+ In addition, it sets up all ARC4 key materials for subsequent encryption and decryption
operations.
If Arc4Context is NULL, then return FALSE.
@@ -75,7 +75,7 @@ Arc4Init ( RC4_set_key (Rc4Key, (UINT32) KeySize, Key);
- CopyMem (Rc4Key + 1, Rc4Key, sizeof(RC4_KEY));
+ CopyMem (Rc4Key + 1, Rc4Key, sizeof (RC4_KEY));
return TRUE;
}
@@ -115,7 +115,7 @@ Arc4Encrypt ( //
// Check input parameters.
//
- if (Arc4Context == NULL || Input == NULL || Output == NULL) {
+ if (Arc4Context == NULL || Input == NULL || Output == NULL || InputSize > INT_MAX) {
return FALSE;
}
@@ -161,7 +161,7 @@ Arc4Decrypt ( //
// Check input parameters.
//
- if (Arc4Context == NULL || Input == NULL || Output == NULL) {
+ if (Arc4Context == NULL || Input == NULL || Output == NULL || InputSize > INT_MAX) {
return FALSE;
}
@@ -205,7 +205,7 @@ Arc4Reset ( Rc4Key = (RC4_KEY *) Arc4Context;
- CopyMem (Rc4Key, Rc4Key + 1, sizeof(RC4_KEY));
+ CopyMem (Rc4Key, Rc4Key + 1, sizeof (RC4_KEY));
return TRUE;
}
diff --git a/Cryptlib/Cipher/CryptTdes.c b/Cryptlib/Cipher/CryptTdes.c index 8213718b..f89094a5 100644 --- a/Cryptlib/Cipher/CryptTdes.c +++ b/Cryptlib/Cipher/CryptTdes.c @@ -37,7 +37,7 @@ TdesGetContextSize ( Initializes user-supplied memory as TDES context for subsequent use.
This function initializes user-supplied memory pointed by TdesContext as TDES context.
- In addtion, it sets up all TDES key materials for subsequent encryption and decryption
+ In addition, it sets up all TDES key materials for subsequent encryption and decryption
operations.
There are 3 key options as follows:
KeyLength = 64, Keying option 1: K1 == K2 == K3 (Backward compatibility with DES)
@@ -76,9 +76,9 @@ TdesInit ( KeySchedule = (DES_key_schedule *) TdesContext;
//
- //
+ // If input Key is a weak key, return error.
//
- if (DES_is_weak_key ((const_DES_cblock *) Key)) {
+ if (DES_is_weak_key ((const_DES_cblock *) Key) == 1) {
return FALSE;
}
@@ -90,7 +90,7 @@ TdesInit ( return TRUE;
}
- if (DES_is_weak_key ((const_DES_cblock *) Key + 8)) {
+ if (DES_is_weak_key ((const_DES_cblock *) Key + 8) == 1) {
return FALSE;
}
@@ -101,7 +101,7 @@ TdesInit ( return TRUE;
}
- if (DES_is_weak_key ((const_DES_cblock *) Key + 16)) {
+ if (DES_is_weak_key ((const_DES_cblock *) Key + 16) == 1) {
return FALSE;
}
@@ -275,7 +275,11 @@ TdesCbcEncrypt ( //
// Check input parameters.
//
- if (TdesContext == NULL || Input == NULL || (InputSize % TDES_BLOCK_SIZE) != 0 || Ivec == NULL || Output == NULL) {
+ if (TdesContext == NULL || Input == NULL || (InputSize % TDES_BLOCK_SIZE) != 0) {
+ return FALSE;
+ }
+
+ if (Ivec == NULL || Output == NULL || InputSize > INT_MAX) {
return FALSE;
}
@@ -339,7 +343,11 @@ TdesCbcDecrypt ( //
// Check input parameters.
//
- if (TdesContext == NULL || Input == NULL || (InputSize % TDES_BLOCK_SIZE) != 0 || Ivec == NULL || Output == NULL) {
+ if (TdesContext == NULL || Input == NULL || (InputSize % TDES_BLOCK_SIZE) != 0) {
+ return FALSE;
+ }
+
+ if (Ivec == NULL || Output == NULL || InputSize > INT_MAX) {
return FALSE;
}
|
