mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Added a sample that fixes comment two on issue #1264.
This commit is contained in:
		| @@ -560,8 +560,8 @@ | |||||||
|       ".gitconfig" |       ".gitconfig" | ||||||
|     ] |     ] | ||||||
|   }, |   }, | ||||||
|   "tokens_total": 454570, |   "tokens_total": 454619, | ||||||
|   "languages_total": 557, |   "languages_total": 558, | ||||||
|   "tokens": { |   "tokens": { | ||||||
|     "IDL": { |     "IDL": { | ||||||
|       ";": 59, |       ";": 59, | ||||||
| @@ -41660,30 +41660,30 @@ | |||||||
|       "After": 1 |       "After": 1 | ||||||
|     }, |     }, | ||||||
|     "C": { |     "C": { | ||||||
|       "#include": 154, |       "#include": 159, | ||||||
|       "<assert.h>": 5, |       "<assert.h>": 5, | ||||||
|       "<stddef.h>": 2, |       "<stddef.h>": 2, | ||||||
|       "<ctype.h>": 3, |       "<ctype.h>": 3, | ||||||
|       "<stdlib.h>": 3, |       "<stdlib.h>": 3, | ||||||
|       "<string.h>": 5, |       "<string.h>": 5, | ||||||
|       "<limits.h>": 2, |       "<limits.h>": 2, | ||||||
|       "#ifndef": 89, |       "#ifndef": 90, | ||||||
|       "ULLONG_MAX": 10, |       "ULLONG_MAX": 10, | ||||||
|       "#endif": 245, |       "#endif": 246, | ||||||
|       "MIN": 3, |       "MIN": 3, | ||||||
|       "#if": 92, |       "#if": 92, | ||||||
|       "HTTP_PARSER_DEBUG": 4, |       "HTTP_PARSER_DEBUG": 4, | ||||||
|       "#define": 920, |       "#define": 921, | ||||||
|       "SET_ERRNO": 47, |       "SET_ERRNO": 47, | ||||||
|       "(": 6247, |       "(": 6249, | ||||||
|       "e": 4, |       "e": 4, | ||||||
|       ")": 6249, |       ")": 6251, | ||||||
|       "do": 21, |       "do": 21, | ||||||
|       "{": 1532, |       "{": 1532, | ||||||
|       "parser": 334, |       "parser": 334, | ||||||
|       "-": 1803, |       "-": 1803, | ||||||
|       "http_errno": 11, |       "http_errno": 11, | ||||||
|       ";": 5466, |       ";": 5468, | ||||||
|       "error_lineno": 3, |       "error_lineno": 3, | ||||||
|       "__LINE__": 50, |       "__LINE__": 50, | ||||||
|       "}": 1548, |       "}": 1548, | ||||||
| @@ -41721,7 +41721,7 @@ | |||||||
|       "KEEP_ALIVE": 4, |       "KEEP_ALIVE": 4, | ||||||
|       "CLOSE": 4, |       "CLOSE": 4, | ||||||
|       "static": 457, |       "static": 457, | ||||||
|       "const": 360, |       "const": 368, | ||||||
|       "char": 530, |       "char": 530, | ||||||
|       "*method_strings": 1, |       "*method_strings": 1, | ||||||
|       "[": 603, |       "[": 603, | ||||||
| @@ -41729,7 +41729,7 @@ | |||||||
|       "XX": 63, |       "XX": 63, | ||||||
|       "num": 24, |       "num": 24, | ||||||
|       "name": 28, |       "name": 28, | ||||||
|       "string": 18, |       "string": 20, | ||||||
|       "#string": 1, |       "#string": 1, | ||||||
|       "HTTP_METHOD_MAP": 3, |       "HTTP_METHOD_MAP": 3, | ||||||
|       "#undef": 7, |       "#undef": 7, | ||||||
| @@ -41919,7 +41919,7 @@ | |||||||
|       "<": 219, |       "<": 219, | ||||||
|       "HPE_INVALID_VERSION": 12, |       "HPE_INVALID_VERSION": 12, | ||||||
|       "http_major": 11, |       "http_major": 11, | ||||||
|       "*": 261, |       "*": 262, | ||||||
|       "http_minor": 11, |       "http_minor": 11, | ||||||
|       "HPE_INVALID_STATUS": 3, |       "HPE_INVALID_STATUS": 3, | ||||||
|       "status_code": 8, |       "status_code": 8, | ||||||
| @@ -41998,7 +41998,7 @@ | |||||||
|       "http_should_keep_alive": 2, |       "http_should_keep_alive": 2, | ||||||
|       "http_method_str": 1, |       "http_method_str": 1, | ||||||
|       "m": 8, |       "m": 8, | ||||||
|       "void": 288, |       "void": 289, | ||||||
|       "http_parser_init": 2, |       "http_parser_init": 2, | ||||||
|       "http_parser_type": 3, |       "http_parser_type": 3, | ||||||
|       "memset": 4, |       "memset": 4, | ||||||
| @@ -42395,7 +42395,7 @@ | |||||||
|       "i_rfString_Before": 5, |       "i_rfString_Before": 5, | ||||||
|       "i_rfString_After": 5, |       "i_rfString_After": 5, | ||||||
|       "afterP": 2, |       "afterP": 2, | ||||||
|       "out": 18, |       "out": 19, | ||||||
|       "after": 6, |       "after": 6, | ||||||
|       "rfString_Afterv": 4, |       "rfString_Afterv": 4, | ||||||
|       "i_rfString_Afterv": 16, |       "i_rfString_Afterv": 16, | ||||||
| @@ -44221,7 +44221,7 @@ | |||||||
|       "bitcountCommand": 1, |       "bitcountCommand": 1, | ||||||
|       "redisLogRaw": 3, |       "redisLogRaw": 3, | ||||||
|       "level": 12, |       "level": 12, | ||||||
|       "*msg": 7, |       "*msg": 8, | ||||||
|       "syslogLevelMap": 2, |       "syslogLevelMap": 2, | ||||||
|       "LOG_DEBUG": 1, |       "LOG_DEBUG": 1, | ||||||
|       "LOG_INFO": 1, |       "LOG_INFO": 1, | ||||||
| @@ -46822,6 +46822,17 @@ | |||||||
|       "jfloat": 1, |       "jfloat": 1, | ||||||
|       "Java_jni_JniLayer_jni_1layer_1report_1analog_1chg": 1, |       "Java_jni_JniLayer_jni_1layer_1report_1analog_1chg": 1, | ||||||
|       "Java_jni_JniLayer_jni_1layer_1kill": 1, |       "Java_jni_JniLayer_jni_1layer_1kill": 1, | ||||||
|  |       "PQC_ENCRYPT_H": 2, | ||||||
|  |       "<fmpz_poly.h>": 1, | ||||||
|  |       "<fmpz.h>": 1, | ||||||
|  |       "ntru_encrypt_poly": 1, | ||||||
|  |       "fmpz_poly_t": 6, | ||||||
|  |       "msg_tern": 1, | ||||||
|  |       "pub_key": 2, | ||||||
|  |       "rnd": 2, | ||||||
|  |       "ntru_params": 2, | ||||||
|  |       "*params": 2, | ||||||
|  |       "ntru_encrypt_string": 1, | ||||||
|       "BOOTSTRAP_H": 2, |       "BOOTSTRAP_H": 2, | ||||||
|       "*true": 1, |       "*true": 1, | ||||||
|       "*false": 1, |       "*false": 1, | ||||||
| @@ -49253,7 +49264,7 @@ | |||||||
|     "AsciiDoc": 103, |     "AsciiDoc": 103, | ||||||
|     "Protocol Buffer": 63, |     "Protocol Buffer": 63, | ||||||
|     "Common Lisp": 103, |     "Common Lisp": 103, | ||||||
|     "C": 59088, |     "C": 59137, | ||||||
|     "XQuery": 801, |     "XQuery": 801, | ||||||
|     "RobotFramework": 483, |     "RobotFramework": 483, | ||||||
|     "Gosu": 410, |     "Gosu": 410, | ||||||
| @@ -49400,7 +49411,7 @@ | |||||||
|     "AsciiDoc": 3, |     "AsciiDoc": 3, | ||||||
|     "Protocol Buffer": 1, |     "Protocol Buffer": 1, | ||||||
|     "Common Lisp": 1, |     "Common Lisp": 1, | ||||||
|     "C": 30, |     "C": 31, | ||||||
|     "XQuery": 1, |     "XQuery": 1, | ||||||
|     "RobotFramework": 3, |     "RobotFramework": 3, | ||||||
|     "Gosu": 4, |     "Gosu": 4, | ||||||
| @@ -49412,5 +49423,5 @@ | |||||||
|     "GLSL": 3, |     "GLSL": 3, | ||||||
|     "Xtend": 2 |     "Xtend": 2 | ||||||
|   }, |   }, | ||||||
|   "md5": "43be9202f3e299ffea3af7298cc39aaa" |   "md5": "5b3ac3847ff456b82cf95a19d03449a4" | ||||||
| } | } | ||||||
							
								
								
									
										89
									
								
								samples/C/ntru_encrypt.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								samples/C/ntru_encrypt.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,89 @@ | |||||||
