403Webshell
Server IP : 195.114.193.97  /  Your IP : 216.73.217.93
Web Server : LiteSpeed
System : Linux host 5.15.0-126-generic #136-Ubuntu SMP Wed Nov 6 10:38:22 UTC 2024 x86_64
User : sembi4241 ( 1126)
PHP Version : 8.1.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/doc/nettle-dev/examples/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/doc/nettle-dev/examples/rsa-session.h
/* Session key definitions for the rsa-encrypt and rsa-decrypt programs.
 */

#ifndef NETTLE_EXAMPLES_RSA_SESSION_H_INCLUDED
#define NETTLE_EXAMPLES_RSA_SESSION_H_INCLUDED

#include "aes.h"
#include "cbc.h"
#include "hmac.h"

#define RSA_VERSION 1

/* Encryption program using the following file format:

     uint32_t version = 1;
     uint32_t nsize;
     uint8_t x[nsize];
     uint8_t encrypted[n];
     uint8_t hmac[SHA1_DIGEST_SIZE];

   where x is the data

     uint32_t version = 1;
     uint8_t aes_key[AES_KEY_SIZE];
     uint8_t iv[AES_BLOCK_SIZE];
     uint8_t hmac_key[SHA1_DIGEST_SIZE];

   of size (4 + AES256_KEY_SIZE + AES_BLOCK_SIZE + SHA1_DIGEST_SIZE) = 72
   bytes, encrypted using rsa-pkcs1.

   The cleartext input is encrypted using aes256-cbc. The final block is
   padded as

     | data | random octets | padding length |

   where the last octet is the padding length, a number between 1 and
   AES_BLOCK_SIZE (inclusive).
*/

struct rsa_session
{
  struct CBC_CTX(struct aes256_ctx, AES_BLOCK_SIZE) aes;
  struct hmac_sha1_ctx hmac;
  struct yarrow256_ctx yarrow;
};

struct rsa_session_info
{
  /* Version followed by aes key, iv and mac key */
  uint8_t key[4 + AES256_KEY_SIZE + AES_BLOCK_SIZE + SHA1_DIGEST_SIZE];
};

#define SESSION_VERSION(s) ((s)->key)
#define SESSION_AES_KEY(s) ((s)->key + 4)
#define SESSION_IV(s) ((s)->key + 4 + AES256_KEY_SIZE)
#define SESSION_HMAC_KEY(s) ((s)->key + 4 + AES256_KEY_SIZE + AES_BLOCK_SIZE)

void
rsa_session_set_encrypt_key(struct rsa_session *ctx,
			    const struct rsa_session_info *key);

void
rsa_session_set_decrypt_key(struct rsa_session *ctx,
			    const struct rsa_session_info *key);

#endif /* NETTLE_EXAMPLES_RSA_SESSION_H_INCLUDED */

Youez - 2016 - github.com/yon3zu
LinuXploit