Back to home page

OSCL-LXR

 
 

    


0001 #ifndef _CRYPTO_GCM_H
0002 #define _CRYPTO_GCM_H
0003 
0004 #include <linux/errno.h>
0005 
0006 #define GCM_AES_IV_SIZE 12
0007 #define GCM_RFC4106_IV_SIZE 8
0008 #define GCM_RFC4543_IV_SIZE 8
0009 
0010 /*
0011  * validate authentication tag for GCM
0012  */
0013 static inline int crypto_gcm_check_authsize(unsigned int authsize)
0014 {
0015     switch (authsize) {
0016     case 4:
0017     case 8:
0018     case 12:
0019     case 13:
0020     case 14:
0021     case 15:
0022     case 16:
0023         break;
0024     default:
0025         return -EINVAL;
0026     }
0027 
0028     return 0;
0029 }
0030 
0031 /*
0032  * validate authentication tag for RFC4106
0033  */
0034 static inline int crypto_rfc4106_check_authsize(unsigned int authsize)
0035 {
0036     switch (authsize) {
0037     case 8:
0038     case 12:
0039     case 16:
0040         break;
0041     default:
0042         return -EINVAL;
0043     }
0044 
0045     return 0;
0046 }
0047 
0048 /*
0049  * validate assoclen for RFC4106/RFC4543
0050  */
0051 static inline int crypto_ipsec_check_assoclen(unsigned int assoclen)
0052 {
0053     switch (assoclen) {
0054     case 16:
0055     case 20:
0056         break;
0057     default:
0058         return -EINVAL;
0059     }
0060 
0061     return 0;
0062 }
0063 #endif