|  | /* | ||||||
|  |  * Copyright (C) 2014 FH Bielefeld | ||||||
|  |  * | ||||||
|  |  * This file is part of a FH Bielefeld project. | ||||||
|  |  * | ||||||
|  |  * This library is free software; you can redistribute it and/or | ||||||
|  |  * modify it under the terms of the GNU Lesser General Public | ||||||
|  |  * License as published by the Free Software Foundation; either | ||||||
|  |  * version 2.1 of the License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * This library is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||||
|  |  * Lesser General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Lesser General Public | ||||||
|  |  * License along with this library; if not, write to the Free Software | ||||||
|  |  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||||||
|  |  * MA  02110-1301  USA | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * @file ntru_encrypt.h | ||||||
|  |  * Header for the internal API of ntru_encrypt.c. | ||||||
|  |  * @brief header for encrypt.c | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | #ifndef PQC_ENCRYPT_H | ||||||
|  | #define PQC_ENCRYPT_H | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #include "ntru_params.h" | ||||||
|  | #include "ntru_poly.h" | ||||||
|  | #include "ntru_string.h" | ||||||
|  |  | ||||||
|  | #include <fmpz_poly.h> | ||||||
|  | #include <fmpz.h> | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * encrypt the msg, using the math: | ||||||
|  |  * e = (h ∗ r) + m (mod q) | ||||||
|  |  * | ||||||
|  |  * e = the encrypted poly | ||||||
|  |  * | ||||||
|  |  * h = the public key | ||||||
|  |  * | ||||||
|  |  * r = the random poly | ||||||
|  |  * | ||||||
|  |  * m = the message poly | ||||||
|  |  * | ||||||
|  |  * q = large mod | ||||||
|  |  * | ||||||
|  |  * @param msg_tern the message to encrypt, in ternary format | ||||||
|  |  * @param pub_key the public key | ||||||
|  |  * @param rnd the random poly (should have relatively small | ||||||
|  |  * coefficients, but not restricted to {-1, 0, 1}) | ||||||
|  |  * @param out the output poly which is in the range {0, q-1} | ||||||
|  |  * (not ternary!) [out] | ||||||
|  |  * @param params ntru_params the ntru context | ||||||
|  |  */ | ||||||
|  | void | ||||||
|  | ntru_encrypt_poly( | ||||||
|  | 		const fmpz_poly_t msg_tern, | ||||||
|  | 		const fmpz_poly_t pub_key, | ||||||
|  | 		const fmpz_poly_t rnd, | ||||||
|  | 		fmpz_poly_t out, | ||||||
|  | 		const ntru_params *params); | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Encrypt a message in the form of a null-terminated char array and | ||||||
|  |  * return a string. | ||||||
|  |  * | ||||||
|  |  * @param msg the message | ||||||
|  |  * @param pub_key the public key | ||||||
|  |  * @param rnd the random poly (should have relatively small | ||||||
|  |  * coefficients, but not restricted to {-1, 0, 1}) | ||||||
|  |  * @param params ntru_params the ntru context | ||||||
|  |  * @return the newly allocated encrypted string | ||||||
|  |  */ | ||||||
|  | string * | ||||||
|  | ntru_encrypt_string( | ||||||
|  | 		const string *msg, | ||||||
|  | 		const fmpz_poly_t pub_key, | ||||||
|  | 		const fmpz_poly_t rnd, | ||||||
|  | 		const ntru_params *params); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #endif /* PQC_ENCRYPT_H */ | ||||||
		Reference in New Issue
	
	Block a user