include/mpin192.h.in [36:199]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "pbc_support.h" /* Field size is assumed to be greater than or equal to group size */ #define PGS_ZZZ MODBYTES_XXX /**< MPIN Group Size */ #define PFS_ZZZ MODBYTES_XXX /**< MPIN Field Size */ #define MPIN_OK 0 /**< Function completed without error */ #define MPIN_INVALID_POINT -14 /**< Point is NOT on the curve */ #define MPIN_BAD_PIN -19 /**< Bad PIN number entered */ #define MAXPIN 10000 /**< max PIN */ #define PBLEN 14 /**< max length of PIN in bits */ //#define PAS_ZZZ 24 /**< MPIN Symmetric Key Size 192 bits */ //#define HASH_TYPE_MPIN_ZZZ SHA384 /**< Choose Hash function */ #define MESSAGE_SIZE 256 /**< Signature message size */ #define M_SIZE_ZZZ (MESSAGE_SIZE+2*PFS_ZZZ+1) /**< Signature message size and G1 size */ /* MPIN support functions */ /* MPIN primitives */ /** @brief Generate Y=H(s,O), where s is epoch time, O is an octet, and H(.) is a hash function * @param h is the hash type @param t is epoch time in seconds @param O is an input octet @param Y is the output octet */ void MPIN_ZZZ_GET_Y(int h,int t,octet *O,octet *Y); /** @brief Extract a PIN number from a client secret * @param h is the hash type @param ID is the input client identity @param factor is an input factor @param facbits is the number of bits in the factor @param CS is the client secret from which the factor is to be extracted @return 0 or an error code */ int MPIN_ZZZ_EXTRACT_FACTOR(int h,octet *ID,int factor,int facbits,octet *CS); /** @brief Extract a PIN number from a client secret * @param h is the hash type @param ID is the input client identity @param factor is an input factor @param facbits is the number of bits in the factor @param CS is the client secret to which the factor is to be added @return 0 or an error code */ int MPIN_ZZZ_RESTORE_FACTOR(int h,octet *ID,int factor,int facbits,octet *CS); /** @brief Extract a PIN number from a client secret * @param h is the hash type @param ID is the input client identity @param pin is an input PIN number @param CS is the client secret from which the PIN is to be extracted @return 0 or an error code */ int MPIN_ZZZ_EXTRACT_PIN(int h,octet *ID,int pin,octet *CS); /** @brief Perform client side of the one-pass version of the M-Pin protocol * If Time Permits are disabled, set d = 0, and UT is not generated and can be set to NULL. If Time Permits are enabled, and PIN error detection is OFF, U is not generated and can be set to NULL. If Time Permits are enabled, and PIN error detection is ON, U and UT are both generated. @param h is the hash type @param d is input date, in days since the epoch. Set to 0 if Time permits disabled @param ID is the input client identity @param R is a pointer to a cryptographically secure random number generator @param x an output internally randomly generated if R!=NULL, otherwise must be provided as an input @param pin is the input PIN number @param T is the input M-Pin token (the client secret with PIN portion removed) @param V is output = -(x+y)(CS+TP), where CS is the reconstructed client secret, and TP is the time permit @param U is output = x.H(ID) @param UT is output = x.(H(ID)+H(d|H(ID))) @param TP is the input time permit @param MESSAGE is the message to be signed @param t is input epoch time in seconds - a timestamp @param y is output H(t|U) or H(t|UT) if Time Permits enabled @return 0 or an error code */ int MPIN_ZZZ_CLIENT(int h,int d,octet *ID,csprng *R,octet *x,int pin,octet *T,octet *V,octet *U,octet *UT,octet *TP, octet* MESSAGE, int t, octet *y); /** @brief Perform first pass of the client side of the 3-pass version of the M-Pin protocol * If Time Permits are disabled, set d = 0, and UT is not generated and can be set to NULL. If Time Permits are enabled, and PIN error detection is OFF, U is not generated and can be set to NULL. If Time Permits are enabled, and PIN error detection is ON, U and UT are both generated. @param h is the hash type @param d is input date, in days since the epoch. Set to 0 if Time permits disabled @param ID is the input client identity @param R is a pointer to a cryptographically secure random number generator @param x an output internally randomly generated if R!=NULL, otherwise must be provided as an input @param pin is the input PIN number @param T is the input M-Pin token (the client secret with PIN portion removed) @param S is output = CS+TP, where CS=is the reconstructed client secret, and TP is the time permit @param U is output = x.H(ID) @param UT is output = x.(H(ID)+H(d|H(ID))) @param TP is the input time permit @return 0 or an error code */ int MPIN_ZZZ_CLIENT_1(int h,int d,octet *ID,csprng *R,octet *x,int pin,octet *T,octet *S,octet *U,octet *UT,octet *TP); /** @brief Generate a random group element * @param R is a pointer to a cryptographically secure random number generator @param S is the output random octet @return 0 or an error code */ int MPIN_ZZZ_RANDOM_GENERATE(csprng *R,octet *S); /** @brief Perform second pass of the client side of the 3-pass version of the M-Pin protocol * @param x an input, a locally generated random number @param y an input random challenge from the server @param V on output = -(x+y).V @return 0 or an error code */ int MPIN_ZZZ_CLIENT_2(octet *x,octet *y,octet *V); /** @brief Perform server side of the one-pass version of the M-Pin protocol * If Time Permits are disabled, set d = 0, and UT and HTID are not generated and can be set to NULL. If Time Permits are enabled, and PIN error detection is OFF, U and HID are not needed and can be set to NULL. If Time Permits are enabled, and PIN error detection is ON, U, UT, HID and HTID are all required. @param h is the hash type @param d is input date, in days since the epoch. Set to 0 if Time permits disabled @param HID is output H(ID), a hash of the client ID @param HTID is output H(ID)+H(d|H(ID)) @param y is output H(t|U) or H(t|UT) if Time Permits enabled @param SS is the input server secret @param U is input from the client = x.H(ID) @param UT is input from the client= x.(H(ID)+H(d|H(ID))) @param V is an input from the client @param E is an output to help the Kangaroos to find the PIN error, or NULL if not required @param F is an output to help the Kangaroos to find the PIN error, or NULL if not required @param ID is the input claimed client identity @param MESSAGE is the message to be signed @param t is input epoch time in seconds - a timestamp @param Pa is input from the client z.Q or NULL if the key-escrow less scheme is not used @return 0 or an error code */ int MPIN_ZZZ_SERVER(int h,int d,octet *HID,octet *HTID,octet *y,octet *SS,octet *U,octet *UT,octet *V,octet *E,octet *F,octet *ID,octet *MESSAGE, int t, octet *Pa); /** @brief Perform first pass of the server side of the 3-pass version of the M-Pin protocol * @param h is the hash type @param d is input date, in days since the epoch. Set to 0 if Time permits disabled @param ID is the input claimed client identity @param HID is output H(ID), a hash of the client ID @param HTID is output H(ID)+H(d|H(ID)) @return 0 or an error code */ void MPIN_ZZZ_SERVER_1(int h,int d,octet *ID,octet *HID,octet *HTID); /** @brief Perform third pass on the server side of the 3-pass version of the M-Pin protocol * If Time Permits are disabled, set d = 0, and UT and HTID are not needed and can be set to NULL. If Time Permits are enabled, and PIN error detection is OFF, U and HID are not needed and can be set to NULL. If Time Permits are enabled, and PIN error detection is ON, U, UT, HID and HTID are all required. @param d is input date, in days since the epoch. Set to 0 if Time permits disabled @param HID is input H(ID), a hash of the client ID @param HTID is input H(ID)+H(d|H(ID)) @param y is the input server's randomly generated challenge - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - include/mpin256.h.in [36:199]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "pbc_support.h" /* Field size is assumed to be greater than or equal to group size */ #define PGS_ZZZ MODBYTES_XXX /**< MPIN Group Size */ #define PFS_ZZZ MODBYTES_XXX /**< MPIN Field Size */ #define MPIN_OK 0 /**< Function completed without error */ #define MPIN_INVALID_POINT -14 /**< Point is NOT on the curve */ #define MPIN_BAD_PIN -19 /**< Bad PIN number entered */ #define MAXPIN 10000 /**< max PIN */ #define PBLEN 14 /**< max length of PIN in bits */ //#define PAS_ZZZ 24 /**< MPIN Symmetric Key Size 192 bits */ //#define HASH_TYPE_MPIN_ZZZ SHA384 /**< Choose Hash function */ #define MESSAGE_SIZE 256 /**< Signature message size */ #define M_SIZE_ZZZ (MESSAGE_SIZE+2*PFS_ZZZ+1) /**< Signature message size and G1 size */ /* MPIN support functions */ /* MPIN primitives */ /** @brief Generate Y=H(s,O), where s is epoch time, O is an octet, and H(.) is a hash function * @param h is the hash type @param t is epoch time in seconds @param O is an input octet @param Y is the output octet */ void MPIN_ZZZ_GET_Y(int h,int t,octet *O,octet *Y); /** @brief Extract a PIN number from a client secret * @param h is the hash type @param ID is the input client identity @param factor is an input factor @param facbits is the number of bits in the factor @param CS is the client secret from which the factor is to be extracted @return 0 or an error code */ int MPIN_ZZZ_EXTRACT_FACTOR(int h,octet *ID,int factor,int facbits,octet *CS); /** @brief Extract a PIN number from a client secret * @param h is the hash type @param ID is the input client identity @param factor is an input factor @param facbits is the number of bits in the factor @param CS is the client secret to which the factor is to be added @return 0 or an error code */ int MPIN_ZZZ_RESTORE_FACTOR(int h,octet *ID,int factor,int facbits,octet *CS); /** @brief Extract a PIN number from a client secret * @param h is the hash type @param ID is the input client identity @param pin is an input PIN number @param CS is the client secret from which the PIN is to be extracted @return 0 or an error code */ int MPIN_ZZZ_EXTRACT_PIN(int h,octet *ID,int pin,octet *CS); /** @brief Perform client side of the one-pass version of the M-Pin protocol * If Time Permits are disabled, set d = 0, and UT is not generated and can be set to NULL. If Time Permits are enabled, and PIN error detection is OFF, U is not generated and can be set to NULL. If Time Permits are enabled, and PIN error detection is ON, U and UT are both generated. @param h is the hash type @param d is input date, in days since the epoch. Set to 0 if Time permits disabled @param ID is the input client identity @param R is a pointer to a cryptographically secure random number generator @param x an output internally randomly generated if R!=NULL, otherwise must be provided as an input @param pin is the input PIN number @param T is the input M-Pin token (the client secret with PIN portion removed) @param V is output = -(x+y)(CS+TP), where CS is the reconstructed client secret, and TP is the time permit @param U is output = x.H(ID) @param UT is output = x.(H(ID)+H(d|H(ID))) @param TP is the input time permit @param MESSAGE is the message to be signed @param t is input epoch time in seconds - a timestamp @param y is output H(t|U) or H(t|UT) if Time Permits enabled @return 0 or an error code */ int MPIN_ZZZ_CLIENT(int h,int d,octet *ID,csprng *R,octet *x,int pin,octet *T,octet *V,octet *U,octet *UT,octet *TP, octet* MESSAGE, int t, octet *y); /** @brief Perform first pass of the client side of the 3-pass version of the M-Pin protocol * If Time Permits are disabled, set d = 0, and UT is not generated and can be set to NULL. If Time Permits are enabled, and PIN error detection is OFF, U is not generated and can be set to NULL. If Time Permits are enabled, and PIN error detection is ON, U and UT are both generated. @param h is the hash type @param d is input date, in days since the epoch. Set to 0 if Time permits disabled @param ID is the input client identity @param R is a pointer to a cryptographically secure random number generator @param x an output internally randomly generated if R!=NULL, otherwise must be provided as an input @param pin is the input PIN number @param T is the input M-Pin token (the client secret with PIN portion removed) @param S is output = CS+TP, where CS=is the reconstructed client secret, and TP is the time permit @param U is output = x.H(ID) @param UT is output = x.(H(ID)+H(d|H(ID))) @param TP is the input time permit @return 0 or an error code */ int MPIN_ZZZ_CLIENT_1(int h,int d,octet *ID,csprng *R,octet *x,int pin,octet *T,octet *S,octet *U,octet *UT,octet *TP); /** @brief Generate a random group element * @param R is a pointer to a cryptographically secure random number generator @param S is the output random octet @return 0 or an error code */ int MPIN_ZZZ_RANDOM_GENERATE(csprng *R,octet *S); /** @brief Perform second pass of the client side of the 3-pass version of the M-Pin protocol * @param x an input, a locally generated random number @param y an input random challenge from the server @param V on output = -(x+y).V @return 0 or an error code */ int MPIN_ZZZ_CLIENT_2(octet *x,octet *y,octet *V); /** @brief Perform server side of the one-pass version of the M-Pin protocol * If Time Permits are disabled, set d = 0, and UT and HTID are not generated and can be set to NULL. If Time Permits are enabled, and PIN error detection is OFF, U and HID are not needed and can be set to NULL. If Time Permits are enabled, and PIN error detection is ON, U, UT, HID and HTID are all required. @param h is the hash type @param d is input date, in days since the epoch. Set to 0 if Time permits disabled @param HID is output H(ID), a hash of the client ID @param HTID is output H(ID)+H(d|H(ID)) @param y is output H(t|U) or H(t|UT) if Time Permits enabled @param SS is the input server secret @param U is input from the client = x.H(ID) @param UT is input from the client= x.(H(ID)+H(d|H(ID))) @param V is an input from the client @param E is an output to help the Kangaroos to find the PIN error, or NULL if not required @param F is an output to help the Kangaroos to find the PIN error, or NULL if not required @param ID is the input claimed client identity @param MESSAGE is the message to be signed @param t is input epoch time in seconds - a timestamp @param Pa is input from the client z.Q or NULL if the key-escrow less scheme is not used @return 0 or an error code */ int MPIN_ZZZ_SERVER(int h,int d,octet *HID,octet *HTID,octet *y,octet *SS,octet *U,octet *UT,octet *V,octet *E,octet *F,octet *ID,octet *MESSAGE, int t, octet *Pa); /** @brief Perform first pass of the server side of the 3-pass version of the M-Pin protocol * @param h is the hash type @param d is input date, in days since the epoch. Set to 0 if Time permits disabled @param ID is the input claimed client identity @param HID is output H(ID), a hash of the client ID @param HTID is output H(ID)+H(d|H(ID)) @return 0 or an error code */ void MPIN_ZZZ_SERVER_1(int h,int d,octet *ID,octet *HID,octet *HTID); /** @brief Perform third pass on the server side of the 3-pass version of the M-Pin protocol * If Time Permits are disabled, set d = 0, and UT and HTID are not needed and can be set to NULL. If Time Permits are enabled, and PIN error detection is OFF, U and HID are not needed and can be set to NULL. If Time Permits are enabled, and PIN error detection is ON, U, UT, HID and HTID are all required. @param d is input date, in days since the epoch. Set to 0 if Time permits disabled @param HID is input H(ID), a hash of the client ID @param HTID is input H(ID)+H(d|H(ID)) @param y is the input server's randomly generated challenge - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -