€•‰ÌŒsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ'/translations/zh_CN/crypto/architecture”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ'/translations/zh_TW/crypto/architecture”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ'/translations/it_IT/crypto/architecture”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ'/translations/ja_JP/crypto/architecture”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ'/translations/ko_KR/crypto/architecture”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒPortuguese (Brazilian)”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ'/translations/pt_BR/crypto/architecture”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ'/translations/sp_SP/crypto/architecture”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒKernel Crypto API Architecture”h]”hŒKernel Crypto API Architecture”…””}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³ŒA/var/lib/git/docbuild/linux/Documentation/crypto/architecture.rst”h´Kubh¶)”}”(hhh]”(h»)”}”(hŒCipher algorithm types”h]”hŒCipher algorithm types”…””}”(hhÎh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhhËh²hh³hÊh´KubhŒ paragraph”“”)”}”(hŒRThe kernel crypto API provides different API calls for the following cipher types:”h]”hŒRThe kernel crypto API provides different API calls for the following cipher types:”…””}”(hhÞh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KhhËh²hubhŒ bullet_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒSymmetric ciphers ”h]”hÝ)”}”(hŒSymmetric ciphers”h]”hŒSymmetric ciphers”…””}”(hh÷h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K hhóubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhhîh²hh³hÊh´Nubhò)”}”(hŒ AEAD ciphers ”h]”hÝ)”}”(hŒ AEAD ciphers”h]”hŒ AEAD ciphers”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhhîh²hh³hÊh´Nubhò)”}”(hŒ/Message digest, including keyed message digest ”h]”hÝ)”}”(hŒ.Message digest, including keyed message digest”h]”hŒ.Message digest, including keyed message digest”…””}”(hj'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Khj#ubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhhîh²hh³hÊh´Nubhò)”}”(hŒRandom number generation ”h]”hÝ)”}”(hŒRandom number generation”h]”hŒRandom number generation”…””}”(hj?h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Khj;ubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhhîh²hh³hÊh´Nubhò)”}”(hŒUser space interface ”h]”hÝ)”}”(hŒUser space interface”h]”hŒUser space interface”…””}”(hjWh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KhjSubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhhîh²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1hìh³hÊh´K hhËh²hubeh}”(h]”Œcipher-algorithm-types”ah ]”h"]”Œcipher algorithm types”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)”}”(hhh]”(h»)”}”(hŒCiphers And Templates”h]”hŒCiphers And Templates”…””}”(hj~h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj{h²hh³hÊh´KubhÝ)”}”(hX<The kernel crypto API provides implementations of single block ciphers and message digests. In addition, the kernel crypto API provides numerous "templates" that can be used in conjunction with the single block ciphers and message digests. Templates include all types of block chaining mode, the HMAC mechanism, etc.”h]”hX@The kernel crypto API provides implementations of single block ciphers and message digests. In addition, the kernel crypto API provides numerous “templates†that can be used in conjunction with the single block ciphers and message digests. Templates include all types of block chaining mode, the HMAC mechanism, etc.”…””}”(hjŒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Khj{h²hubhÝ)”}”(hŒªSingle block ciphers and message digests can either be directly used by a caller or invoked together with a template to form multi-block ciphers or keyed message digests.”h]”hŒªSingle block ciphers and message digests can either be directly used by a caller or invoked together with a template to form multi-block ciphers or keyed message digests.”…””}”(hjšh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Khj{h²hubhÝ)”}”(hŒ|A single block cipher may even be called with multiple templates. However, templates cannot be used without a single cipher.”h]”hŒ|A single block cipher may even be called with multiple templates. However, templates cannot be used without a single cipher.”…””}”(hj¨h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K!hj{h²hubhÝ)”}”(hŒ4See /proc/crypto and search for "name". For example:”h]”hŒ8See /proc/crypto and search for “nameâ€. For example:”…””}”(hj¶h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K$hj{h²hubhí)”}”(hhh]”(hò)”}”(hŒaes ”h]”hÝ)”}”(hŒaes”h]”hŒaes”…””}”(hjËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K&hjÇubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhjÄh²hh³hÊh´Nubhò)”}”(hŒ ecb(aes) ”h]”hÝ)”}”(hŒecb(aes)”h]”hŒecb(aes)”…””}”(hjãh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K(hjßubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhjÄh²hh³hÊh´Nubhò)”}”(hŒ cmac(aes) ”h]”hÝ)”}”(hŒ cmac(aes)”h]”hŒ cmac(aes)”…””}”(hjûh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K*hj÷ubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhjÄh²hh³hÊh´Nubhò)”}”(hŒ ccm(aes) ”h]”hÝ)”}”(hŒccm(aes)”h]”hŒccm(aes)”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K,hjubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhjÄh²hh³hÊh´Nubhò)”}”(hŒrfc4106(gcm(aes)) ”h]”hÝ)”}”(hŒrfc4106(gcm(aes))”h]”hŒrfc4106(gcm(aes))”…””}”(hj+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K.hj'ubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhjÄh²hh³hÊh´Nubhò)”}”(hŒsha1 ”h]”hÝ)”}”(hŒsha1”h]”hŒsha1”…””}”(hjCh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K0hj?ubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhjÄh²hh³hÊh´Nubhò)”}”(hŒ hmac(sha1) ”h]”hÝ)”}”(hŒ hmac(sha1)”h]”hŒ hmac(sha1)”…””}”(hj[h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K2hjWubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhjÄh²hh³hÊh´Nubhò)”}”(hŒauthenc(hmac(sha1),cbc(aes)) ”h]”hÝ)”}”(hŒauthenc(hmac(sha1),cbc(aes))”h]”hŒauthenc(hmac(sha1),cbc(aes))”…””}”(hjsh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K4hjoubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhjÄh²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jqjruh1hìh³hÊh´K&hj{h²hubhÝ)”}”(hŒUIn these examples, "aes" and "sha1" are the ciphers and all others are the templates.”h]”hŒ]In these examples, “aes†and “sha1†are the ciphers and all others are the templates.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K6hj{h²hubeh}”(h]”Œciphers-and-templates”ah ]”h"]”Œciphers and templates”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)”}”(hhh]”(h»)”}”(hŒ&Synchronous And Asynchronous Operation”h]”hŒ&Synchronous And Asynchronous Operation”…””}”(hj¦h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj£h²hh³hÊh´K:ubhÝ)”}”(hŒKThe kernel crypto API provides synchronous and asynchronous API operations.”h]”hŒKThe kernel crypto API provides synchronous and asynchronous API operations.”…””}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhjÃh²hh³hÊh´Nubhò)”}”(hŒ-CRYPTO_ALG_TYPE_RNG Random Number Generation ”h]”hÝ)”}”(hŒ,CRYPTO_ALG_TYPE_RNG Random Number Generation”h]”hŒ,CRYPTO_ALG_TYPE_RNG Random Number Generation”…””}”(hjZh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KÓhjVubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhjÃh²hh³hÊh´Nubhò)”}”(hŒ+CRYPTO_ALG_TYPE_AKCIPHER Asymmetric cipher ”h]”hÝ)”}”(hŒ*CRYPTO_ALG_TYPE_AKCIPHER Asymmetric cipher”h]”hŒ*CRYPTO_ALG_TYPE_AKCIPHER Asymmetric cipher”…””}”(hjrh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KÕhjnubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhjÃh²hh³hÊh´Nubhò)”}”(hŒ)CRYPTO_ALG_TYPE_SIG Asymmetric signature ”h]”hÝ)”}”(hŒ(CRYPTO_ALG_TYPE_SIG Asymmetric signature”h]”hŒ(CRYPTO_ALG_TYPE_SIG Asymmetric signature”…””}”(hjŠh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K×hj†ubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhjÃh²hh³hÊh´Nubhò)”}”(hX$CRYPTO_ALG_TYPE_PCOMPRESS Enhanced version of CRYPTO_ALG_TYPE_COMPRESS allowing for segmented compression / decompression instead of performing the operation on one segment only. CRYPTO_ALG_TYPE_PCOMPRESS is intended to replace CRYPTO_ALG_TYPE_COMPRESS once existing consumers are converted. ”h]”hÝ)”}”(hX#CRYPTO_ALG_TYPE_PCOMPRESS Enhanced version of CRYPTO_ALG_TYPE_COMPRESS allowing for segmented compression / decompression instead of performing the operation on one segment only. CRYPTO_ALG_TYPE_PCOMPRESS is intended to replace CRYPTO_ALG_TYPE_COMPRESS once existing consumers are converted.”h]”hX#CRYPTO_ALG_TYPE_PCOMPRESS Enhanced version of CRYPTO_ALG_TYPE_COMPRESS allowing for segmented compression / decompression instead of performing the operation on one segment only. CRYPTO_ALG_TYPE_PCOMPRESS is intended to replace CRYPTO_ALG_TYPE_COMPRESS once existing consumers are converted.”…””}”(hj¢h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KÙhjžubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhjÃh²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jqjruh1hìh³hÊh´KÅhj–h²hubhÝ)”}”(hŒÇThe mask flag restricts the type of cipher. The only allowed flag is CRYPTO_ALG_ASYNC to restrict the cipher lookup function to asynchronous ciphers. Usually, a caller provides a 0 for the mask flag.”h]”hŒÇThe mask flag restricts the type of cipher. The only allowed flag is CRYPTO_ALG_ASYNC to restrict the cipher lookup function to asynchronous ciphers. Usually, a caller provides a 0 for the mask flag.”…””}”(hj¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kßhj–h²hubhÝ)”}”(hXaWhen the caller provides a mask and type specification, the caller limits the search the kernel crypto API can perform for a suitable cipher implementation for the given cipher name. That means, even when a caller uses a cipher name that exists during its initialization call, the kernel crypto API may not select it due to the used type and mask field.”h]”hXaWhen the caller provides a mask and type specification, the caller limits the search the kernel crypto API can perform for a suitable cipher implementation for the given cipher name. That means, even when a caller uses a cipher name that exists during its initialization call, the kernel crypto API may not select it due to the used type and mask field.”…””}”(hjÊh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kãhj–h²hubeh}”(h]”Œ cipher-allocation-type-and-masks”ah ]”h"]”Œ cipher allocation type and masks”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kºubh¶)”}”(hhh]”(h»)”}”(hŒ'Internal Structure of Kernel Crypto API”h]”hŒ'Internal Structure of Kernel Crypto API”…””}”(hjãh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjàh²hh³hÊh´KëubhÝ)”}”(hŒêThe kernel crypto API has an internal structure where a cipher implementation may use many layers and indirections. This section shall help to clarify how the kernel crypto API uses various components to implement the complete cipher.”h]”hŒêThe kernel crypto API has an internal structure where a cipher implementation may use many layers and indirections. This section shall help to clarify how the kernel crypto API uses various components to implement the complete cipher.”…””}”(hjñh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kíhjàh²hubhÝ)”}”(hŒÉThe following subsections explain the internal structure based on existing cipher implementations. The first section addresses the most complex scenario where all other scenarios form a logical subset.”h]”hŒÉThe following subsections explain the internal structure based on existing cipher implementations. The first section addresses the most complex scenario where all other scenarios form a logical subset.”…””}”(hjÿh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kòhjàh²hubh¶)”}”(hhh]”(h»)”}”(hŒGeneric AEAD Cipher Structure”h]”hŒGeneric AEAD Cipher Structure”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj h²hh³hÊh´K÷ubhÝ)”}”(hŒªThe following ASCII art decomposes the kernel crypto API layers when using the AEAD cipher with the automated IV generation. The shown example is used by the IPSEC layer.”h]”hŒªThe following ASCII art decomposes the kernel crypto API layers when using the AEAD cipher with the automated IV generation. The shown example is used by the IPSEC layer.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kùhj h²hubhÝ)”}”(hŒ»For other use cases of AEAD ciphers, the ASCII art applies as well, but the caller may not use the AEAD cipher with a separate IV generator. In this case, the caller must generate the IV.”h]”hŒ»For other use cases of AEAD ciphers, the ASCII art applies as well, but the caller may not use the AEAD cipher with a separate IV generator. In this case, the caller must generate the IV.”…””}”(hj,h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kýhj h²hubhÝ)”}”(hXThe depicted example decomposes the AEAD cipher of GCM(AES) based on the generic C implementations (gcm.c, aes-generic.c, ctr.c, ghash-generic.c, seqiv.c). The generic implementation serves as an example showing the complete logic of the kernel crypto API.”h]”hXThe depicted example decomposes the AEAD cipher of GCM(AES) based on the generic C implementations (gcm.c, aes-generic.c, ctr.c, ghash-generic.c, seqiv.c). The generic implementation serves as an example showing the complete logic of the kernel crypto API.”…””}”(hj:h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mhj h²hubhÝ)”}”(hX<It is possible that some streamlined cipher implementations (like AES-NI) provide implementations merging aspects which in the view of the kernel crypto API cannot be decomposed into layers any more. In case of the AES-NI implementation, the CTR mode, the GHASH implementation and the AES cipher are all merged into one cipher implementation registered with the kernel crypto API. In this case, the concept described by the following ASCII art applies too. However, the decomposition of GCM into the individual sub-components by the kernel crypto API is not done any more.”h]”hX<It is possible that some streamlined cipher implementations (like AES-NI) provide implementations merging aspects which in the view of the kernel crypto API cannot be decomposed into layers any more. In case of the AES-NI implementation, the CTR mode, the GHASH implementation and the AES cipher are all merged into one cipher implementation registered with the kernel crypto API. In this case, the concept described by the following ASCII art applies too. However, the decomposition of GCM into the individual sub-components by the kernel crypto API is not done any more.”…””}”(hjHh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mhj h²hubhÝ)”}”(hXEach block in the following ASCII art is an independent cipher instance obtained from the kernel crypto API. Each block is accessed by the caller or by other blocks using the API functions defined by the kernel crypto API for the cipher implementation type.”h]”hXEach block in the following ASCII art is an independent cipher instance obtained from the kernel crypto API. Each block is accessed by the caller or by other blocks using the API functions defined by the kernel crypto API for the cipher implementation type.”…””}”(hjVh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mhj h²hubhÝ)”}”(hŒbThe blocks below indicate the cipher type as well as the specific logic implemented in the cipher.”h]”hŒbThe blocks below indicate the cipher type as well as the specific logic implemented in the cipher.”…””}”(hjdh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mhj h²hubhÝ)”}”(hŒÓThe ASCII art picture also indicates the call structure, i.e. who calls which component. The arrows point to the invoked block where the caller uses the API applicable to the cipher type specified for the block.”h]”hŒÓThe ASCII art picture also indicates the call structure, i.e. who calls which component. The arrows point to the invoked block where the caller uses the API applicable to the cipher type specified for the block.”…””}”(hjrh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mhj h²hubj)”}”(hX;kernel crypto API | IPSEC Layer | +-----------+ | | | (1) | aead | <----------------------------------- esp_output | (seqiv) | ---+ +-----------+ | | (2) +-----------+ | | | <--+ (2) | aead | <----------------------------------- esp_input | (gcm) | ------------+ +-----------+ | | (3) | (5) v v +-----------+ +-----------+ | | | | | skcipher | | ahash | | (ctr) | ---+ | (ghash) | +-----------+ | +-----------+ | +-----------+ | (4) | | <--+ | cipher | | (aes) | +-----------+”h]”hX;kernel crypto API | IPSEC Layer | +-----------+ | | | (1) | aead | <----------------------------------- esp_output | (seqiv) | ---+ +-----------+ | | (2) +-----------+ | | | <--+ (2) | aead | <----------------------------------- esp_input | (gcm) | ------------+ +-----------+ | | (3) | (5) v v +-----------+ +-----------+ | | | | | skcipher | | ahash | | (ctr) | ---+ | (ghash) | +-----------+ | +-----------+ | +-----------+ | (4) | | <--+ | cipher | | (aes) | +-----------+”…””}”hj€sbah}”(h]”h ]”h"]”h$]”h&]”jjuh1jh³hÊh´Mhj h²hubhÝ)”}”(hX+The following call sequence is applicable when the IPSEC layer triggers an encryption operation with the esp_output function. During configuration, the administrator set up the use of seqiv(rfc4106(gcm(aes))) as the cipher for ESP. The following call sequence is now depicted in the ASCII art above:”h]”hX+The following call sequence is applicable when the IPSEC layer triggers an encryption operation with the esp_output function. During configuration, the administrator set up the use of seqiv(rfc4106(gcm(aes))) as the cipher for ESP. The following call sequence is now depicted in the ASCII art above:”…””}”(hjŽh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M<hj h²hubhŒenumerated_list”“”)”}”(hhh]”(hò)”}”(hŒ‘esp_output() invokes crypto_aead_encrypt() to trigger an encryption operation of the AEAD cipher with IV generator. The SEQIV generates the IV. ”h]”(hÝ)”}”(hŒsesp_output() invokes crypto_aead_encrypt() to trigger an encryption operation of the AEAD cipher with IV generator.”h]”hŒsesp_output() invokes crypto_aead_encrypt() to trigger an encryption operation of the AEAD cipher with IV generator.”…””}”(hj¥h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MBhj¡ubhÝ)”}”(hŒThe SEQIV generates the IV.”h]”hŒThe SEQIV generates the IV.”…””}”(hj³h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MEhj¡ubeh}”(h]”h ]”h"]”h$]”h&]”uh1hñhjžh²hh³hÊh´Nubhò)”}”(hX2Now, SEQIV uses the AEAD API function calls to invoke the associated AEAD cipher. In our case, during the instantiation of SEQIV, the cipher handle for GCM is provided to SEQIV. This means that SEQIV invokes AEAD cipher operations with the GCM cipher handle. During instantiation of the GCM handle, the CTR(AES) and GHASH ciphers are instantiated. The cipher handles for CTR(AES) and GHASH are retained for later use. The GCM implementation is responsible to invoke the CTR mode AES and the GHASH cipher in the right manner to implement the GCM specification. ”h]”(hÝ)”}”(hXNow, SEQIV uses the AEAD API function calls to invoke the associated AEAD cipher. In our case, during the instantiation of SEQIV, the cipher handle for GCM is provided to SEQIV. This means that SEQIV invokes AEAD cipher operations with the GCM cipher handle.”h]”hXNow, SEQIV uses the AEAD API function calls to invoke the associated AEAD cipher. In our case, during the instantiation of SEQIV, the cipher handle for GCM is provided to SEQIV. This means that SEQIV invokes AEAD cipher operations with the GCM cipher handle.”…””}”(hjËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MGhjÇubhÝ)”}”(hŒžDuring instantiation of the GCM handle, the CTR(AES) and GHASH ciphers are instantiated. The cipher handles for CTR(AES) and GHASH are retained for later use.”h]”hŒžDuring instantiation of the GCM handle, the CTR(AES) and GHASH ciphers are instantiated. The cipher handles for CTR(AES) and GHASH are retained for later use.”…””}”(hjÙh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MLhjÇubhÝ)”}”(hŒThe GCM implementation is responsible to invoke the CTR mode AES and the GHASH cipher in the right manner to implement the GCM specification.”h]”hŒThe GCM implementation is responsible to invoke the CTR mode AES and the GHASH cipher in the right manner to implement the GCM specification.”…””}”(hjçh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MPhjÇubeh}”(h]”h ]”h"]”h$]”h&]”uh1hñhjžh²hh³hÊh´Nubhò)”}”(hXÁThe GCM AEAD cipher type implementation now invokes the SKCIPHER API with the instantiated CTR(AES) cipher handle. During instantiation of the CTR(AES) cipher, the CIPHER type implementation of AES is instantiated. The cipher handle for AES is retained. That means that the SKCIPHER implementation of CTR(AES) only implements the CTR block chaining mode. After performing the block chaining operation, the CIPHER implementation of AES is invoked. ”h]”(hÝ)”}”(hŒrThe GCM AEAD cipher type implementation now invokes the SKCIPHER API with the instantiated CTR(AES) cipher handle.”h]”hŒrThe GCM AEAD cipher type implementation now invokes the SKCIPHER API with the instantiated CTR(AES) cipher handle.”…””}”(hjÿh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MThjûubhÝ)”}”(hŒŠDuring instantiation of the CTR(AES) cipher, the CIPHER type implementation of AES is instantiated. The cipher handle for AES is retained.”h]”hŒŠDuring instantiation of the CTR(AES) cipher, the CIPHER type implementation of AES is instantiated. The cipher handle for AES is retained.”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MWhjûubhÝ)”}”(hŒÀThat means that the SKCIPHER implementation of CTR(AES) only implements the CTR block chaining mode. After performing the block chaining operation, the CIPHER implementation of AES is invoked.”h]”hŒÀThat means that the SKCIPHER implementation of CTR(AES) only implements the CTR block chaining mode. After performing the block chaining operation, the CIPHER implementation of AES is invoked.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M[hjûubeh}”(h]”h ]”h"]”h$]”h&]”uh1hñhjžh²hh³hÊh´Nubhò)”}”(hŒeThe SKCIPHER of CTR(AES) now invokes the CIPHER API with the AES cipher handle to encrypt one block. ”h]”hÝ)”}”(hŒdThe SKCIPHER of CTR(AES) now invokes the CIPHER API with the AES cipher handle to encrypt one block.”h]”hŒdThe SKCIPHER of CTR(AES) now invokes the CIPHER API with the AES cipher handle to encrypt one block.”…””}”(hj3h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M_hj/ubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhjžh²hh³hÊh´Nubhò)”}”(hŒ\The GCM AEAD implementation also invokes the GHASH cipher implementation via the AHASH API. ”h]”hÝ)”}”(hŒ[The GCM AEAD implementation also invokes the GHASH cipher implementation via the AHASH API.”h]”hŒ[The GCM AEAD implementation also invokes the GHASH cipher implementation via the AHASH API.”…””}”(hjKh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MbhjGubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhjžh²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œenumtype”Œarabic”Œprefix”hŒsuffix”Œ.”uh1jœhj h²hh³hÊh´MBubhÝ)”}”(hŒœWhen the IPSEC layer triggers the esp_input() function, the same call sequence is followed with the only difference that the operation starts with step (2).”h]”hŒœWhen the IPSEC layer triggers the esp_input() function, the same call sequence is followed with the only difference that the operation starts with step (2).”…””}”(hjjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mehj h²hubeh}”(h]”Œgeneric-aead-cipher-structure”ah ]”h"]”Œgeneric aead cipher structure”ah$]”h&]”uh1hµhjàh²hh³hÊh´K÷ubh¶)”}”(hhh]”(h»)”}”(hŒGeneric Block Cipher Structure”h]”hŒGeneric Block Cipher Structure”…””}”(hjƒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj€h²hh³hÊh´MjubhÝ)”}”(hŒ[Generic block ciphers follow the same concept as depicted with the ASCII art picture above.”h]”hŒ[Generic block ciphers follow the same concept as depicted with the ASCII art picture above.”…””}”(hj‘h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mlhj€h²hubhÝ)”}”(hŒËFor example, CBC(AES) is implemented with cbc.c, and aes-generic.c. The ASCII art picture above applies as well with the difference that only step (4) is used and the SKCIPHER block chaining mode is CBC.”h]”hŒËFor example, CBC(AES) is implemented with cbc.c, and aes-generic.c. The ASCII art picture above applies as well with the difference that only step (4) is used and the SKCIPHER block chaining mode is CBC.”…””}”(hjŸh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mohj€h²hubeh}”(h]”Œgeneric-block-cipher-structure”ah ]”h"]”Œgeneric block cipher structure”ah$]”h&]”uh1hµhjàh²hh³hÊh´Mjubh¶)”}”(hhh]”(h»)”}”(hŒ&Generic Keyed Message Digest Structure”h]”hŒ&Generic Keyed Message Digest Structure”…””}”(hj¸h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjµh²hh³hÊh´MtubhÝ)”}”(hŒnKeyed message digest implementations again follow the same concept as depicted in the ASCII art picture above.”h]”hŒnKeyed message digest implementations again follow the same concept as depicted in the ASCII art picture above.”…””}”(hjÆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mvhjµh²hubhÝ)”}”(hŒ‚For example, HMAC(SHA256) is implemented with hmac.c and sha256_generic.c. The following ASCII art illustrates the implementation:”h]”hŒ‚For example, HMAC(SHA256) is implemented with hmac.c and sha256_generic.c. The following ASCII art illustrates the implementation:”…””}”(hjÔh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Myhjµh²hubj)”}”(hX5kernel crypto API | Caller | +-----------+ (1) | | | <------------------ some_function | ahash | | (hmac) | ---+ +-----------+ | | (2) +-----------+ | | | <--+ | shash | | (sha256) | +-----------+”h]”hX5kernel crypto API | Caller | +-----------+ (1) | | | <------------------ some_function | ahash | | (hmac) | ---+ +-----------+ | | (2) +-----------+ | | | <--+ | shash | | (sha256) | +-----------+”…””}”hjâsbah}”(h]”h ]”h"]”h$]”h&]”jjuh1jh³hÊh´M€hjµh²hubhÝ)”}”(hŒSThe following call sequence is applicable when a caller triggers an HMAC operation:”h]”hŒSThe following call sequence is applicable when a caller triggers an HMAC operation:”…””}”(hjðh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mhjµh²hubj)”}”(hhh]”(hò)”}”(hXjThe AHASH API functions are invoked by the caller. The HMAC implementation performs its operation as needed. During initialization of the HMAC cipher, the SHASH cipher type of SHA256 is instantiated. The cipher handle for the SHA256 instance is retained. At one time, the HMAC implementation requires a SHA256 operation where the SHA256 cipher handle is used. ”h]”(hÝ)”}”(hŒlThe AHASH API functions are invoked by the caller. The HMAC implementation performs its operation as needed.”h]”hŒlThe AHASH API functions are invoked by the caller. The HMAC implementation performs its operation as needed.”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M“hj ubhÝ)”}”(hŒ‘During initialization of the HMAC cipher, the SHASH cipher type of SHA256 is instantiated. The cipher handle for the SHA256 instance is retained.”h]”hŒ‘During initialization of the HMAC cipher, the SHASH cipher type of SHA256 is instantiated. The cipher handle for the SHA256 instance is retained.”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M–hj ubhÝ)”}”(hŒhAt one time, the HMAC implementation requires a SHA256 operation where the SHA256 cipher handle is used.”h]”hŒhAt one time, the HMAC implementation requires a SHA256 operation where the SHA256 cipher handle is used.”…””}”(hj! h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mšhj ubeh}”(h]”h ]”h"]”h$]”h&]”uh1hñhjþh²hh³hÊh´Nubhò)”}”(hŒjThe HMAC instance now invokes the SHASH API with the SHA256 cipher handle to calculate the message digest.”h]”hÝ)”}”(hŒjThe HMAC instance now invokes the SHASH API with the SHA256 cipher handle to calculate the message digest.”h]”hŒjThe HMAC instance now invokes the SHASH API with the SHA256 cipher handle to calculate the message digest.”…””}”(hj9 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mhj5 ubah}”(h]”h ]”h"]”h$]”h&]”uh1hñhjþh²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jejfjghjhjiuh1jœhjµh²hh³hÊh´M“ubeh}”(h]”Œ&generic-keyed-message-digest-structure”ah ]”h"]”Œ&generic keyed message digest structure”ah$]”h&]”uh1hµhjàh²hh³hÊh´Mtubeh}”(h]”Œ'internal-structure-of-kernel-crypto-api”ah ]”h"]”Œ'internal structure of kernel crypto api”ah$]”h&]”uh1hµhh·h²hh³hÊh´Këubeh}”(h]”Œkernel-crypto-api-architecture”ah ]”h"]”Œkernel crypto api architecture”ah$]”h&]”uh1hµhhh²hh³hÊh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÊuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(hºNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jŽ Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÊŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jh je jxjuj jjãjàjljij“jjÝjÚj` j] j}jzj²j¯jX jU uŒ nametypes”}”(jh ‰jx‰j ‰jã‰jl‰j“‰j݉j` ‰j}‰j²‰jX ‰uh}”(je h·juhËjj{jàj£jijæjjojÚj–j] jàjzj j¯j€jU jµuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.