]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/include/libsec.h
libc, seconds: new time and date apis (try 2)
[plan9front.git] / sys / include / libsec.h
index 2f19ce36ed02ee20c7ecf2df4389e968e6e3f625..b19d18a762944965dbbb9ebb6901a8e35da70ca1 100644 (file)
@@ -24,26 +24,27 @@ struct AESstate
        ulong   offset;
        int     rounds;
        int     keybytes;
+       void    *ekey;                          /* expanded encryption round key */
+       void    *dkey;                          /* expanded decryption round key */
        uchar   key[AESmaxkey];                 /* unexpanded key */
-       ulong   ekey[4*(AESmaxrounds + 1)];     /* encryption key */
-       ulong   dkey[4*(AESmaxrounds + 1)];     /* decryption key */
        uchar   ivec[AESbsize];                 /* initialization vector */
-       uchar   mackey[3 * AESbsize];   /* 3 XCBC mac 96 keys */
+       uchar   storage[512];                   /* storage for expanded keys */
 };
 
 /* block ciphers */
-void   aes_encrypt(ulong rk[], int Nr, uchar pt[16], uchar ct[16]);
-void   aes_decrypt(ulong rk[], int Nr, uchar ct[16], uchar pt[16]);
+extern void (*aes_encrypt)(ulong rk[], int Nr, uchar pt[16], uchar ct[16]);
+extern void (*aes_decrypt)(ulong rk[], int Nr, uchar ct[16], uchar pt[16]);
+
+void   setupAESstate(AESstate *s, uchar key[], int nkey, uchar *ivec);
 
-void   setupAESstate(AESstate *s, uchar key[], int keybytes, uchar *ivec);
 void   aesCBCencrypt(uchar *p, int len, AESstate *s);
 void   aesCBCdecrypt(uchar *p, int len, AESstate *s);
 void   aesCFBencrypt(uchar *p, int len, AESstate *s);
 void   aesCFBdecrypt(uchar *p, int len, AESstate *s);
 void   aesOFBencrypt(uchar *p, int len, AESstate *s);
 
-void   setupAESXCBCstate(AESstate *s);
-uchar* aesXCBCmac(uchar *p, int len, AESstate *s);
+void   aes_xts_encrypt(AESstate *tweak, AESstate *ecb, uvlong sectorNumber, uchar *input, uchar *output, ulong len);
+void   aes_xts_decrypt(AESstate *tweak, AESstate *ecb, uvlong sectorNumber, uchar *input, uchar *output, ulong len);
 
 typedef struct AESGCMstate AESGCMstate;
 struct AESGCMstate
@@ -229,6 +230,7 @@ enum
        SHA2_512dlen=   64,     /* SHA-512 digest length */
        MD4dlen=        16,     /* MD4 digest length */
        MD5dlen=        16,     /* MD5 digest length */
+       RIPEMD160dlen=  20,     /* RIPEMD-160 digest length */
        Poly1305dlen=   16,     /* Poly1305 digest length */
 
        Hmacblksz       = 64,   /* in bytes; from rfc2104 */
@@ -258,6 +260,7 @@ typedef struct DigestState MD4state;
 
 DigestState*   md4(uchar*, ulong, uchar*, DigestState*);
 DigestState*   md5(uchar*, ulong, uchar*, DigestState*);
+DigestState*   ripemd160(uchar *, ulong, uchar *, DigestState *);
 DigestState*   sha1(uchar*, ulong, uchar*, DigestState*);
 DigestState*   sha2_224(uchar*, ulong, uchar*, DigestState*);
 DigestState*   sha2_256(uchar*, ulong, uchar*, DigestState*);
@@ -273,11 +276,6 @@ DigestState*       hmac_sha2_224(uchar*, ulong, uchar*, ulong, uchar*, DigestState*);
 DigestState*   hmac_sha2_256(uchar*, ulong, uchar*, ulong, uchar*, DigestState*);
 DigestState*   hmac_sha2_384(uchar*, ulong, uchar*, ulong, uchar*, DigestState*);
 DigestState*   hmac_sha2_512(uchar*, ulong, uchar*, ulong, uchar*, DigestState*);
-char*          md5pickle(MD5state*);
-MD5state*      md5unpickle(char*);
-char*          sha1pickle(SHA1state*);
-SHA1state*     sha1unpickle(char*);
-
 DigestState*   poly1305(uchar*, ulong, uchar*, ulong, uchar*, DigestState*);
 
 /*
@@ -374,9 +372,11 @@ void               X509dump(uchar *cert, int ncert);
 mpint*         pkcs1padbuf(uchar *buf, int len, mpint *modulus, int blocktype);
 int            pkcs1unpadbuf(uchar *buf, int len, mpint *modulus, int blocktype);
 int            asn1encodeRSApub(RSApub *pk, uchar *buf, int len);
+int            asn1encodeRSApriv(RSApriv *k, uchar *buf, int len);
 int            asn1encodedigest(DigestState* (*fun)(uchar*, ulong, uchar*, DigestState*),
                        uchar *digest, uchar *buf, int len);
 
+int            X509digestSPKI(uchar *, int, DigestState* (*)(uchar*, ulong, uchar*, DigestState*), uchar *);
 
 /*
  * elgamal
@@ -458,7 +458,6 @@ void                dsaprivfree(DSApriv*);
 DSAsig*                dsasigalloc(void);
 void           dsasigfree(DSAsig*);
 DSApub*                dsaprivtopub(DSApriv*);
-DSApriv*       asn1toDSApriv(uchar*, int);
 
 /*
  * TLS
@@ -501,10 +500,6 @@ int        okCertificate(uchar *cert, int len, Thumbprint *ok);
 uchar  *readcert(char *filename, int *pcertlen);
 PEMChain*readcertchain(char *filename);
 
-/* aes_xts.c */
-int aes_xts_encrypt(ulong tweak[], ulong ecb[], uvlong sectorNumber, uchar *input, uchar *output, ulong len) ;
-int aes_xts_decrypt(ulong tweak[], ulong ecb[], uvlong sectorNumber, uchar *input, uchar *output, ulong len);
-
 typedef struct ECpoint{
        int inf;
        mpint *x;
@@ -555,8 +550,6 @@ void        secp256r1(mpint *p, mpint *a, mpint *b, mpint *x, mpint *y, mpint *n, mpint
 void   secp256k1(mpint *p, mpint *a, mpint *b, mpint *x, mpint *y, mpint *n, mpint *h);
 void   secp384r1(mpint *p, mpint *a, mpint *b, mpint *x, mpint *y, mpint *n, mpint *h);
 
-DigestState*   ripemd160(uchar *, ulong, uchar *, DigestState *);
-
 /*
  * Diffie-Hellman key exchange
  */