lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALLzPKaczBwsj0s5wxTLaZ2_=J_fCdbP2SB0R2oUxMyHLDRYMg@mail.gmail.com>
Date:	Thu, 16 Aug 2012 00:11:10 +0300
From:	"Kasatkin, Dmitry" <dmitry.kasatkin@...el.com>
To:	Serge Hallyn <serge.hallyn@...onical.com>
Cc:	zohar@...ux.vnet.ibm.com, jmorris@...ei.org, rusty@...tcorp.com.au,
	dhowells@...hat.com, linux-security-module@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [RFC v2 1/7] integrity: added digest calculation function

On Wed, Aug 15, 2012 at 11:11 PM, Serge Hallyn
<serge.hallyn@...onical.com> wrote:
> Quoting Dmitry Kasatkin (dmitry.kasatkin@...el.com):
>> There are several functions, that need to calculate digest.
>> This patch adds common function for use by integrity subsystem.
>>
>> Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@...el.com>
>> ---
>>  security/integrity/digsig.c    |   31 +++++++++++++++++++++++++++++--
>>  security/integrity/integrity.h |    3 +++
>>  2 files changed, 32 insertions(+), 2 deletions(-)
>>
>> diff --git a/security/integrity/digsig.c b/security/integrity/digsig.c
>> index 2dc167d..61a0c92 100644
>> --- a/security/integrity/digsig.c
>> +++ b/security/integrity/digsig.c
>> @@ -13,9 +13,9 @@
>>  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>>
>>  #include <linux/err.h>
>> -#include <linux/rbtree.h>
>>  #include <linux/key-type.h>
>>  #include <linux/digsig.h>
>> +#include <crypto/hash.h>
>>
>>  #include "integrity.h"
>>
>> @@ -28,7 +28,7 @@ static const char *keyring_name[INTEGRITY_KEYRING_MAX] = {
>>  };
>>
>>  int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen,
>> -                                     const char *digest, int digestlen)
>> +                         const char *digest, int digestlen)
>>  {
>>       if (id >= INTEGRITY_KEYRING_MAX)
>>               return -EINVAL;
>> @@ -46,3 +46,30 @@ int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen,
>>
>>       return digsig_verify(keyring[id], sig, siglen, digest, digestlen);
>>  }
>> +
>> +int integrity_calc_digest(const char *algo, const void *data, const int len,
>> +                       char *digest)
>> +{
>> +     int rc = -ENOMEM;
>> +     struct crypto_shash *tfm;
>> +
>> +     tfm = crypto_alloc_shash(algo, 0, 0);
>> +     if (IS_ERR(tfm)) {
>> +             rc = PTR_ERR(tfm);
>> +             pr_err("Can not allocate %s (reason: %d)\n", algo, rc);
>> +             return rc;
>> +     } else {
>> +             struct {
>> +                     struct shash_desc shash;
>> +                     char ctx[crypto_shash_descsize(tfm)];
>> +             } desc;
>
> Needless confusing indentation here.  Just move the struct {} desc; to the
> top and drop the else.  That will make it much more readable.
>

Intention was to allocate it only if tfm allocation succeeded..
But indeed failure very unlikely..

thanks.

>> +             desc.shash.tfm = tfm;
>> +             desc.shash.flags = 0;
>> +
>> +             rc = crypto_shash_digest(&desc.shash, data, len, digest);
>> +     }
>> +
>> +     crypto_free_shash(tfm);
>> +     return rc;
>> +}
>> diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h
>> index e21362a..48ee2d4 100644
>> --- a/security/integrity/integrity.h
>> +++ b/security/integrity/integrity.h
>> @@ -59,6 +59,9 @@ struct integrity_iint_cache *integrity_iint_find(struct inode *inode);
>>
>>  #ifdef CONFIG_INTEGRITY_SIGNATURE
>>
>> +int integrity_calc_digest(const char *algo, const void *data, const int len,
>> +                       char *digest);
>> +
>>  int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen,
>>                                       const char *digest, int digestlen);
>>
>> --
>> 1.7.9.5
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
>> the body of a message to majordomo@...r.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