UBUNTU: SAUCE: apparmor4.0.0 [43/90]: LSM stacking v39: UBUNTU: SAUCE: apparmor4.0.0 [12/95]: add/use fns to print hash string hex value
BugLink: http://bugs.launchpad.net/bugs/2028253 Signed-off-by: John Johansen <john.johansen@canonical.com> (cherry picked from https://gitlab.com/jjohansen/apparmor-kernel) Signed-off-by: Andrea Righi <andrea.righi@canonical.com> (cherry picked from commit f29a03f77b0c72a62fe44e1b1942d7e497b32fd5 https://git.launchpad.net/~apparmor-dev/ubuntu-kernel-next) Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
This commit is contained in:
committed by
Paolo Pisati
parent
47fd788813
commit
77811af4f0
@@ -25,6 +25,26 @@ unsigned int aa_hash_size(void)
|
||||
return apparmor_hash_size;
|
||||
}
|
||||
|
||||
void aa_snprint_hashstr(char *out, unsigned char *hash, unsigned int hsize)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < hsize; i++)
|
||||
sprintf(out + i*2, "%.2x", hash[i]);
|
||||
out[hsize*2] = 0;
|
||||
}
|
||||
|
||||
char *aa_asprint_hashstr(unsigned char *hash, unsigned int hsize, gfp_t gfp)
|
||||
{
|
||||
char *buffer = kmalloc(hsize*2 + 1, gfp);
|
||||
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
aa_snprint_hashstr(buffer, hash, hsize);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
char *aa_calc_hash(void *data, size_t len)
|
||||
{
|
||||
SHASH_DESC_ON_STACK(desc, apparmor_tfm);
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
#ifdef CONFIG_SECURITY_APPARMOR_HASH
|
||||
unsigned int aa_hash_size(void);
|
||||
void aa_snprint_hashstr(char *out, unsigned char *hash, unsigned int hsize);
|
||||
char *aa_asprint_hashstr(unsigned char *hash, unsigned int hsize, gfp_t gfp);
|
||||
char *aa_calc_hash(void *data, size_t len);
|
||||
int aa_calc_profile_hash(struct aa_profile *profile, u32 version, void *start,
|
||||
size_t len);
|
||||
@@ -32,6 +34,15 @@ static inline unsigned int aa_hash_size(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void aa_snprint_hashstr(char *out, unsigned char *hash, unsigned int hsize)
|
||||
{
|
||||
}
|
||||
|
||||
char *aa_asprint_hashstr(unsigned char *hash, unsigned int hsize, gfp_t gfp);
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPARMOR_CRYPTO_H */
|
||||
|
||||
Reference in New Issue
Block a user