LCOV - code coverage report
Current view: top level - net80211 - ieee80211_crypto.h (source / functions) Hit Total Coverage
Test: 6.4 Lines: 0 6 0.0 %
Date: 2018-10-19 03:25:38 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*      $OpenBSD: ieee80211_crypto.h,v 1.25 2017/08/18 17:30:12 stsp Exp $      */
       2             : 
       3             : /*-
       4             :  * Copyright (c) 2007,2008 Damien Bergamini <damien.bergamini@free.fr>
       5             :  *
       6             :  * Permission to use, copy, modify, and distribute this software for any
       7             :  * purpose with or without fee is hereby granted, provided that the above
       8             :  * copyright notice and this permission notice appear in all copies.
       9             :  *
      10             :  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
      11             :  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
      12             :  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
      13             :  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
      14             :  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
      15             :  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
      16             :  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
      17             :  */
      18             : 
      19             : #ifndef _NET80211_IEEE80211_CRYPTO_H_
      20             : #define _NET80211_IEEE80211_CRYPTO_H_
      21             : 
      22             : /*
      23             :  * 802.11 protocol crypto-related definitions.
      24             :  */
      25             : 
      26             : /*
      27             :  * 802.11 ciphers.
      28             :  */
      29             : enum ieee80211_cipher {
      30             :         IEEE80211_CIPHER_NONE           = 0x00000000,
      31             :         IEEE80211_CIPHER_USEGROUP       = 0x00000001,
      32             :         IEEE80211_CIPHER_WEP40          = 0x00000002,
      33             :         IEEE80211_CIPHER_TKIP           = 0x00000004,
      34             :         IEEE80211_CIPHER_CCMP           = 0x00000008,
      35             :         IEEE80211_CIPHER_WEP104         = 0x00000010,
      36             :         IEEE80211_CIPHER_BIP            = 0x00000020    /* 11w */
      37             : };
      38             : 
      39             : /*
      40             :  * 802.11 Authentication and Key Management Protocols.
      41             :  */
      42             : enum ieee80211_akm {
      43             :         IEEE80211_AKM_NONE              = 0x00000000,
      44             :         IEEE80211_AKM_8021X             = 0x00000001,
      45             :         IEEE80211_AKM_PSK               = 0x00000002,
      46             :         IEEE80211_AKM_SHA256_8021X      = 0x00000004,   /* 11w */
      47             :         IEEE80211_AKM_SHA256_PSK        = 0x00000008    /* 11w */
      48             : };
      49             : 
      50             : #define IEEE80211_TKIP_HDRLEN   8
      51             : #define IEEE80211_TKIP_MICLEN   8
      52             : #define IEEE80211_TKIP_ICVLEN   4
      53             : #define IEEE80211_CCMP_HDRLEN   8
      54             : #define IEEE80211_CCMP_MICLEN   8
      55             : 
      56             : #define IEEE80211_PMK_LEN       32
      57             : 
      58             : #ifdef _KERNEL 
      59             : 
      60             : static __inline int
      61           0 : ieee80211_is_8021x_akm(enum ieee80211_akm akm)
      62             : {
      63           0 :         return akm == IEEE80211_AKM_8021X ||
      64           0 :             akm == IEEE80211_AKM_SHA256_8021X;
      65             : }
      66             : 
      67             : static __inline int
      68           0 : ieee80211_is_sha256_akm(enum ieee80211_akm akm)
      69             : {
      70           0 :         return akm == IEEE80211_AKM_SHA256_8021X ||
      71           0 :             akm == IEEE80211_AKM_SHA256_PSK;
      72             : }
      73             : 
      74             : struct ieee80211_key {
      75             :         u_int8_t                k_id;           /* identifier (0-5) */
      76             :         enum ieee80211_cipher   k_cipher;
      77             :         u_int                   k_flags;
      78             : #define IEEE80211_KEY_GROUP     0x00000001      /* group data key */
      79             : #define IEEE80211_KEY_TX        0x00000002      /* Tx+Rx */
      80             : #define IEEE80211_KEY_IGTK      0x00000004      /* integrity group key */
      81             : 
      82             :         u_int                   k_len;
      83             :         u_int64_t               k_rsc[IEEE80211_NUM_TID];
      84             :         u_int64_t               k_mgmt_rsc;
      85             :         u_int64_t               k_tsc;
      86             :         u_int8_t                k_key[32];
      87             :         void                    *k_priv;
      88             : };
      89             : 
      90             : #define IEEE80211_KEYBUF_SIZE   16
      91             : 
      92             : /*
      93             :  * Entry in the PMKSA cache.
      94             :  */
      95             : struct ieee80211_pmk {
      96             :         enum ieee80211_akm      pmk_akm;
      97             :         u_int32_t               pmk_lifetime;
      98             : #define IEEE80211_PMK_INFINITE  0
      99             : 
     100             :         u_int8_t                pmk_pmkid[IEEE80211_PMKID_LEN];
     101             :         u_int8_t                pmk_macaddr[IEEE80211_ADDR_LEN];
     102             :         u_int8_t                pmk_key[IEEE80211_PMK_LEN];
     103             : 
     104             :         TAILQ_ENTRY(ieee80211_pmk) pmk_next;
     105             : };
     106             : 
     107             : /* forward references */
     108             : struct  ieee80211com;
     109             : struct  ieee80211_node;
     110             : 
     111             : void    ieee80211_crypto_attach(struct ifnet *);
     112             : void    ieee80211_crypto_detach(struct ifnet *);
     113             : 
     114             : void    ieee80211_crypto_clear_groupkeys(struct ieee80211com *);
     115             : struct  ieee80211_key *ieee80211_get_txkey(struct ieee80211com *,
     116             :             const struct ieee80211_frame *, struct ieee80211_node *);
     117             : struct  ieee80211_key *ieee80211_get_rxkey(struct ieee80211com *,
     118             :             struct mbuf *, struct ieee80211_node *);
     119             : struct  mbuf *ieee80211_encrypt(struct ieee80211com *, struct mbuf *,
     120             :             struct ieee80211_key *);
     121             : struct  mbuf *ieee80211_decrypt(struct ieee80211com *, struct mbuf *,
     122             :             struct ieee80211_node *);
     123             : 
     124             : int     ieee80211_set_key(struct ieee80211com *, struct ieee80211_node *,
     125             :             struct ieee80211_key *);
     126             : void    ieee80211_delete_key(struct ieee80211com *, struct ieee80211_node *,
     127             :             struct ieee80211_key *);
     128             : 
     129             : void    ieee80211_eapol_key_mic(struct ieee80211_eapol_key *,
     130             :             const u_int8_t *);
     131             : int     ieee80211_eapol_key_check_mic(struct ieee80211_eapol_key *,
     132             :             const u_int8_t *);
     133             : #ifndef IEEE80211_STA_ONLY
     134             : void    ieee80211_eapol_key_encrypt(struct ieee80211com *,
     135             :             struct ieee80211_eapol_key *, const u_int8_t *);
     136             : #endif
     137             : int     ieee80211_eapol_key_decrypt(struct ieee80211_eapol_key *,
     138             :             const u_int8_t *);
     139             : 
     140             : struct  ieee80211_pmk *ieee80211_pmksa_add(struct ieee80211com *,
     141             :             enum ieee80211_akm, const u_int8_t *, const u_int8_t *, u_int32_t);
     142             : struct  ieee80211_pmk *ieee80211_pmksa_find(struct ieee80211com *,
     143             :             struct ieee80211_node *, const u_int8_t *);
     144             : void    ieee80211_derive_ptk(enum ieee80211_akm, const u_int8_t *,
     145             :             const u_int8_t *, const u_int8_t *, const u_int8_t *,
     146             :             const u_int8_t *, struct ieee80211_ptk *);
     147             : int     ieee80211_cipher_keylen(enum ieee80211_cipher);
     148             : 
     149             : int     ieee80211_wep_set_key(struct ieee80211com *, struct ieee80211_key *);
     150             : void    ieee80211_wep_delete_key(struct ieee80211com *,
     151             :             struct ieee80211_key *);
     152             : struct  mbuf *ieee80211_wep_encrypt(struct ieee80211com *, struct mbuf *,
     153             :             struct ieee80211_key *);
     154             : struct  mbuf *ieee80211_wep_decrypt(struct ieee80211com *, struct mbuf *,
     155             :             struct ieee80211_key *);
     156             : 
     157             : int     ieee80211_tkip_set_key(struct ieee80211com *, struct ieee80211_key *);
     158             : void    ieee80211_tkip_delete_key(struct ieee80211com *,
     159             :             struct ieee80211_key *);
     160             : struct  mbuf *ieee80211_tkip_encrypt(struct ieee80211com *,
     161             :             struct mbuf *, struct ieee80211_key *);
     162             : struct  mbuf *ieee80211_tkip_decrypt(struct ieee80211com *,
     163             :             struct mbuf *, struct ieee80211_key *);
     164             : void    ieee80211_tkip_mic(struct mbuf *, int, const u_int8_t *,
     165             :             u_int8_t[IEEE80211_TKIP_MICLEN]);
     166             : void    ieee80211_michael_mic_failure(struct ieee80211com *, u_int64_t);
     167             : #ifndef IEEE80211_STA_ONLY
     168             : void    ieee80211_michael_mic_failure_timeout(void *);
     169             : #endif
     170             : 
     171             : int     ieee80211_ccmp_set_key(struct ieee80211com *, struct ieee80211_key *);
     172             : void    ieee80211_ccmp_delete_key(struct ieee80211com *,
     173             :             struct ieee80211_key *);
     174             : struct  mbuf *ieee80211_ccmp_encrypt(struct ieee80211com *, struct mbuf *,
     175             :             struct ieee80211_key *);
     176             : struct  mbuf *ieee80211_ccmp_decrypt(struct ieee80211com *, struct mbuf *,
     177             :             struct ieee80211_key *);
     178             : 
     179             : int     ieee80211_bip_set_key(struct ieee80211com *, struct ieee80211_key *);
     180             : void    ieee80211_bip_delete_key(struct ieee80211com *,
     181             :             struct ieee80211_key *);
     182             : struct  mbuf *ieee80211_bip_encap(struct ieee80211com *, struct mbuf *,
     183             :             struct ieee80211_key *);
     184             : struct  mbuf *ieee80211_bip_decap(struct ieee80211com *, struct mbuf *,
     185             :             struct ieee80211_key *);
     186             : 
     187             : #endif /* _KERNEL */
     188             : #endif /* _NET80211_IEEE80211_CRYPTO_H_ */

Generated by: LCOV version 1.13