Compare commits
	
		
			1114 Commits
		
	
	
		
			OpenSSL-fi
			...
			BEN_FIPS_T
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					fdf12fd455 | ||
| 
						 | 
					50c71f8701 | ||
| 
						 | 
					f25b0dddbb | ||
| 
						 | 
					871743aea9 | ||
| 
						 | 
					2821a5e587 | ||
| 
						 | 
					739320b840 | ||
| 
						 | 
					c9ee3ccd45 | ||
| 
						 | 
					95a64aa4b8 | ||
| 
						 | 
					80be2f484f | ||
| 
						 | 
					cf54f06dcb | ||
| 
						 | 
					5389c2dfa1 | ||
| 
						 | 
					4e2307ebdc | ||
| 
						 | 
					64961dc3c5 | ||
| 
						 | 
					ed2e0e3988 | ||
| 
						 | 
					7027553741 | ||
| 
						 | 
					445aa1c44a | ||
| 
						 | 
					2343078660 | ||
| 
						 | 
					2fe7c59277 | ||
| 
						 | 
					899ffab2c9 | ||
| 
						 | 
					577332db14 | ||
| 
						 | 
					3b84ce3b6f | ||
| 
						 | 
					2667b068a1 | ||
| 
						 | 
					a26be0386e | ||
| 
						 | 
					d5adc4b475 | ||
| 
						 | 
					fe2d15d814 | ||
| 
						 | 
					c45c8f3f1c | ||
| 
						 | 
					b09c9a91cb | ||
| 
						 | 
					a2fd4d03e8 | ||
| 
						 | 
					52fc641da0 | ||
| 
						 | 
					f29f610bf5 | ||
| 
						 | 
					27d63818e1 | ||
| 
						 | 
					fa68935f57 | ||
| 
						 | 
					b2f94f81e1 | ||
| 
						 | 
					ad6eec30a3 | ||
| 
						 | 
					25c578f3ca | ||
| 
						 | 
					22f083815c | ||
| 
						 | 
					c61e45fba0 | ||
| 
						 | 
					7418027279 | ||
| 
						 | 
					d3446728f9 | ||
| 
						 | 
					245dac4d17 | ||
| 
						 | 
					c377882c39 | ||
| 
						 | 
					c2cdb1a877 | ||
| 
						 | 
					31b28f95be | ||
| 
						 | 
					f61bc950c1 | ||
| 
						 | 
					64a014a6d2 | ||
| 
						 | 
					a86eff4296 | ||
| 
						 | 
					4c4ef336a9 | ||
| 
						 | 
					1ce9c76f8e | ||
| 
						 | 
					19c8d4a5f8 | ||
| 
						 | 
					e7d580a924 | ||
| 
						 | 
					1f8e046af9 | ||
| 
						 | 
					7e1ef2d62a | ||
| 
						 | 
					ccf61c87fe | ||
| 
						 | 
					6d02c53762 | ||
| 
						 | 
					dac0d334ad | ||
| 
						 | 
					f63ff4a1a3 | ||
| 
						 | 
					9ef37a8dc9 | ||
| 
						 | 
					fbb40083c1 | ||
| 
						 | 
					549d89f7ed | ||
| 
						 | 
					5db9e7bec8 | ||
| 
						 | 
					104f570c73 | ||
| 
						 | 
					e1015c1fe7 | ||
| 
						 | 
					97e62d5554 | ||
| 
						 | 
					9aca5b2259 | ||
| 
						 | 
					b8b47f67d0 | ||
| 
						 | 
					b5da126b21 | ||
| 
						 | 
					a7d64957b9 | ||
| 
						 | 
					f743ef233a | ||
| 
						 | 
					79176d6053 | ||
| 
						 | 
					e726e5f170 | ||
| 
						 | 
					c1a32376db | ||
| 
						 | 
					6b211d8cd2 | ||
| 
						 | 
					f3bda010df | ||
| 
						 | 
					4ccac96346 | ||
| 
						 | 
					4ef3352608 | ||
| 
						 | 
					1f1bd3a51a | ||
| 
						 | 
					b2293a6cc6 | ||
| 
						 | 
					766332ac11 | ||
| 
						 | 
					51f7c5a6ea | ||
| 
						 | 
					fc0376e257 | ||
| 
						 | 
					51c568b309 | ||
| 
						 | 
					2b3784c235 | ||
| 
						 | 
					2e9f3c4636 | ||
| 
						 | 
					aac3861773 | ||
| 
						 | 
					e0162fa745 | ||
| 
						 | 
					a8e3195083 | ||
| 
						 | 
					4435349cc6 | ||
| 
						 | 
					ec47bb7c81 | ||
| 
						 | 
					bf50d5b4ac | ||
| 
						 | 
					94a1183fab | ||
| 
						 | 
					30e4269241 | ||
| 
						 | 
					59315df637 | ||
| 
						 | 
					3659df7d15 | ||
| 
						 | 
					16f1fdbc8b | ||
| 
						 | 
					98c1a4900c | ||
| 
						 | 
					2541f58309 | ||
| 
						 | 
					6b063f32d9 | ||
| 
						 | 
					693f2e3625 | ||
| 
						 | 
					afab06d3f5 | ||
| 
						 | 
					8fb97c9acd | ||
| 
						 | 
					7312a38d9e | ||
| 
						 | 
					475e8d3d1d | ||
| 
						 | 
					c5f070d5d5 | ||
| 
						 | 
					1b9e855744 | ||
| 
						 | 
					f3b2ea53e2 | ||
| 
						 | 
					ed71769948 | ||
| 
						 | 
					e1c0a9c416 | ||
| 
						 | 
					0b8c5413a4 | ||
| 
						 | 
					c473d53898 | ||
| 
						 | 
					e8f8249319 | ||
| 
						 | 
					e2ced802b4 | ||
| 
						 | 
					9163658aa8 | ||
| 
						 | 
					d3a15e132d | ||
| 
						 | 
					47954f114c | ||
| 
						 | 
					3ef747c8b6 | ||
| 
						 | 
					75622f1ece | ||
| 
						 | 
					a052dd6532 | ||
| 
						 | 
					5cc2658cff | ||
| 
						 | 
					2f4335ec2b | ||
| 
						 | 
					2ab0740785 | ||
| 
						 | 
					82f676c633 | ||
| 
						 | 
					5f24adda77 | ||
| 
						 | 
					900f062d1f | ||
| 
						 | 
					ba64c2cc8f | ||
| 
						 | 
					29e62e487f | ||
| 
						 | 
					ec28f9c12c | ||
| 
						 | 
					4e6480faf8 | ||
| 
						 | 
					00dc2d7551 | ||
| 
						 | 
					27346c53b1 | ||
| 
						 | 
					e2491c45ab | ||
| 
						 | 
					398cd7276f | ||
| 
						 | 
					873ddf7c0c | ||
| 
						 | 
					4aae637f6c | ||
| 
						 | 
					705d0f5c8d | ||
| 
						 | 
					844df66895 | ||
| 
						 | 
					0d5b4f594d | ||
| 
						 | 
					8c2786fff7 | ||
| 
						 | 
					66ce343361 | ||
| 
						 | 
					1b9f21fdc8 | ||
| 
						 | 
					f3031b106d | ||
| 
						 | 
					6e260c4093 | ||
| 
						 | 
					f19d064087 | ||
| 
						 | 
					25a1259911 | ||
| 
						 | 
					f63f51dc22 | ||
| 
						 | 
					4eebab0d22 | ||
| 
						 | 
					bc63a2ee0e | ||
| 
						 | 
					476f09712c | ||
| 
						 | 
					fe0444b17e | ||
| 
						 | 
					16c9148220 | ||
| 
						 | 
					9d92486cfb | ||
| 
						 | 
					bb41fdb5ec | ||
| 
						 | 
					3410aa1aa8 | ||
| 
						 | 
					f50b911a3f | ||
| 
						 | 
					2a948bd306 | ||
| 
						 | 
					d4e35514ba | ||
| 
						 | 
					3fd6b9f6d4 | ||
| 
						 | 
					a598524ad6 | ||
| 
						 | 
					828ce10ce7 | ||
| 
						 | 
					8939adbad9 | ||
| 
						 | 
					ff160dba54 | ||
| 
						 | 
					fb5b7317a7 | ||
| 
						 | 
					457f692eab | ||
| 
						 | 
					e077b5452f | ||
| 
						 | 
					a9cfd20da7 | ||
| 
						 | 
					22e6c2524e | ||
| 
						 | 
					6d8cbdcb53 | ||
| 
						 | 
					54a7ea6f36 | ||
| 
						 | 
					0e2f5ec2d2 | ||
| 
						 | 
					8c5e375c8e | ||
| 
						 | 
					ce8a202831 | ||
| 
						 | 
					0ece1d304d | ||
| 
						 | 
					7f0f9f1934 | ||
| 
						 | 
					8f09a154e3 | ||
| 
						 | 
					4e7566579e | ||
| 
						 | 
					fba1cfa06d | ||
| 
						 | 
					110c6f72ec | ||
| 
						 | 
					27f7d430ce | ||
| 
						 | 
					5964e95c0a | ||
| 
						 | 
					f78ae9c0f2 | ||
| 
						 | 
					e072e16e92 | ||
| 
						 | 
					7a79b5601a | ||
| 
						 | 
					74b0c41e47 | ||
| 
						 | 
					bbfbd4b270 | ||
| 
						 | 
					88ec5a637f | ||
| 
						 | 
					75fcbb43a7 | ||
| 
						 | 
					e4e049e489 | ||
| 
						 | 
					225e35bd36 | ||
| 
						 | 
					9f81f23742 | ||
| 
						 | 
					0ae4ad9e9f | ||
| 
						 | 
					a157379adc | ||
| 
						 | 
					1ed3815650 | ||
| 
						 | 
					27310553b1 | ||
| 
						 | 
					78490b9cc2 | ||
| 
						 | 
					86ccb91ddb | ||
| 
						 | 
					8e4552ed30 | ||
| 
						 | 
					bc4a5ed341 | ||
| 
						 | 
					d5157a6244 | ||
| 
						 | 
					d07e7c32c2 | ||
| 
						 | 
					8f35294c1b | ||
| 
						 | 
					2bdcfbd7a3 | ||
| 
						 | 
					46b695d850 | ||
| 
						 | 
					6076f21f5e | ||
| 
						 | 
					be34231656 | ||
| 
						 | 
					54e73364f1 | ||
| 
						 | 
					c6b220d933 | ||
| 
						 | 
					d1c5c168b5 | ||
| 
						 | 
					931756b833 | ||
| 
						 | 
					39e76bc454 | ||
| 
						 | 
					961b565690 | ||
| 
						 | 
					142cdf5ec9 | ||
| 
						 | 
					1e2b14e9ca | ||
| 
						 | 
					4fe70c7812 | ||
| 
						 | 
					21eb91c79e | ||
| 
						 | 
					9d80973ea1 | ||
| 
						 | 
					e4fb312330 | ||
| 
						 | 
					1296e72d1d | ||
| 
						 | 
					f077cf68af | ||
| 
						 | 
					a69cc10af1 | ||
| 
						 | 
					2dd060d94e | ||
| 
						 | 
					546490c00e | ||
| 
						 | 
					409a5de586 | ||
| 
						 | 
					84b1e84af1 | ||
| 
						 | 
					5250725ba5 | ||
| 
						 | 
					84d5ad6181 | ||
| 
						 | 
					96c15b8aad | ||
| 
						 | 
					4fc2bf07b5 | ||
| 
						 | 
					2007fe63f8 | ||
| 
						 | 
					ee435c0d9c | ||
| 
						 | 
					3f691235da | ||
| 
						 | 
					86a925b27e | ||
| 
						 | 
					954d8e4f79 | ||
| 
						 | 
					b575dff21a | ||
| 
						 | 
					b35ca7b257 | ||
| 
						 | 
					0102bb94cb | ||
| 
						 | 
					57bc7769b7 | ||
| 
						 | 
					0461b8c90b | ||
| 
						 | 
					bd8e228d60 | ||
| 
						 | 
					bad99f6a9d | ||
| 
						 | 
					5600a9cba1 | ||
| 
						 | 
					607ae30be8 | ||
| 
						 | 
					37d9503a67 | ||
| 
						 | 
					a1033894d7 | ||
| 
						 | 
					0480574310 | ||
| 
						 | 
					dab0aaa612 | ||
| 
						 | 
					6fcf1dbc50 | ||
| 
						 | 
					352df99302 | ||
| 
						 | 
					a3063b37ef | ||
| 
						 | 
					cf13eaf1a1 | ||
| 
						 | 
					cc811b1d7e | ||
| 
						 | 
					a81d9af7f7 | ||
| 
						 | 
					1dc94d4dcc | ||
| 
						 | 
					5a2485ce12 | ||
| 
						 | 
					142398d3a7 | ||
| 
						 | 
					6c0118ee8e | ||
| 
						 | 
					765ca5ea06 | ||
| 
						 | 
					97333eaff7 | ||
| 
						 | 
					b088a2d3f9 | ||
| 
						 | 
					b9447ec1bc | ||
| 
						 | 
					73bec6d4b7 | ||
| 
						 | 
					e4b95737f0 | ||
| 
						 | 
					c13eba970c | ||
| 
						 | 
					4309b740ce | ||
| 
						 | 
					c0d4f622eb | ||
| 
						 | 
					a004b06237 | ||
| 
						 | 
					98eab43915 | ||
| 
						 | 
					ef03883edd | ||
| 
						 | 
					636631cdd5 | ||
| 
						 | 
					02ff8c1b66 | ||
| 
						 | 
					0b0be7a381 | ||
| 
						 | 
					83df7b20c4 | ||
| 
						 | 
					90c60eee9d | ||
| 
						 | 
					8e1e238219 | ||
| 
						 | 
					88c1fec923 | ||
| 
						 | 
					981469c80d | ||
| 
						 | 
					b5a4fd98a5 | ||
| 
						 | 
					bd573ee31a | ||
| 
						 | 
					20dc821092 | ||
| 
						 | 
					6d85cd36e2 | ||
| 
						 | 
					10ac28e26d | ||
| 
						 | 
					8f94b2010f | ||
| 
						 | 
					d48e6a47bd | ||
| 
						 | 
					40b676aa4f | ||
| 
						 | 
					7e4e392b07 | ||
| 
						 | 
					30e3c99d9f | ||
| 
						 | 
					0f618d0576 | ||
| 
						 | 
					624feae8af | ||
| 
						 | 
					246f2b016b | ||
| 
						 | 
					118204f9a7 | ||
| 
						 | 
					60d16c258a | ||
| 
						 | 
					c56dbabcfd | ||
| 
						 | 
					30167ace51 | ||
| 
						 | 
					b01db3b279 | ||
| 
						 | 
					2af5880cfd | ||
| 
						 | 
					ff3fa159d0 | ||
| 
						 | 
					c440333535 | ||
| 
						 | 
					5322333b7b | ||
| 
						 | 
					e98823d847 | ||
| 
						 | 
					d87a127837 | ||
| 
						 | 
					0062e618f0 | ||
| 
						 | 
					282382cc14 | ||
| 
						 | 
					0a3aece096 | ||
| 
						 | 
					bc35d57932 | ||
| 
						 | 
					dd1a3c26ba | ||
| 
						 | 
					5f988984e4 | ||
| 
						 | 
					0748cdc7f1 | ||
| 
						 | 
					b2c71c489d | ||
| 
						 | 
					2ce906cee7 | ||
| 
						 | 
					23b1ff0970 | ||
| 
						 | 
					c2777386fc | ||
| 
						 | 
					7a48984dd5 | ||
| 
						 | 
					96f2552c8a | ||
| 
						 | 
					e5658b9331 | ||
| 
						 | 
					ac2336adb0 | ||
| 
						 | 
					5da8738fea | ||
| 
						 | 
					f9f6c92c52 | ||
| 
						 | 
					98753dd088 | ||
| 
						 | 
					881cb8b108 | ||
| 
						 | 
					66bca12856 | ||
| 
						 | 
					256c5769b4 | ||
| 
						 | 
					b36ea7636b | ||
| 
						 | 
					1f7238a434 | ||
| 
						 | 
					2944c9c665 | ||
| 
						 | 
					129bd04329 | ||
| 
						 | 
					a6816db813 | ||
| 
						 | 
					1d76d78858 | ||
| 
						 | 
					fb70607064 | ||
| 
						 | 
					959ba907df | ||
| 
						 | 
					dfc3b51e78 | ||
| 
						 | 
					7f2e024e78 | ||
| 
						 | 
					193e764c0b | ||
| 
						 | 
					6b20c70b52 | ||
| 
						 | 
					69c5d47bd4 | ||
| 
						 | 
					daf5fafced | ||
| 
						 | 
					fa47b4d8b8 | ||
| 
						 | 
					661ef5eead | ||
| 
						 | 
					d38ef273cc | ||
| 
						 | 
					85ca752e33 | ||
| 
						 | 
					17244d193b | ||
| 
						 | 
					df77232bdc | ||
| 
						 | 
					2ae5bd9bb6 | ||
| 
						 | 
					8ce7348625 | ||
| 
						 | 
					3f1cbad2e7 | ||
| 
						 | 
					e78a012305 | ||
| 
						 | 
					4d1e5535b2 | ||
| 
						 | 
					1954767b45 | ||
| 
						 | 
					0bc81d5135 | ||
| 
						 | 
					6983b4615c | ||
| 
						 | 
					339e4dd3ef | ||
| 
						 | 
					d57084f235 | ||
| 
						 | 
					4a2e36b19e | ||
| 
						 | 
					1c2018f37f | ||
| 
						 | 
					04572965ea | ||
| 
						 | 
					1832f5e751 | ||
| 
						 | 
					d3f56a69fb | ||
| 
						 | 
					bfbc667397 | ||
| 
						 | 
					cb284033f5 | ||
| 
						 | 
					ef9d3a10c3 | ||
| 
						 | 
					20c9a50710 | ||
| 
						 | 
					5b9aa0e474 | ||
| 
						 | 
					475cc45a61 | ||
| 
						 | 
					21fa937c9f | ||
| 
						 | 
					bae500aa21 | ||
| 
						 | 
					5534b7f133 | ||
| 
						 | 
					163d6401c5 | ||
| 
						 | 
					fc24169eaf | ||
| 
						 | 
					0c78046356 | ||
| 
						 | 
					4b8e01a22f | ||
| 
						 | 
					a882c80e6f | ||
| 
						 | 
					5de00c254d | ||
| 
						 | 
					d7b612e737 | ||
| 
						 | 
					d95b69b32c | ||
| 
						 | 
					1dbfa26b5a | ||
| 
						 | 
					342a584c2b | ||
| 
						 | 
					718d8a931d | ||
| 
						 | 
					39db27cb83 | ||
| 
						 | 
					cc81432b5b | ||
| 
						 | 
					c71414b3a9 | ||
| 
						 | 
					542e010aa5 | ||
| 
						 | 
					84ce9aa177 | ||
| 
						 | 
					4c94c028a7 | ||
| 
						 | 
					88a908e50d | ||
| 
						 | 
					d7de7bcf3e | ||
| 
						 | 
					cbdda5cc87 | ||
| 
						 | 
					4e356d9876 | ||
| 
						 | 
					ff3ab1699b | ||
| 
						 | 
					8eeefabf32 | ||
| 
						 | 
					214b8b998a | ||
| 
						 | 
					2ef9e7efe6 | ||
| 
						 | 
					449598e723 | ||
| 
						 | 
					5201cb5acb | ||
| 
						 | 
					ab79ac44d5 | ||
| 
						 | 
					e286dfe6ed | ||
| 
						 | 
					17e3b273e6 | ||
| 
						 | 
					c93c8d1123 | ||
| 
						 | 
					d5bf2e06b3 | ||
| 
						 | 
					bbd6c8bd16 | ||
| 
						 | 
					00f76ad0df | ||
| 
						 | 
					4b70367430 | ||
| 
						 | 
					ce9cbfc815 | ||
| 
						 | 
					a92a9f02fb | ||
| 
						 | 
					b65d3741b3 | ||
| 
						 | 
					fcf8f4d453 | ||
| 
						 | 
					13617646da | ||
| 
						 | 
					7a3565009e | ||
| 
						 | 
					9f3864fde3 | ||
| 
						 | 
					db186beee4 | ||
| 
						 | 
					1f1a32541f | ||
| 
						 | 
					0465313e70 | ||
| 
						 | 
					8d2563f136 | ||
| 
						 | 
					21996c6d8e | ||
| 
						 | 
					fcc5349156 | ||
| 
						 | 
					1a07628209 | ||
| 
						 | 
					814af7e175 | ||
| 
						 | 
					bf683ec609 | ||
| 
						 | 
					e851895f04 | ||
| 
						 | 
					a2049ba394 | ||
| 
						 | 
					a8239afc86 | ||
| 
						 | 
					bb38cd49e4 | ||
| 
						 | 
					1cbdbcd587 | ||
| 
						 | 
					7e201e9f73 | ||
| 
						 | 
					9fc866c5eb | ||
| 
						 | 
					b0e88fb11b | ||
| 
						 | 
					04c71cd725 | ||
| 
						 | 
					d64b16ab25 | ||
| 
						 | 
					f30b793779 | ||
| 
						 | 
					94ea9c84c5 | ||
| 
						 | 
					5c72869563 | ||
| 
						 | 
					712419b73a | ||
| 
						 | 
					7627efc92f | ||
| 
						 | 
					cd7f458e28 | ||
| 
						 | 
					ea01493df0 | ||
| 
						 | 
					323edf1908 | ||
| 
						 | 
					ba9cf37d59 | ||
| 
						 | 
					2581aacd52 | ||
| 
						 | 
					533a0c4ce7 | ||
| 
						 | 
					93f3decc4f | ||
| 
						 | 
					1c799131ae | ||
| 
						 | 
					b1d4b48d39 | ||
| 
						 | 
					bed4559052 | ||
| 
						 | 
					7f87c1c0fc | ||
| 
						 | 
					aaf7b47abe | ||
| 
						 | 
					af0b30e77c | ||
| 
						 | 
					9494e3cc40 | ||
| 
						 | 
					a272f7eb08 | ||
| 
						 | 
					b3dd9f3bb5 | ||
| 
						 | 
					bb9104f0ee | ||
| 
						 | 
					ae0b7667a9 | ||
| 
						 | 
					fabf7d3a67 | ||
| 
						 | 
					54307ce955 | ||
| 
						 | 
					2589b74fd8 | ||
| 
						 | 
					d9090acdfb | ||
| 
						 | 
					72951df799 | ||
| 
						 | 
					a9b41af71c | ||
| 
						 | 
					a0ed612fef | ||
| 
						 | 
					afdec73ca5 | ||
| 
						 | 
					2e70cb6506 | ||
| 
						 | 
					1794904a4a | ||
| 
						 | 
					fd28279a62 | ||
| 
						 | 
					6b27ae1d94 | ||
| 
						 | 
					a6ee8fe26a | ||
| 
						 | 
					e758ce69a3 | ||
| 
						 | 
					38b085902f | ||
| 
						 | 
					27498a3330 | ||
| 
						 | 
					49cd4b7316 | ||
| 
						 | 
					a067cba35b | ||
| 
						 | 
					2905015c6e | ||
| 
						 | 
					610abd4c52 | ||
| 
						 | 
					ddc6ea162f | ||
| 
						 | 
					b8804bf15d | ||
| 
						 | 
					d03ad453a5 | ||
| 
						 | 
					3f71579dfc | ||
| 
						 | 
					f217439ee2 | ||
| 
						 | 
					9d8f3cfb7f | ||
| 
						 | 
					d5c79928ef | ||
| 
						 | 
					37529750e2 | ||
| 
						 | 
					c9ea7400b4 | ||
| 
						 | 
					9fa15b6ff8 | ||
| 
						 | 
					9c44ebc1e2 | ||
| 
						 | 
					75e3026a14 | ||
| 
						 | 
					0a3af9a403 | ||
| 
						 | 
					3a08cf3bfb | ||
| 
						 | 
					8826087a97 | ||
| 
						 | 
					8aa09a245c | ||
| 
						 | 
					a5fd84de41 | ||
| 
						 | 
					dc199cfaa2 | ||
| 
						 | 
					b81ef84227 | ||
| 
						 | 
					91203a9482 | ||
| 
						 | 
					134fea9d0f | ||
| 
						 | 
					a153c46d7f | ||
| 
						 | 
					8faad520ae | ||
| 
						 | 
					8f89ae928b | ||
| 
						 | 
					782ded56e5 | ||
| 
						 | 
					8e458d52b5 | ||
| 
						 | 
					1f475c1f6f | ||
| 
						 | 
					bc9867e672 | ||
| 
						 | 
					412fd4708d | ||
| 
						 | 
					273c624442 | ||
| 
						 | 
					8b591c2f8e | ||
| 
						 | 
					8f4a23e3b7 | ||
| 
						 | 
					c83d8e2ba6 | ||
| 
						 | 
					6afc70be84 | ||
| 
						 | 
					f503c2c9e6 | ||
| 
						 | 
					7656893d51 | ||
| 
						 | 
					ff38d68237 | ||
| 
						 | 
					aff3e60754 | ||
| 
						 | 
					8196d87371 | ||
| 
						 | 
					61b1ad197a | ||
| 
						 | 
					293bb4b1b8 | ||
| 
						 | 
					29ca164513 | ||
| 
						 | 
					97d58eadbf | ||
| 
						 | 
					8cdeec9f54 | ||
| 
						 | 
					082cd4e564 | ||
| 
						 | 
					2115a89212 | ||
| 
						 | 
					af3ec1e24e | ||
| 
						 | 
					f275683ae8 | ||
| 
						 | 
					da91e37d37 | ||
| 
						 | 
					2758c44398 | ||
| 
						 | 
					4e056a2894 | ||
| 
						 | 
					f60b017da8 | ||
| 
						 | 
					08634f1156 | ||
| 
						 | 
					a50d6a801f | ||
| 
						 | 
					0439a5a8a7 | ||
| 
						 | 
					8ffe66b4ce | ||
| 
						 | 
					d62ec8362a | ||
| 
						 | 
					259b33d5a3 | ||
| 
						 | 
					6393c09cda | ||
| 
						 | 
					9421f1ab9c | ||
| 
						 | 
					5bf0d0ea1e | ||
| 
						 | 
					769f74b818 | ||
| 
						 | 
					64051a3a71 | ||
| 
						 | 
					8260eded07 | ||
| 
						 | 
					402b4a784d | ||
| 
						 | 
					651e7ddf7e | ||
| 
						 | 
					40bace2da6 | ||
| 
						 | 
					e89c82f549 | ||
| 
						 | 
					812d100d06 | ||
| 
						 | 
					b759742352 | ||
| 
						 | 
					475e4d23bd | ||
| 
						 | 
					bf4ae6dcfa | ||
| 
						 | 
					17d4f07658 | ||
| 
						 | 
					5ec797f263 | ||
| 
						 | 
					5b1aea7afe | ||
| 
						 | 
					327e113775 | ||
| 
						 | 
					58f3009aba | ||
| 
						 | 
					b193f29a9b | ||
| 
						 | 
					7ab58bf012 | ||
| 
						 | 
					cd10ba9c39 | ||
| 
						 | 
					96a3369c4a | ||
| 
						 | 
					e8ad570e3f | ||
| 
						 | 
					ad1ddf413c | ||
| 
						 | 
					e2c2152be9 | ||
| 
						 | 
					919b2a9673 | ||
| 
						 | 
					024a20905d | ||
| 
						 | 
					69ba8a00ad | ||
| 
						 | 
					f6a0c4f853 | ||
| 
						 | 
					040ade9bee | ||
| 
						 | 
					46ce790727 | ||
| 
						 | 
					9831d941ca | ||
| 
						 | 
					707ceb29e0 | ||
| 
						 | 
					3d470fc7b7 | ||
| 
						 | 
					edb7b28a00 | ||
| 
						 | 
					c4efde7403 | ||
| 
						 | 
					a1edc87664 | ||
| 
						 | 
					9cbc3356e7 | ||
| 
						 | 
					9161c2ff51 | ||
| 
						 | 
					21f8cf65e6 | ||
| 
						 | 
					8bcc049399 | ||
| 
						 | 
					95900b8592 | ||
| 
						 | 
					20a50cb517 | ||
| 
						 | 
					a71a482250 | ||
| 
						 | 
					8b6ee018c2 | ||
| 
						 | 
					ddab3c9327 | ||
| 
						 | 
					6a9a7ff259 | ||
| 
						 | 
					f7cd5462c9 | ||
| 
						 | 
					d268511c84 | ||
| 
						 | 
					190467767e | ||
| 
						 | 
					8d699c8c93 | ||
| 
						 | 
					e2a93e38d6 | ||
| 
						 | 
					41c2fb962c | ||
| 
						 | 
					455bacd4d3 | ||
| 
						 | 
					e85cbdad7a | ||
| 
						 | 
					c752563e43 | ||
| 
						 | 
					0eae6cd5f2 | ||
| 
						 | 
					0bf707e346 | ||
| 
						 | 
					96a2c35d91 | ||
| 
						 | 
					f9fde13590 | ||
| 
						 | 
					74174b9d05 | ||
| 
						 | 
					89eda1fc01 | ||
| 
						 | 
					bbec79a0c1 | ||
| 
						 | 
					6f7ba4be1f | ||
| 
						 | 
					2ccb522c5b | ||
| 
						 | 
					0bf76767b0 | ||
| 
						 | 
					732c9fe179 | ||
| 
						 | 
					4f99ab58f7 | ||
| 
						 | 
					339abc9bd9 | ||
| 
						 | 
					4407fbc2d4 | ||
| 
						 | 
					27f08d6d48 | ||
| 
						 | 
					a9e0953900 | ||
| 
						 | 
					9597027693 | ||
| 
						 | 
					78f41a4e89 | ||
| 
						 | 
					76dcae8020 | ||
| 
						 | 
					190ef122b2 | ||
| 
						 | 
					dc74e7d5d7 | ||
| 
						 | 
					3d76ceddff | ||
| 
						 | 
					b963f807be | ||
| 
						 | 
					005bbb52ff | ||
| 
						 | 
					a690102da2 | ||
| 
						 | 
					09db11783d | ||
| 
						 | 
					f6733ae577 | ||
| 
						 | 
					2d2ca3aab1 | ||
| 
						 | 
					cfc7620572 | ||
| 
						 | 
					9a01bc0732 | ||
| 
						 | 
					dbcc560717 | ||
| 
						 | 
					449d39f41c | ||
| 
						 | 
					84236041c1 | ||
| 
						 | 
					8d44d96ec3 | ||
| 
						 | 
					707e098687 | ||
| 
						 | 
					88de74ad83 | ||
| 
						 | 
					97b8718f15 | ||
| 
						 | 
					388a6f937f | ||
| 
						 | 
					a61050ad96 | ||
| 
						 | 
					baaeac3036 | ||
| 
						 | 
					d19370b617 | ||
| 
						 | 
					8376acbf7f | ||
| 
						 | 
					12a2ff9625 | ||
| 
						 | 
					292a217b51 | ||
| 
						 | 
					104117c5e7 | ||
| 
						 | 
					7ab3c662e3 | ||
| 
						 | 
					4fd5e85a18 | ||
| 
						 | 
					e9a9211e75 | ||
| 
						 | 
					d438845ac8 | ||
| 
						 | 
					b1d495b2c4 | ||
| 
						 | 
					6b7a46b721 | ||
| 
						 | 
					ff90d659e6 | ||
| 
						 | 
					8f841c70c4 | ||
| 
						 | 
					052c0f276e | ||
| 
						 | 
					1e7e392419 | ||
| 
						 | 
					e11b82c337 | ||
| 
						 | 
					04ad43af9e | ||
| 
						 | 
					227aec9a0f | ||
| 
						 | 
					b0165ce439 | ||
| 
						 | 
					3c8756f024 | ||
| 
						 | 
					1801bc0658 | ||
| 
						 | 
					ebbad107bf | ||
| 
						 | 
					fc0ab2eac2 | ||
| 
						 | 
					64cb996206 | ||
| 
						 | 
					413f2b2247 | ||
| 
						 | 
					fbf4c7b4f1 | ||
| 
						 | 
					99542d8763 | ||
| 
						 | 
					b3c1d18d03 | ||
| 
						 | 
					6c8aec60ca | ||
| 
						 | 
					c0ca52952e | ||
| 
						 | 
					39d727d0c3 | ||
| 
						 | 
					6319853811 | ||
| 
						 | 
					6b3a385f85 | ||
| 
						 | 
					27a80b7906 | ||
| 
						 | 
					4e33db9a3f | ||
| 
						 | 
					ca9a114f7a | ||
| 
						 | 
					ce1dc2e9b2 | ||
| 
						 | 
					b4b62004a6 | ||
| 
						 | 
					f7eb95852c | ||
| 
						 | 
					12a296edfc | ||
| 
						 | 
					e696a05791 | ||
| 
						 | 
					4a13e4b36c | ||
| 
						 | 
					b7fb041f31 | ||
| 
						 | 
					a98beb3a2d | ||
| 
						 | 
					f627c159b1 | ||
| 
						 | 
					535cedf136 | ||
| 
						 | 
					3a00964dd3 | ||
| 
						 | 
					a69d50b02d | ||
| 
						 | 
					ed7443661c | ||
| 
						 | 
					3d2aa62cb6 | ||
| 
						 | 
					9925249ba5 | ||
| 
						 | 
					d7041ea5de | ||
| 
						 | 
					68a9ee13e8 | ||
| 
						 | 
					a64f08f3dd | ||
| 
						 | 
					384897f46b | ||
| 
						 | 
					08e60fc0ff | ||
| 
						 | 
					ea050a6eb3 | ||
| 
						 | 
					bde63f803a | ||
| 
						 | 
					e73308638a | ||
| 
						 | 
					1ac3419ef6 | ||
| 
						 | 
					1e9858a28b | ||
| 
						 | 
					8f4a09e531 | ||
| 
						 | 
					3b2f77d88e | ||
| 
						 | 
					52ccf9e1c1 | ||
| 
						 | 
					5e947727a9 | ||
| 
						 | 
					d7bd58cf36 | ||
| 
						 | 
					b84e473d63 | ||
| 
						 | 
					4aecd67d04 | ||
| 
						 | 
					74a25e9cd9 | ||
| 
						 | 
					d020139db7 | ||
| 
						 | 
					f84acec8ea | ||
| 
						 | 
					d3b282e01f | ||
| 
						 | 
					85d9e2f2f0 | ||
| 
						 | 
					04ed3994e2 | ||
| 
						 | 
					6100502726 | ||
| 
						 | 
					a1f09ea8f8 | ||
| 
						 | 
					bce625987d | ||
| 
						 | 
					3c1a6f441b | ||
| 
						 | 
					97d640e1f0 | ||
| 
						 | 
					ddf7602425 | ||
| 
						 | 
					d3c32ffbcc | ||
| 
						 | 
					1d2a3fe246 | ||
| 
						 | 
					00c8546d21 | ||
| 
						 | 
					31e441a805 | ||
| 
						 | 
					c4a28caa32 | ||
| 
						 | 
					c3eb0c1e7f | ||
| 
						 | 
					d18f681310 | ||
| 
						 | 
					ea5214328b | ||
| 
						 | 
					0833a40d13 | ||
| 
						 | 
					ab1a01e9b2 | ||
| 
						 | 
					f1e1d6d6af | ||
| 
						 | 
					b012127a99 | ||
| 
						 | 
					265a9e2c5d | ||
| 
						 | 
					b0b3b11dbf | ||
| 
						 | 
					c578208d63 | ||
| 
						 | 
					038461a61b | ||
| 
						 | 
					716c94492a | ||
| 
						 | 
					a4f335ba3e | ||
| 
						 | 
					90832c891e | ||
| 
						 | 
					dc2ab9f4fa | ||
| 
						 | 
					162d858a90 | ||
| 
						 | 
					13ac37d01a | ||
| 
						 | 
					c2decc56b0 | ||
| 
						 | 
					1649d5fee1 | ||
| 
						 | 
					f8279b8ea3 | ||
| 
						 | 
					76b8f839c2 | ||
| 
						 | 
					8d37f07e09 | ||
| 
						 | 
					450c73d98b | ||
| 
						 | 
					2ead4a5df6 | ||
| 
						 | 
					addafc08a5 | ||
| 
						 | 
					e970fa0022 | ||
| 
						 | 
					458bb156bf | ||
| 
						 | 
					bca9dc2a51 | ||
| 
						 | 
					3720ea24f0 | ||
| 
						 | 
					72a37c03be | ||
| 
						 | 
					93d1969c78 | ||
| 
						 | 
					6178bb8fe9 | ||
| 
						 | 
					5b195b5a0e | ||
| 
						 | 
					4289131ae6 | ||
| 
						 | 
					b721e1e239 | ||
| 
						 | 
					6cf2012a4d | ||
| 
						 | 
					e459ebaed1 | ||
| 
						 | 
					e9e3ce40c5 | ||
| 
						 | 
					56d84db1d4 | ||
| 
						 | 
					16758de0a2 | ||
| 
						 | 
					f19b6474fe | ||
| 
						 | 
					2f6f2970c4 | ||
| 
						 | 
					f227a1af7d | ||
| 
						 | 
					4408572079 | ||
| 
						 | 
					31b5b999c7 | ||
| 
						 | 
					f8bcfb5d5a | ||
| 
						 | 
					44e9c2617a | ||
| 
						 | 
					b61739874e | ||
| 
						 | 
					73957bd323 | ||
| 
						 | 
					81f1338613 | ||
| 
						 | 
					90baf2a92d | ||
| 
						 | 
					13793a0ddf | ||
| 
						 | 
					b334853d72 | ||
| 
						 | 
					4b5d50e26b | ||
| 
						 | 
					6d454e6ab2 | ||
| 
						 | 
					4f0e09aa67 | ||
| 
						 | 
					e921bbf9f6 | ||
| 
						 | 
					205a4a9571 | ||
| 
						 | 
					44279d4638 | ||
| 
						 | 
					9f1c3d7392 | ||
| 
						 | 
					362be34a2f | ||
| 
						 | 
					ec7f13d375 | ||
| 
						 | 
					ec27c2ac97 | ||
| 
						 | 
					b97c854e15 | ||
| 
						 | 
					bdbbf930aa | ||
| 
						 | 
					5254b53e97 | ||
| 
						 | 
					8adc3e5db7 | ||
| 
						 | 
					4810644f65 | ||
| 
						 | 
					d24d873e17 | ||
| 
						 | 
					7728770623 | ||
| 
						 | 
					279c36564f | ||
| 
						 | 
					50d1c3fd85 | ||
| 
						 | 
					ed712101ea | ||
| 
						 | 
					015eb65963 | ||
| 
						 | 
					afafa3e15c | ||
| 
						 | 
					150f2d8d24 | ||
| 
						 | 
					a6545f0566 | ||
| 
						 | 
					5fc041cca0 | ||
| 
						 | 
					089cd046af | ||
| 
						 | 
					7e8852c549 | ||
| 
						 | 
					4064a85205 | ||
| 
						 | 
					3a9fef60a1 | ||
| 
						 | 
					be9419edf4 | ||
| 
						 | 
					a729d47d41 | ||
| 
						 | 
					6abf827f25 | ||
| 
						 | 
					5af9fcaf35 | ||
| 
						 | 
					5736d40dad | ||
| 
						 | 
					0dfd83b9f4 | ||
| 
						 | 
					8e10dea8ec | ||
| 
						 | 
					a69e8ea1a1 | ||
| 
						 | 
					1f656724f6 | ||
| 
						 | 
					ca55c617e5 | ||
| 
						 | 
					9063e375e8 | ||
| 
						 | 
					97c9760f61 | ||
| 
						 | 
					df60710ea8 | ||
| 
						 | 
					5d2edd2659 | ||
| 
						 | 
					a558ae9496 | ||
| 
						 | 
					d58a949aae | ||
| 
						 | 
					00e608c89d | ||
| 
						 | 
					b4dfd76a4c | ||
| 
						 | 
					ea9a52d124 | ||
| 
						 | 
					75cc5e05ad | ||
| 
						 | 
					84ae14d754 | ||
| 
						 | 
					a9e897adc3 | ||
| 
						 | 
					fc0f3ad254 | ||
| 
						 | 
					a1fbe27123 | ||
| 
						 | 
					1c45b1fef3 | ||
| 
						 | 
					e003386793 | ||
| 
						 | 
					a533b89c9f | ||
| 
						 | 
					a2ffad81c8 | ||
| 
						 | 
					081cdf3f63 | ||
| 
						 | 
					dbf5b18a99 | ||
| 
						 | 
					0b3f7afaed | ||
| 
						 | 
					d6e8f6ae2b | ||
| 
						 | 
					af629a19d7 | ||
| 
						 | 
					9a3eaa1117 | ||
| 
						 | 
					7a68e6aad1 | ||
| 
						 | 
					f27fa54388 | ||
| 
						 | 
					48acb9e08a | ||
| 
						 | 
					e5706ccbde | ||
| 
						 | 
					9a82ef5255 | ||
| 
						 | 
					4a1dcb2d03 | ||
| 
						 | 
					ef92312b41 | ||
| 
						 | 
					4673461789 | ||
| 
						 | 
					2f8275c52d | ||
| 
						 | 
					39ebb51bba | ||
| 
						 | 
					d7227da9a8 | ||
| 
						 | 
					ab805194a6 | ||
| 
						 | 
					4fac53a757 | ||
| 
						 | 
					11198b78a2 | ||
| 
						 | 
					573a568dd0 | ||
| 
						 | 
					ff3dd00370 | ||
| 
						 | 
					2028c2800a | ||
| 
						 | 
					fd8766b67e | ||
| 
						 | 
					7d210e5194 | ||
| 
						 | 
					2e674fc611 | ||
| 
						 | 
					5cfd3419c6 | ||
| 
						 | 
					9efd4fb891 | ||
| 
						 | 
					b2e85f9d93 | ||
| 
						 | 
					f10581829d | ||
| 
						 | 
					78af3b274f | ||
| 
						 | 
					facd9a2024 | ||
| 
						 | 
					461f00dd53 | ||
| 
						 | 
					22f03eaedf | ||
| 
						 | 
					d467c74954 | ||
| 
						 | 
					c4c745ccb8 | ||
| 
						 | 
					3b66e34e74 | ||
| 
						 | 
					2250f475fc | ||
| 
						 | 
					ed703912b2 | ||
| 
						 | 
					2cddcd1dbb | ||
| 
						 | 
					231360a3b7 | ||
| 
						 | 
					65ac3faff6 | ||
| 
						 | 
					778252741e | ||
| 
						 | 
					96e40d97cc | ||
| 
						 | 
					4b3743c85a | ||
| 
						 | 
					5795665a7d | ||
| 
						 | 
					88f1be140c | ||
| 
						 | 
					fc16b228fd | ||
| 
						 | 
					a5b2ccaaad | ||
| 
						 | 
					5dd352c916 | ||
| 
						 | 
					3c204aaf50 | ||
| 
						 | 
					3ae184d31f | ||
| 
						 | 
					3e975124f3 | ||
| 
						 | 
					74c467f9f2 | ||
| 
						 | 
					1b97c938e9 | ||
| 
						 | 
					b3e2acac4e | ||
| 
						 | 
					403fa0dc53 | ||
| 
						 | 
					f918c330a9 | ||
| 
						 | 
					7f52f77efe | ||
| 
						 | 
					90b480f2af | ||
| 
						 | 
					578c33c010 | ||
| 
						 | 
					d6a821b9d7 | ||
| 
						 | 
					7d8b5c530f | ||
| 
						 | 
					2033da0b23 | ||
| 
						 | 
					c4ac954c59 | ||
| 
						 | 
					2640aec227 | ||
| 
						 | 
					a1037ce3bc | ||
| 
						 | 
					249737e53d | ||
| 
						 | 
					c70573dee1 | ||
| 
						 | 
					6c98ed520d | ||
| 
						 | 
					37ceea7333 | ||
| 
						 | 
					374b227226 | ||
| 
						 | 
					8c4a5016ce | ||
| 
						 | 
					1056275825 | ||
| 
						 | 
					9634acedaf | ||
| 
						 | 
					3a4b0bed49 | ||
| 
						 | 
					84f4e33ea3 | ||
| 
						 | 
					b093ef7445 | ||
| 
						 | 
					405ac901c9 | ||
| 
						 | 
					721ccb6cf5 | ||
| 
						 | 
					ba05727773 | ||
| 
						 | 
					f9332da521 | ||
| 
						 | 
					156516ce44 | ||
| 
						 | 
					157e44a799 | ||
| 
						 | 
					7d2ff3f081 | ||
| 
						 | 
					25a87e82d4 | ||
| 
						 | 
					e400753ed8 | ||
| 
						 | 
					0984fcf118 | ||
| 
						 | 
					18cc99ac17 | ||
| 
						 | 
					1522c23470 | ||
| 
						 | 
					2341e303da | ||
| 
						 | 
					dca142029c | ||
| 
						 | 
					7448f5e5ed | ||
| 
						 | 
					45caf9c50c | ||
| 
						 | 
					ace2ca484b | ||
| 
						 | 
					7dc584ed91 | ||
| 
						 | 
					855f0b4f2f | ||
| 
						 | 
					2bf30d6b47 | ||
| 
						 | 
					685e7d7225 | ||
| 
						 | 
					38dbcb2248 | ||
| 
						 | 
					bb3a69f801 | ||
| 
						 | 
					55db40d3e0 | ||
| 
						 | 
					f1fbf15116 | ||
| 
						 | 
					9bdbdda261 | ||
| 
						 | 
					ad2057500a | ||
| 
						 | 
					d0e3726ca4 | ||
| 
						 | 
					75a46764e5 | ||
| 
						 | 
					4eceda658b | ||
| 
						 | 
					1c511bdb7c | ||
| 
						 | 
					f9bd76e4f7 | ||
| 
						 | 
					e74e0dedcd | ||
| 
						 | 
					dcf6eb2a9e | ||
| 
						 | 
					7d2980f09e | ||
| 
						 | 
					f1fe6fa6e4 | ||
| 
						 | 
					ecb7a9c73a | ||
| 
						 | 
					aebe0396e9 | ||
| 
						 | 
					4e9a77cf26 | ||
| 
						 | 
					14ef32631c | ||
| 
						 | 
					500f07c8de | ||
| 
						 | 
					ae936dae90 | ||
| 
						 | 
					67166dc05c | ||
| 
						 | 
					aa9fed8cc2 | ||
| 
						 | 
					442eb8a4c3 | ||
| 
						 | 
					46805f696d | ||
| 
						 | 
					29f6a99432 | ||
| 
						 | 
					1f13793b1a | ||
| 
						 | 
					08130eb158 | ||
| 
						 | 
					b27dfeacc9 | ||
| 
						 | 
					fb0f53b2e0 | ||
| 
						 | 
					baa521bef5 | ||
| 
						 | 
					7bcf65a125 | ||
| 
						 | 
					306009bb6a | ||
| 
						 | 
					dfc5336975 | ||
| 
						 | 
					4cea95a547 | ||
| 
						 | 
					b23b3272dc | ||
| 
						 | 
					1696aa1891 | ||
| 
						 | 
					52407725c9 | ||
| 
						 | 
					81da3c3319 | ||
| 
						 | 
					7729bc2634 | ||
| 
						 | 
					69a305d434 | ||
| 
						 | 
					ab5b1cf86b | ||
| 
						 | 
					c33387749b | ||
| 
						 | 
					c9ca65b469 | ||
| 
						 | 
					8e078f45e0 | ||
| 
						 | 
					f84ffd0130 | ||
| 
						 | 
					300e3d7c73 | ||
| 
						 | 
					365c6e4661 | ||
| 
						 | 
					1dc03ef706 | ||
| 
						 | 
					d4a67e3186 | ||
| 
						 | 
					18e10315e5 | ||
| 
						 | 
					e9caaa4ad9 | ||
| 
						 | 
					a6198b9ed1 | ||
| 
						 | 
					a7be294ed7 | ||
| 
						 | 
					617f461c9d | ||
| 
						 | 
					1dcb6c994f | ||
| 
						 | 
					a9ab63c01c | ||
| 
						 | 
					f89db4020f | ||
| 
						 | 
					393c09659e | ||
| 
						 | 
					2d96549cd0 | ||
| 
						 | 
					b48892d403 | ||
| 
						 | 
					7b907f0bb5 | ||
| 
						 | 
					9dfcad117c | ||
| 
						 | 
					7018feed88 | ||
| 
						 | 
					9be529f12d | ||
| 
						 | 
					f5e5277908 | ||
| 
						 | 
					c991c6e710 | ||
| 
						 | 
					e1f4319279 | ||
| 
						 | 
					2826fcc851 | ||
| 
						 | 
					37562f753a | ||
| 
						 | 
					248252682c | ||
| 
						 | 
					cc3586028e | ||
| 
						 | 
					f60df86c89 | ||
| 
						 | 
					bc7a3a9e99 | ||
| 
						 | 
					d3cbf7d86a | ||
| 
						 | 
					313bf45e42 | ||
| 
						 | 
					ce34d0ac09 | ||
| 
						 | 
					4e9dd6b0f5 | ||
| 
						 | 
					b6ccbffe2b | ||
| 
						 | 
					1aecc34e9e | ||
| 
						 | 
					75b9c0044c | ||
| 
						 | 
					600b77a93f | ||
| 
						 | 
					39335c356b | ||
| 
						 | 
					a3c62bb737 | ||
| 
						 | 
					2f6263a696 | ||
| 
						 | 
					35748f40d6 | ||
| 
						 | 
					ed62478192 | ||
| 
						 | 
					9e7733a743 | ||
| 
						 | 
					fc0bdd1aa8 | ||
| 
						 | 
					e9dad4048f | ||
| 
						 | 
					ddba94214f | ||
| 
						 | 
					e9f970891d | ||
| 
						 | 
					a89cf50c59 | ||
| 
						 | 
					f90c544039 | ||
| 
						 | 
					afcf54a5c9 | ||
| 
						 | 
					3671e38af4 | ||
| 
						 | 
					4fc3946111 | ||
| 
						 | 
					59a941e4a4 | ||
| 
						 | 
					a7cd5f3f38 | ||
| 
						 | 
					0bdbc5a86e | ||
| 
						 | 
					abecef77cf | ||
| 
						 | 
					b74dfe6e8e | ||
| 
						 | 
					d80f6e0f8c | ||
| 
						 | 
					13962f0b15 | ||
| 
						 | 
					2fc1f3dd48 | ||
| 
						 | 
					f2cbb15468 | ||
| 
						 | 
					e38e8b29f8 | ||
| 
						 | 
					c03ceadfbd | ||
| 
						 | 
					e50baf58ab | ||
| 
						 | 
					1750ec5c52 | ||
| 
						 | 
					c77bd28775 | ||
| 
						 | 
					1619add90c | ||
| 
						 | 
					a1a4e8b6bb | ||
| 
						 | 
					25f350a058 | ||
| 
						 | 
					121cb9ee38 | ||
| 
						 | 
					bc173b9fb0 | ||
| 
						 | 
					4fd9c70f06 | ||
| 
						 | 
					91aeab0de3 | ||
| 
						 | 
					c913cf446f | ||
| 
						 | 
					a88f39457b | ||
| 
						 | 
					2bbaab4a24 | ||
| 
						 | 
					1a8f4b57a9 | ||
| 
						 | 
					022b31a8c8 | ||
| 
						 | 
					dd6b494eb3 | ||
| 
						 | 
					c9bea5bad3 | ||
| 
						 | 
					296324ea03 | ||
| 
						 | 
					fa41e86a28 | ||
| 
						 | 
					9e77b7075a | ||
| 
						 | 
					5c7f9a627f | ||
| 
						 | 
					bc3e3472c1 | ||
| 
						 | 
					66bd86e2c2 | ||
| 
						 | 
					487fe20490 | ||
| 
						 | 
					80d9b1ccd7 | ||
| 
						 | 
					69c48301e0 | ||
| 
						 | 
					2be9b88135 | ||
| 
						 | 
					98fa4fce09 | ||
| 
						 | 
					1ec1d17e16 | ||
| 
						 | 
					1e11df0dc3 | ||
| 
						 | 
					421d474332 | ||
| 
						 | 
					58060fa11b | ||
| 
						 | 
					cea698f19c | ||
| 
						 | 
					48781ef7f7 | ||
| 
						 | 
					6d1a837df7 | ||
| 
						 | 
					21f422ca5e | ||
| 
						 | 
					291ae60b52 | ||
| 
						 | 
					3b79d2789d | ||
| 
						 | 
					bb9dcc99cf | ||
| 
						 | 
					3d59821134 | ||
| 
						 | 
					cae111287b | ||
| 
						 | 
					e36e473859 | ||
| 
						 | 
					d7fb66aa82 | ||
| 
						 | 
					344b3b5ce1 | ||
| 
						 | 
					3f7cf29124 | ||
| 
						 | 
					63dc69fef6 | ||
| 
						 | 
					cfe1c195c4 | ||
| 
						 | 
					0cd8572b2d | ||
| 
						 | 
					7c2831ac90 | ||
| 
						 | 
					de603b75fc | ||
| 
						 | 
					1244be2eda | ||
| 
						 | 
					9f0a373b51 | ||
| 
						 | 
					b0701709c1 | ||
| 
						 | 
					34aa216a65 | ||
| 
						 | 
					a76a29f233 | ||
| 
						 | 
					4e06ab75e8 | ||
| 
						 | 
					26147fb954 | ||
| 
						 | 
					bd53a054b1 | ||
| 
						 | 
					211b8685d3 | ||
| 
						 | 
					9c75b2d931 | ||
| 
						 | 
					54d11e6057 | ||
| 
						 | 
					3d7ba69a05 | ||
| 
						 | 
					58133d22a8 | ||
| 
						 | 
					330e5c5460 | ||
| 
						 | 
					ab519c8262 | ||
| 
						 | 
					65f29a78b2 | ||
| 
						 | 
					c363b5a62f | ||
| 
						 | 
					60ed0f94ed | ||
| 
						 | 
					f38f8d94a9 | ||
| 
						 | 
					679eb352e0 | ||
| 
						 | 
					80bbb6578e | ||
| 
						 | 
					19cc0f0ab4 | ||
| 
						 | 
					14e14ea68c | ||
| 
						 | 
					834d37ed86 | ||
| 
						 | 
					adcc235ef6 | ||
| 
						 | 
					86a0d0234d | ||
| 
						 | 
					4598be561a | ||
| 
						 | 
					af5db47e99 | ||
| 
						 | 
					fb67f40f04 | ||
| 
						 | 
					48033c3242 | ||
| 
						 | 
					aa1f5b3581 | ||
| 
						 | 
					d9d3a69595 | ||
| 
						 | 
					f9adfa6d4e | ||
| 
						 | 
					85b1fce1ef | ||
| 
						 | 
					da566db150 | ||
| 
						 | 
					be37dc73f6 | ||
| 
						 | 
					976b2c9c2f | ||
| 
						 | 
					b74d2cda28 | ||
| 
						 | 
					cc5dd9f14e | ||
| 
						 | 
					fbfcdc4cef | 
@@ -14,3 +14,4 @@ cctest.c
 | 
			
		||||
cctest.a
 | 
			
		||||
libcrypto.so.*
 | 
			
		||||
libssl.so.*
 | 
			
		||||
libcrypto.sha1
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										566
									
								
								CHANGES
									
									
									
									
									
								
							
							
						
						
									
										566
									
								
								CHANGES
									
									
									
									
									
								
							@@ -2,553 +2,24 @@
 | 
			
		||||
 OpenSSL CHANGES
 | 
			
		||||
 _______________
 | 
			
		||||
 | 
			
		||||
 Changes between 0.9.7c and 0.9.8  [xx XXX xxxx]
 | 
			
		||||
 Changes between 0.9.7c and 0.9.7d  [xx XXX XXXX]
 | 
			
		||||
 | 
			
		||||
  *) Update support for ECC-based TLS ciphersuites according to
 | 
			
		||||
     draft-ietf-tls-ecc-03.txt: the KDF1 key derivation function with
 | 
			
		||||
     SHA-1 now is only used for "small" curves (where the
 | 
			
		||||
     representation of a field element takes up to 24 bytes); for
 | 
			
		||||
     larger curves, the field element resulting from ECDH is directly
 | 
			
		||||
     used as premaster secret.
 | 
			
		||||
     [Douglas Stebila (Sun Microsystems Laboratories)]
 | 
			
		||||
  *)
 | 
			
		||||
 | 
			
		||||
  *) Add code for kP+lQ timings to crypto/ec/ectest.c, and add SEC2
 | 
			
		||||
     curve secp160r1 to the tests.
 | 
			
		||||
     [Douglas Stebila (Sun Microsystems Laboratories)]
 | 
			
		||||
 Changes between 0.9.7b and 0.9.7c  [30 Sep 2003]
 | 
			
		||||
 | 
			
		||||
  *) Add the possibility to load symbols globally with DSO.
 | 
			
		||||
     [G<>tz Babin-Ebell <babin-ebell@trustcenter.de> via Richard Levitte]
 | 
			
		||||
  *) Fix various bugs revealed by running the NISCC test suite:
 | 
			
		||||
 | 
			
		||||
  *) Add the functions ERR_set_mark() and ERR_pop_to_mark() for better
 | 
			
		||||
     control of the error stack.
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
     Stop out of bounds reads in the ASN1 code when presented with
 | 
			
		||||
     invalid tags (CAN-2003-0543 and CAN-2003-0544).
 | 
			
		||||
     
 | 
			
		||||
  *) Add support for STORE in ENGINE.
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
     Free up ASN1_TYPE correctly if ANY type is invalid (CAN-2003-0545).
 | 
			
		||||
 | 
			
		||||
  *) Add the STORE type.  The intention is to provide a common interface
 | 
			
		||||
     to certificate and key stores, be they simple file-based stores, or
 | 
			
		||||
     HSM-type store, or LDAP stores, or...
 | 
			
		||||
     NOTE: The code is currently UNTESTED and isn't really used anywhere.
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
     If verify callback ignores invalid public key errors don't try to check
 | 
			
		||||
     certificate signature with the NULL public key.
 | 
			
		||||
 | 
			
		||||
  *) Add a generic structure called OPENSSL_ITEM.  This can be used to
 | 
			
		||||
     pass a list of arguments to any function as well as provide a way
 | 
			
		||||
     for a function to pass data back to the caller.
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
 | 
			
		||||
  *) Add the functions BUF_strndup() and BUF_memdup().  BUF_strndup()
 | 
			
		||||
     works like BUF_strdup() but can be used to duplicate a portion of
 | 
			
		||||
     a string.  The copy gets NUL-terminated.  BUF_memdup() duplicates
 | 
			
		||||
     a memory area.
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
 | 
			
		||||
  *) Add the function sk_find_ex() which works like sk_find(), but will
 | 
			
		||||
     return an index to an element even if an exact match couldn't be
 | 
			
		||||
     found.  The index is guaranteed to point at the element where the
 | 
			
		||||
     searched-for key would be inserted to preserve sorting order.
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
 | 
			
		||||
  *) Add the function OBJ_bsearch_ex() which works like OBJ_bsearch() but
 | 
			
		||||
     takes an extra flags argument for optional functionality.  Currently,
 | 
			
		||||
     the following flags are defined:
 | 
			
		||||
 | 
			
		||||
	OBJ_BSEARCH_VALUE_ON_NOMATCH
 | 
			
		||||
	This one gets OBJ_bsearch_ex() to return a pointer to the first
 | 
			
		||||
	element where the comparing function returns a negative or zero
 | 
			
		||||
	number.
 | 
			
		||||
 | 
			
		||||
	OBJ_BSEARCH_FIRST_VALUE_ON_MATCH
 | 
			
		||||
	This one gets OBJ_bsearch_ex() to return a pointer to the first
 | 
			
		||||
	element where the comparing function returns zero.  This is useful
 | 
			
		||||
	if there are more than one element where the comparing function
 | 
			
		||||
	returns zero.
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
 | 
			
		||||
  *) Make it possible to create self-signed certificates with 'openssl ca'
 | 
			
		||||
     in such a way that the self-signed certificate becomes part of the
 | 
			
		||||
     CA database and uses the same mechanisms for serial number generation
 | 
			
		||||
     as all other certificate signing.  The new flag '-selfsign' enables
 | 
			
		||||
     this functionality.  Adapt CA.sh and CA.pl.in.
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
 | 
			
		||||
  *) Add functionality to check the public key of a certificate request
 | 
			
		||||
     against a given private.  This is useful to check that a certificate
 | 
			
		||||
     request can be signed by that key (self-signing).
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
 | 
			
		||||
  *) Make it possible to have multiple active certificates with the same
 | 
			
		||||
     subject in the CA index file.  This is done only if the keyword
 | 
			
		||||
     'unique_subject' is set to 'no' in the main CA section (default
 | 
			
		||||
     if 'CA_default') of the configuration file.  The value is saved
 | 
			
		||||
     with the database itself in a separate index attribute file,
 | 
			
		||||
     named like the index file with '.attr' appended to the name.
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
 | 
			
		||||
  *) Generate muti valued AVAs using '+' notation in config files for
 | 
			
		||||
     req and dirName.
 | 
			
		||||
     [Steve Henson]
 | 
			
		||||
 | 
			
		||||
  *) Support for nameConstraints certificate extension.
 | 
			
		||||
     [Steve Henson]
 | 
			
		||||
 | 
			
		||||
  *) Support for policyConstraints certificate extension.
 | 
			
		||||
     [Steve Henson]
 | 
			
		||||
 | 
			
		||||
  *) Support for policyMappings certificate extension.
 | 
			
		||||
     [Steve Henson]
 | 
			
		||||
 | 
			
		||||
  *) Fixed a typo bug that would cause ENGINE_set_default() to set an
 | 
			
		||||
     ENGINE as defaults for all supported algorithms irrespective of
 | 
			
		||||
     the 'flags' parameter. 'flags' is now honoured, so applications
 | 
			
		||||
     should make sure they are passing it correctly.
 | 
			
		||||
     [Geoff Thorpe]
 | 
			
		||||
 | 
			
		||||
  *) Make sure the default DSA_METHOD implementation only uses its
 | 
			
		||||
     dsa_mod_exp() and/or bn_mod_exp() handlers if they are non-NULL,
 | 
			
		||||
     and change its own handlers to be NULL so as to remove unnecessary
 | 
			
		||||
     indirection. This lets alternative implementations fallback to the
 | 
			
		||||
     default implementation more easily.
 | 
			
		||||
     [Geoff Thorpe]
 | 
			
		||||
 | 
			
		||||
  *) Support for directoryName in GeneralName related extensions
 | 
			
		||||
     in config files.
 | 
			
		||||
     [Steve Henson]
 | 
			
		||||
 | 
			
		||||
  *) Make it possible to link applications using Makefile.shared.
 | 
			
		||||
     Make that possible even when linking against static libraries!
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
 | 
			
		||||
  *) Support for single pass processing for S/MIME signing. This now
 | 
			
		||||
     means that S/MIME signing can be done from a pipe, in addition
 | 
			
		||||
     cleartext signing (multipart/signed type) is effectively streaming
 | 
			
		||||
     and the signed data does not need to be all held in memory.
 | 
			
		||||
 | 
			
		||||
     This is done with a new flag PKCS7_STREAM. When this flag is set
 | 
			
		||||
     PKCS7_sign() only initializes the PKCS7 structure and the actual signing
 | 
			
		||||
     is done after the data is output (and digests calculated) in
 | 
			
		||||
     SMIME_write_PKCS7().
 | 
			
		||||
     [Steve Henson]
 | 
			
		||||
 | 
			
		||||
  *) Add full support for -rpath/-R, both in shared libraries and
 | 
			
		||||
     applications, at least on the platforms where it's known how
 | 
			
		||||
     to do it.
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
 | 
			
		||||
  *) In crypto/ec/ec_mult.c, implement fast point multiplication with
 | 
			
		||||
     precomputation, based on wNAF splitting: EC_GROUP_precompute_mult()
 | 
			
		||||
     will now compute a table of multiples of the generator that
 | 
			
		||||
     makes subsequent invocations of EC_POINTs_mul() or EC_POINT_mul()
 | 
			
		||||
     faster (notably in the case of a single point multiplication,
 | 
			
		||||
     scalar * generator).
 | 
			
		||||
     [Nils Larsch, Bodo Moeller]
 | 
			
		||||
 | 
			
		||||
  *) IPv6 support for certificate extensions. The various extensions
 | 
			
		||||
     which use the IP:a.b.c.d can now take IPv6 addresses using the
 | 
			
		||||
     formats of RFC1884 2.2 . IPv6 addresses are now also displayed
 | 
			
		||||
     correctly.
 | 
			
		||||
     [Steve Henson]
 | 
			
		||||
 | 
			
		||||
  *) Added an ENGINE that implements RSA by performing private key
 | 
			
		||||
     exponentiations with the GMP library. The conversions to and from
 | 
			
		||||
     GMP's mpz_t format aren't optimised nor are any montgomery forms
 | 
			
		||||
     cached, and on x86 it appears OpenSSL's own performance has caught up.
 | 
			
		||||
     However there are likely to be other architectures where GMP could
 | 
			
		||||
     provide a boost. This ENGINE is not built in by default, but it can be
 | 
			
		||||
     specified at Configure time and should be accompanied by the necessary
 | 
			
		||||
     linker additions, eg;
 | 
			
		||||
         ./config -DOPENSSL_USE_GMP -lgmp
 | 
			
		||||
     [Geoff Thorpe]
 | 
			
		||||
 | 
			
		||||
  *) "openssl engine" will not display ENGINE/DSO load failure errors when
 | 
			
		||||
     testing availability of engines with "-t" - the old behaviour is
 | 
			
		||||
     produced by increasing the feature's verbosity with "-tt".
 | 
			
		||||
     [Geoff Thorpe]
 | 
			
		||||
 | 
			
		||||
  *) ECDSA routines: under certain error conditions uninitialized BN objects
 | 
			
		||||
     could be freed. Solution: make sure initialization is performed early
 | 
			
		||||
     enough. (Reported and fix supplied by Nils Larsch <nla@trustcenter.de>
 | 
			
		||||
     via PR#459)
 | 
			
		||||
     [Lutz Jaenicke]
 | 
			
		||||
 | 
			
		||||
  *) Key-generation can now be implemented in RSA_METHOD, DSA_METHOD
 | 
			
		||||
     and DH_METHOD (eg. by ENGINE implementations) to override the normal
 | 
			
		||||
     software implementations. For DSA and DH, parameter generation can
 | 
			
		||||
     also be overriden by providing the appropriate method callbacks.
 | 
			
		||||
     [Geoff Thorpe]
 | 
			
		||||
 | 
			
		||||
  *) Change the "progress" mechanism used in key-generation and
 | 
			
		||||
     primality testing to functions that take a new BN_GENCB pointer in
 | 
			
		||||
     place of callback/argument pairs. The new API functions have "_ex"
 | 
			
		||||
     postfixes and the older functions are reimplemented as wrappers for
 | 
			
		||||
     the new ones. The OPENSSL_NO_DEPRECATED symbol can be used to hide
 | 
			
		||||
     declarations of the old functions to help (graceful) attempts to
 | 
			
		||||
     migrate to the new functions. Also, the new key-generation API
 | 
			
		||||
     functions operate on a caller-supplied key-structure and return
 | 
			
		||||
     success/failure rather than returning a key or NULL - this is to
 | 
			
		||||
     help make "keygen" another member function of RSA_METHOD etc.
 | 
			
		||||
 | 
			
		||||
     Example for using the new callback interface:
 | 
			
		||||
 | 
			
		||||
          int (*my_callback)(int a, int b, BN_GENCB *cb) = ...;
 | 
			
		||||
          void *my_arg = ...;
 | 
			
		||||
          BN_GENCB my_cb;
 | 
			
		||||
 | 
			
		||||
          BN_GENCB_set(&my_cb, my_callback, my_arg);
 | 
			
		||||
 | 
			
		||||
          return BN_is_prime_ex(some_bignum, BN_prime_checks, NULL, &cb);
 | 
			
		||||
          /* For the meaning of a, b in calls to my_callback(), see the
 | 
			
		||||
           * documentation of the function that calls the callback.
 | 
			
		||||
           * cb will point to my_cb; my_arg can be retrieved as cb->arg.
 | 
			
		||||
           * my_callback should return 1 if it wants BN_is_prime_ex()
 | 
			
		||||
           * to continue, or 0 to stop.
 | 
			
		||||
           */
 | 
			
		||||
 | 
			
		||||
     [Geoff Thorpe]
 | 
			
		||||
 | 
			
		||||
  *) Change the ZLIB compression method to be stateful, and make it
 | 
			
		||||
     available to TLS with the number defined in 
 | 
			
		||||
     draft-ietf-tls-compression-04.txt.
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
 | 
			
		||||
  *) Add the ASN.1 structures and functions for CertificatePair, which
 | 
			
		||||
     is defined as follows (according to X.509_4thEditionDraftV6.pdf):
 | 
			
		||||
 | 
			
		||||
     CertificatePair ::= SEQUENCE {
 | 
			
		||||
        forward		[0]	Certificate OPTIONAL,
 | 
			
		||||
        reverse		[1]	Certificate OPTIONAL,
 | 
			
		||||
        -- at least one of the pair shall be present -- }
 | 
			
		||||
 | 
			
		||||
     Also implement the PEM functions to read and write certificate
 | 
			
		||||
     pairs, and defined the PEM tag as "CERTIFICATE PAIR".
 | 
			
		||||
 | 
			
		||||
     This needed to be defined, mostly for the sake of the LDAP
 | 
			
		||||
     attribute crossCertificatePair, but may prove useful elsewhere as
 | 
			
		||||
     well.
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
 | 
			
		||||
  *) Make it possible to inhibit symlinking of shared libraries in
 | 
			
		||||
     Makefile.shared, for Cygwin's sake.
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
 | 
			
		||||
  *) Extend the BIGNUM API by creating new macros that behave like
 | 
			
		||||
     functions
 | 
			
		||||
 | 
			
		||||
          void BN_set_sign(BIGNUM *a, int neg);
 | 
			
		||||
          int BN_get_sign(const BIGNUM *a);
 | 
			
		||||
 | 
			
		||||
     and avoid the need to access 'a->neg' directly in applications.
 | 
			
		||||
     [Nils Larsch  <nla@trustcenter.de>]
 | 
			
		||||
 | 
			
		||||
  *) Implement fast modular reduction for pseudo-Mersenne primes
 | 
			
		||||
     used in NIST curves (crypto/bn/bn_nist.c, crypto/ec/ecp_nist.c).
 | 
			
		||||
     EC_GROUP_new_curve_GFp() will now automatically use this
 | 
			
		||||
     if applicable.
 | 
			
		||||
     [Nils Larsch <nla@trustcenter.de>]
 | 
			
		||||
 | 
			
		||||
  *) Add new lock type (CRYPTO_LOCK_BN).
 | 
			
		||||
     [Bodo Moeller]
 | 
			
		||||
 | 
			
		||||
  *) Change the ENGINE framework to automatically load engines
 | 
			
		||||
     dynamically from specific directories unless they could be
 | 
			
		||||
     found to already be built in or loaded.  Move all the
 | 
			
		||||
     current engines except for the cryptodev one to a new
 | 
			
		||||
     directory engines/.
 | 
			
		||||
     The engines in engines/ are built as shared libraries if
 | 
			
		||||
     the "shared" options was given to ./Configure or ./config.
 | 
			
		||||
     Otherwise, they are inserted in libcrypto.a.
 | 
			
		||||
     /usr/local/ssl/engines is the default directory for dynamic
 | 
			
		||||
     engines, but that can be overriden at configure time through
 | 
			
		||||
     the usual use of --prefix and/or --openssldir, and at run
 | 
			
		||||
     time with the environment variable OPENSSL_ENGINES.
 | 
			
		||||
     [Geoff Thorpe and Richard Levitte]
 | 
			
		||||
 | 
			
		||||
  *) Add Makefile.shared, a helper makefile to build shared
 | 
			
		||||
     libraries.  Addapt Makefile.org.
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
 | 
			
		||||
  *) Add version info to Win32 DLLs.
 | 
			
		||||
     [Peter 'Luna' Runestig" <peter@runestig.com>]
 | 
			
		||||
 | 
			
		||||
  *) Add new 'medium level' PKCS#12 API. Certificates and keys
 | 
			
		||||
     can be added using this API to created arbitrary PKCS#12
 | 
			
		||||
     files while avoiding the low level API.
 | 
			
		||||
 | 
			
		||||
     New options to PKCS12_create(), key or cert can be NULL and
 | 
			
		||||
     will then be omitted from the output file. The encryption
 | 
			
		||||
     algorithm NIDs can be set to -1 for no encryption, the mac
 | 
			
		||||
     iteration count can be set to 0 to omit the mac.
 | 
			
		||||
 | 
			
		||||
     Enhance pkcs12 utility by making the -nokeys and -nocerts
 | 
			
		||||
     options work when creating a PKCS#12 file. New option -nomac
 | 
			
		||||
     to omit the mac, NONE can be set for an encryption algorithm.
 | 
			
		||||
     New code is modified to use the enhanced PKCS12_create()
 | 
			
		||||
     instead of the low level API.
 | 
			
		||||
     [Steve Henson]
 | 
			
		||||
 | 
			
		||||
  *) Extend ASN1 encoder to support indefinite length constructed
 | 
			
		||||
     encoding. This can output sequences tags and octet strings in
 | 
			
		||||
     this form. Modify pk7_asn1.c to support indefinite length
 | 
			
		||||
     encoding. This is experimental and needs additional code to
 | 
			
		||||
     be useful, such as an ASN1 bio and some enhanced streaming
 | 
			
		||||
     PKCS#7 code.
 | 
			
		||||
 | 
			
		||||
     Extend template encode functionality so that tagging is passed
 | 
			
		||||
     down to the template encoder.
 | 
			
		||||
     [Steve Henson]
 | 
			
		||||
 | 
			
		||||
  *) Let 'openssl req' fail if an argument to '-newkey' is not
 | 
			
		||||
     recognized instead of using RSA as a default.
 | 
			
		||||
     [Bodo Moeller]
 | 
			
		||||
 | 
			
		||||
  *) Add support for ECC-based ciphersuites from draft-ietf-tls-ecc-01.txt.
 | 
			
		||||
     As these are not official, they are not included in "ALL";
 | 
			
		||||
     the "ECCdraft" ciphersuite group alias can be used to select them.
 | 
			
		||||
     [Vipul Gupta and Sumit Gupta (Sun Microsystems Laboratories)]
 | 
			
		||||
 | 
			
		||||
  *) Add ECDH engine support.
 | 
			
		||||
     [Nils Gura and Douglas Stebila (Sun Microsystems Laboratories)]
 | 
			
		||||
 | 
			
		||||
  *) Add ECDH in new directory crypto/ecdh/.
 | 
			
		||||
     [Douglas Stebila (Sun Microsystems Laboratories)]
 | 
			
		||||
 | 
			
		||||
  *) Let BN_rand_range() abort with an error after 100 iterations
 | 
			
		||||
     without success (which indicates a broken PRNG).
 | 
			
		||||
     [Bodo Moeller]
 | 
			
		||||
 | 
			
		||||
  *) Change BN_mod_sqrt() so that it verifies that the input value
 | 
			
		||||
     is really the square of the return value.  (Previously,
 | 
			
		||||
     BN_mod_sqrt would show GIGO behaviour.)
 | 
			
		||||
     [Bodo Moeller]
 | 
			
		||||
 | 
			
		||||
  *) Add named elliptic curves over binary fields from X9.62, SECG,
 | 
			
		||||
     and WAP/WTLS; add OIDs that were still missing.
 | 
			
		||||
 | 
			
		||||
     [Sheueling Chang Shantz and Douglas Stebila
 | 
			
		||||
     (Sun Microsystems Laboratories)]
 | 
			
		||||
 | 
			
		||||
  *) Extend the EC library for elliptic curves over binary fields
 | 
			
		||||
     (new files ec2_smpl.c, ec2_smpt.c, ec2_mult.c in crypto/ec/).
 | 
			
		||||
     New EC_METHOD:
 | 
			
		||||
 | 
			
		||||
          EC_GF2m_simple_method
 | 
			
		||||
 | 
			
		||||
     New API functions:
 | 
			
		||||
 | 
			
		||||
          EC_GROUP_new_curve_GF2m
 | 
			
		||||
          EC_GROUP_set_curve_GF2m
 | 
			
		||||
          EC_GROUP_get_curve_GF2m
 | 
			
		||||
          EC_POINT_set_affine_coordinates_GF2m
 | 
			
		||||
          EC_POINT_get_affine_coordinates_GF2m
 | 
			
		||||
          EC_POINT_set_compressed_coordinates_GF2m
 | 
			
		||||
 | 
			
		||||
     Point compression for binary fields is disabled by default for
 | 
			
		||||
     patent reasons (compile with OPENSSL_EC_BIN_PT_COMP defined to
 | 
			
		||||
     enable it).
 | 
			
		||||
 | 
			
		||||
     As binary polynomials are represented as BIGNUMs, various members
 | 
			
		||||
     of the EC_GROUP and EC_POINT data structures can be shared
 | 
			
		||||
     between the implementations for prime fields and binary fields;
 | 
			
		||||
     the above ..._GF2m functions (except for EX_GROUP_new_curve_GF2m)
 | 
			
		||||
     are essentially identical to their ..._GFp counterparts.
 | 
			
		||||
     (For simplicity, the '..._GFp' prefix has been dropped from
 | 
			
		||||
     various internal method names.)
 | 
			
		||||
 | 
			
		||||
     An internal 'field_div' method (similar to 'field_mul' and
 | 
			
		||||
     'field_sqr') has been added; this is used only for binary fields.
 | 
			
		||||
 | 
			
		||||
     [Sheueling Chang Shantz and Douglas Stebila
 | 
			
		||||
     (Sun Microsystems Laboratories)]
 | 
			
		||||
 | 
			
		||||
  *) Optionally dispatch EC_POINT_mul(), EC_POINT_precompute_mult()
 | 
			
		||||
     through methods ('mul', 'precompute_mult').
 | 
			
		||||
 | 
			
		||||
     The generic implementations (now internally called 'ec_wNAF_mul'
 | 
			
		||||
     and 'ec_wNAF_precomputed_mult') remain the default if these
 | 
			
		||||
     methods are undefined.
 | 
			
		||||
 | 
			
		||||
     [Sheueling Chang Shantz and Douglas Stebila
 | 
			
		||||
     (Sun Microsystems Laboratories)]
 | 
			
		||||
 | 
			
		||||
  *) New function EC_GROUP_get_degree, which is defined through
 | 
			
		||||
     EC_METHOD.  For curves over prime fields, this returns the bit
 | 
			
		||||
     length of the modulus.
 | 
			
		||||
 | 
			
		||||
     [Sheueling Chang Shantz and Douglas Stebila
 | 
			
		||||
     (Sun Microsystems Laboratories)]
 | 
			
		||||
 | 
			
		||||
  *) New functions EC_GROUP_dup, EC_POINT_dup.
 | 
			
		||||
     (These simply call ..._new  and ..._copy).
 | 
			
		||||
 | 
			
		||||
     [Sheueling Chang Shantz and Douglas Stebila
 | 
			
		||||
     (Sun Microsystems Laboratories)]
 | 
			
		||||
 | 
			
		||||
  *) Add binary polynomial arithmetic software in crypto/bn/bn_gf2m.c.
 | 
			
		||||
     Polynomials are represented as BIGNUMs (where the sign bit is not
 | 
			
		||||
     used) in the following functions [macros]:  
 | 
			
		||||
 | 
			
		||||
          BN_GF2m_add
 | 
			
		||||
          BN_GF2m_sub             [= BN_GF2m_add]
 | 
			
		||||
          BN_GF2m_mod             [wrapper for BN_GF2m_mod_arr]
 | 
			
		||||
          BN_GF2m_mod_mul         [wrapper for BN_GF2m_mod_mul_arr]
 | 
			
		||||
          BN_GF2m_mod_sqr         [wrapper for BN_GF2m_mod_sqr_arr]
 | 
			
		||||
          BN_GF2m_mod_inv
 | 
			
		||||
          BN_GF2m_mod_exp         [wrapper for BN_GF2m_mod_exp_arr]
 | 
			
		||||
          BN_GF2m_mod_sqrt        [wrapper for BN_GF2m_mod_sqrt_arr]
 | 
			
		||||
          BN_GF2m_mod_solve_quad  [wrapper for BN_GF2m_mod_solve_quad_arr]
 | 
			
		||||
          BN_GF2m_cmp             [= BN_ucmp]
 | 
			
		||||
 | 
			
		||||
     (Note that only the 'mod' functions are actually for fields GF(2^m).
 | 
			
		||||
     BN_GF2m_add() is misnomer, but this is for the sake of consistency.)
 | 
			
		||||
 | 
			
		||||
     For some functions, an the irreducible polynomial defining a
 | 
			
		||||
     field can be given as an 'unsigned int[]' with strictly
 | 
			
		||||
     decreasing elements giving the indices of those bits that are set;
 | 
			
		||||
     i.e., p[] represents the polynomial
 | 
			
		||||
          f(t) = t^p[0] + t^p[1] + ... + t^p[k]
 | 
			
		||||
     where
 | 
			
		||||
          p[0] > p[1] > ... > p[k] = 0.
 | 
			
		||||
     This applies to the following functions:
 | 
			
		||||
 | 
			
		||||
          BN_GF2m_mod_arr
 | 
			
		||||
          BN_GF2m_mod_mul_arr
 | 
			
		||||
          BN_GF2m_mod_sqr_arr
 | 
			
		||||
          BN_GF2m_mod_inv_arr        [wrapper for BN_GF2m_mod_inv]
 | 
			
		||||
          BN_GF2m_mod_div_arr        [wrapper for BN_GF2m_mod_div]
 | 
			
		||||
          BN_GF2m_mod_exp_arr
 | 
			
		||||
          BN_GF2m_mod_sqrt_arr
 | 
			
		||||
          BN_GF2m_mod_solve_quad_arr
 | 
			
		||||
          BN_GF2m_poly2arr
 | 
			
		||||
          BN_GF2m_arr2poly
 | 
			
		||||
 | 
			
		||||
     Conversion can be performed by the following functions:
 | 
			
		||||
 | 
			
		||||
          BN_GF2m_poly2arr
 | 
			
		||||
          BN_GF2m_arr2poly
 | 
			
		||||
 | 
			
		||||
     bntest.c has additional tests for binary polynomial arithmetic.
 | 
			
		||||
 | 
			
		||||
     Two implementations for BN_GF2m_mod_div() are available.
 | 
			
		||||
     The default algorithm simply uses BN_GF2m_mod_inv() and
 | 
			
		||||
     BN_GF2m_mod_mul().  The alternative algorithm is compiled in only
 | 
			
		||||
     if OPENSSL_SUN_GF2M_DIV is defined (patent pending; read the
 | 
			
		||||
     copyright notice in crypto/bn/bn_gf2m.c before enabling it).
 | 
			
		||||
 | 
			
		||||
     [Sheueling Chang Shantz and Douglas Stebila
 | 
			
		||||
     (Sun Microsystems Laboratories)]
 | 
			
		||||
 | 
			
		||||
  *) Add new error code 'ERR_R_DISABLED' that can be used when some
 | 
			
		||||
     functionality is disabled at compile-time.
 | 
			
		||||
     [Douglas Stebila <douglas.stebila@sun.com>]
 | 
			
		||||
 | 
			
		||||
  *) Change default behaviour of 'openssl asn1parse' so that more
 | 
			
		||||
     information is visible when viewing, e.g., a certificate:
 | 
			
		||||
 | 
			
		||||
     Modify asn1_parse2 (crypto/asn1/asn1_par.c) so that in non-'dump'
 | 
			
		||||
     mode the content of non-printable OCTET STRINGs is output in a
 | 
			
		||||
     style similar to INTEGERs, but with '[HEX DUMP]' prepended to
 | 
			
		||||
     avoid the appearance of a printable string.
 | 
			
		||||
     [Nils Larsch <nla@trustcenter.de>]
 | 
			
		||||
 | 
			
		||||
  *) Add 'asn1_flag' and 'asn1_form' member to EC_GROUP with access
 | 
			
		||||
     functions
 | 
			
		||||
          EC_GROUP_set_asn1_flag()
 | 
			
		||||
          EC_GROUP_get_asn1_flag()
 | 
			
		||||
          EC_GROUP_set_point_conversion_form()
 | 
			
		||||
          EC_GROUP_get_point_conversion_form()
 | 
			
		||||
     These control ASN1 encoding details:
 | 
			
		||||
     - Curves (i.e., groups) are encoded explicitly unless asn1_flag
 | 
			
		||||
       has been set to OPENSSL_EC_NAMED_CURVE.
 | 
			
		||||
     - Points are encoded in uncompressed form by default; options for
 | 
			
		||||
       asn1_for are as for point2oct, namely
 | 
			
		||||
          POINT_CONVERSION_COMPRESSED
 | 
			
		||||
          POINT_CONVERSION_UNCOMPRESSED
 | 
			
		||||
          POINT_CONVERSION_HYBRID
 | 
			
		||||
 | 
			
		||||
     Also add 'seed' and 'seed_len' members to EC_GROUP with access
 | 
			
		||||
     functions
 | 
			
		||||
          EC_GROUP_set_seed()
 | 
			
		||||
          EC_GROUP_get0_seed()
 | 
			
		||||
          EC_GROUP_get_seed_len()
 | 
			
		||||
     This is used only for ASN1 purposes (so far).
 | 
			
		||||
     [Nils Larsch <nla@trustcenter.de>]
 | 
			
		||||
 | 
			
		||||
  *) Add 'field_type' member to EC_METHOD, which holds the NID
 | 
			
		||||
     of the appropriate field type OID.  The new function
 | 
			
		||||
     EC_METHOD_get_field_type() returns this value.
 | 
			
		||||
     [Nils Larsch <nla@trustcenter.de>]
 | 
			
		||||
 | 
			
		||||
  *) Add functions 
 | 
			
		||||
          EC_POINT_point2bn()
 | 
			
		||||
          EC_POINT_bn2point()
 | 
			
		||||
          EC_POINT_point2hex()
 | 
			
		||||
          EC_POINT_hex2point()
 | 
			
		||||
     providing useful interfaces to EC_POINT_point2oct() and
 | 
			
		||||
     EC_POINT_oct2point().
 | 
			
		||||
     [Nils Larsch <nla@trustcenter.de>]
 | 
			
		||||
 | 
			
		||||
  *) Change internals of the EC library so that the functions
 | 
			
		||||
          EC_GROUP_set_generator()
 | 
			
		||||
          EC_GROUP_get_generator()
 | 
			
		||||
          EC_GROUP_get_order()
 | 
			
		||||
          EC_GROUP_get_cofactor()
 | 
			
		||||
     are implemented directly in crypto/ec/ec_lib.c and not dispatched
 | 
			
		||||
     to methods, which would lead to unnecessary code duplication when
 | 
			
		||||
     adding different types of curves.
 | 
			
		||||
     [Nils Larsch <nla@trustcenter.de> with input by Bodo Moeller]
 | 
			
		||||
 | 
			
		||||
  *) Implement compute_wNAF (crypto/ec/ec_mult.c) without BIGNUM
 | 
			
		||||
     arithmetic, and such that modified wNAFs are generated
 | 
			
		||||
     (which avoid length expansion in many cases).
 | 
			
		||||
     [Bodo Moeller]
 | 
			
		||||
 | 
			
		||||
  *) Add a function EC_GROUP_check_discriminant() (defined via
 | 
			
		||||
     EC_METHOD) that verifies that the curve discriminant is non-zero.
 | 
			
		||||
 | 
			
		||||
     Add a function EC_GROUP_check() that makes some sanity tests
 | 
			
		||||
     on a EC_GROUP, its generator and order.  This includes
 | 
			
		||||
     EC_GROUP_check_discriminant().
 | 
			
		||||
     [Nils Larsch <nla@trustcenter.de>]
 | 
			
		||||
 | 
			
		||||
  *) Add ECDSA in new directory crypto/ecdsa/.
 | 
			
		||||
 | 
			
		||||
     Add applications 'openssl ecparam' and 'openssl ecdsa'
 | 
			
		||||
     (these are based on 'openssl dsaparam' and 'openssl dsa').
 | 
			
		||||
 | 
			
		||||
     ECDSA support is also included in various other files across the
 | 
			
		||||
     library.  Most notably,
 | 
			
		||||
     - 'openssl req' now has a '-newkey ecdsa:file' option;
 | 
			
		||||
     - EVP_PKCS82PKEY (crypto/evp/evp_pkey.c) now can handle ECDSA;
 | 
			
		||||
     - X509_PUBKEY_get (crypto/asn1/x_pubkey.c) and
 | 
			
		||||
       d2i_PublicKey (crypto/asn1/d2i_pu.c) have been modified to make
 | 
			
		||||
       them suitable for ECDSA where domain parameters must be
 | 
			
		||||
       extracted before the specific public key;
 | 
			
		||||
     - ECDSA engine support has been added.
 | 
			
		||||
     [Nils Larsch <nla@trustcenter.de>]
 | 
			
		||||
 | 
			
		||||
  *) Include some named elliptic curves, and add OIDs from X9.62,
 | 
			
		||||
     SECG, and WAP/WTLS.  Each curve can be obtained from the new
 | 
			
		||||
     function
 | 
			
		||||
          EC_GROUP_new_by_nid(),
 | 
			
		||||
     and the list of available named curves can be obtained with
 | 
			
		||||
          EC_get_builtin_curves().
 | 
			
		||||
     Also add a 'curve_name' member to EC_GROUP objects, which can be
 | 
			
		||||
     accessed via
 | 
			
		||||
         EC_GROUP_set_nid()
 | 
			
		||||
         EC_GROUP_get_nid()
 | 
			
		||||
     [Nils Larsch <nla@trustcenter.de, Bodo Moeller]
 | 
			
		||||
 
 | 
			
		||||
  *) Remove a few calls to bn_wexpand() in BN_sqr() (the one in there
 | 
			
		||||
     was actually never needed) and in BN_mul().  The removal in BN_mul()
 | 
			
		||||
     required a small change in bn_mul_part_recursive() and the addition
 | 
			
		||||
     of the functions bn_cmp_part_words(), bn_sub_part_words() and
 | 
			
		||||
     bn_add_part_words(), which do the same thing as bn_cmp_words(),
 | 
			
		||||
     bn_sub_words() and bn_add_words() except they take arrays with
 | 
			
		||||
     differing sizes.
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
 | 
			
		||||
 Changes between 0.9.7b and 0.9.7c  [xx XXX 2003]
 | 
			
		||||
 | 
			
		||||
  *) New -ignore_err option in ocsp application to stop the server
 | 
			
		||||
     exiting on the first error in a request.
 | 
			
		||||
     [Steve Henson]
 | 
			
		||||
@@ -611,8 +82,11 @@
 | 
			
		||||
     between threads, blinding will still be very fast).
 | 
			
		||||
     [Bodo Moeller]
 | 
			
		||||
 | 
			
		||||
yet to be integrated into this CVS branch:
 | 
			
		||||
- Geoff's ENGINE_set_default() fix
 | 
			
		||||
  *) Fixed a typo bug that would cause ENGINE_set_default() to set an
 | 
			
		||||
     ENGINE as defaults for all supported algorithms irrespective of
 | 
			
		||||
     the 'flags' parameter. 'flags' is now honoured, so applications
 | 
			
		||||
     should make sure they are passing it correctly.
 | 
			
		||||
     [Geoff Thorpe]
 | 
			
		||||
 | 
			
		||||
  *) Target "mingw" now allows native Windows code to be generated in
 | 
			
		||||
     the Cygwin environment as well as with the MinGW compiler.
 | 
			
		||||
@@ -2522,7 +1996,17 @@ des-cbc           3624.96k     5258.21k     5530.91k     5624.30k     5628.26k
 | 
			
		||||
  *) Clean old EAY MD5 hack from e_os.h.
 | 
			
		||||
     [Richard Levitte]
 | 
			
		||||
 | 
			
		||||
 Changes between 0.9.6j and 0.9.6k  [xx XXX 2003]
 | 
			
		||||
 Changes between 0.9.6j and 0.9.6k  [30 Sep 2003]
 | 
			
		||||
 | 
			
		||||
  *) Fix various bugs revealed by running the NISCC test suite:
 | 
			
		||||
 | 
			
		||||
     Stop out of bounds reads in the ASN1 code when presented with
 | 
			
		||||
     invalid tags (CAN-2003-0543 and CAN-2003-0544).
 | 
			
		||||
     
 | 
			
		||||
     If verify callback ignores invalid public key errors don't try to check
 | 
			
		||||
     certificate signature with the NULL public key.
 | 
			
		||||
 | 
			
		||||
     [Steve Henson]
 | 
			
		||||
 | 
			
		||||
  *) In ssl3_accept() (ssl/s3_srvr.c) only accept a client certificate
 | 
			
		||||
     if the server requested one: as stated in TLS 1.0 and SSL 3.0
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										204
									
								
								Configure
									
									
									
									
									
								
							
							
						
						
									
										204
									
								
								Configure
									
									
									
									
									
								
							@@ -10,7 +10,7 @@ use strict;
 | 
			
		||||
 | 
			
		||||
# see INSTALL for instructions.
 | 
			
		||||
 | 
			
		||||
my $usage="Usage: Configure [no-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-engine] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-dso] [no-krb5] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--test-sanity] os/compiler[:flags]\n";
 | 
			
		||||
my $usage="Usage: Configure [no-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-engine] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-dso] [no-krb5] [386] [fips] [debug] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--test-sanity] os/compiler[:flags]\n";
 | 
			
		||||
 | 
			
		||||
# Options:
 | 
			
		||||
#
 | 
			
		||||
@@ -135,16 +135,17 @@ my %table=(
 | 
			
		||||
# Our development configs
 | 
			
		||||
"purify",	"purify gcc:-g -DPURIFY -Wall::(unknown)::-lsocket -lnsl::::",
 | 
			
		||||
"debug",	"gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror::(unknown)::-lefence::::",
 | 
			
		||||
"debug-ben",	"gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::asm/bn86-elf.o asm/co86-elf.o",
 | 
			
		||||
"debug-ben",	"gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -O2 -Wall -Wshadow -Werror -pipe::(unknown)::::asm/bn86-elf.o asm/co86-elf.o",
 | 
			
		||||
"debug-ben-openbsd","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::",
 | 
			
		||||
"debug-ben-openbsd-debug","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::",
 | 
			
		||||
"debug-ben-debug",	"gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::::",
 | 
			
		||||
"debug-ben-debug",	"gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -g3 -O2 -Wall -Wshadow -Werror -pipe::(unknown)::::::",
 | 
			
		||||
"debug-ben-strict",	"gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -pipe::(unknown)::::::",
 | 
			
		||||
"debug-ben-fips-debug","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DFIPS -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::asm/bn86-elf.o asm/co86-elf.o",
 | 
			
		||||
"debug-rse","cc:-DTERMIOS -DL_ENDIAN -pipe -O -g -ggdb3 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}",
 | 
			
		||||
"debug-bodo",	"gcc:-DL_ENDIAN -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DBIO_PAIR_DEBUG -DPEDANTIC -g -m486 -pedantic -Wshadow -Wall::-D_REENTRANT:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}",
 | 
			
		||||
"debug-ulf",	"gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -g -O2 -m486 -Wall -Werror -Wshadow -pipe::-D_REENTRANT:::${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}",
 | 
			
		||||
"debug-steve",	"gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG_ALL -DPEDANTIC -g -mcpu=i486 -pedantic -Wall -Werror -Wshadow -pipe::-D_REENTRANT::-rdynamic -ldl:${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared",
 | 
			
		||||
"debug-steve-linux-pseudo64",	"gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG_ALL -DOPENSSL_NO_ASM -g -mcpu=i486 -Wall -Werror -Wshadow -pipe::-D_REENTRANT::-rdynamic -ldl:SIXTY_FOUR_BIT::dlfcn:linux-shared",
 | 
			
		||||
"debug-steve",	"gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG_ALL -DPEDANTIC -g -mcpu=i486 -pedantic -Wall -Werror -Wshadow -pipe::-D_REENTRANT::-rdynamic -ldl:${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn",
 | 
			
		||||
"debug-steve-linux-pseudo64",	"gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG_ALL -DOPENSSL_NO_ASM -g -mcpu=i486 -Wall -Werror -Wshadow -pipe::-D_REENTRANT::-rdynamic -ldl:SIXTY_FOUR_BIT::dlfcn",
 | 
			
		||||
"debug-levitte-linux-elf","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"debug-levitte-linux-noasm","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"debug-levitte-linux-elf-extreme","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wconversion -Wno-long-long -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
@@ -168,17 +169,18 @@ my %table=(
 | 
			
		||||
 | 
			
		||||
#### SPARC Solaris with GNU C setups
 | 
			
		||||
"solaris-sparcv7-gcc","gcc:-O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::::::::::dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"solaris-sparcv8-gcc","gcc:-mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o:asm/des_enc-sparc.o fcrypt_b.o::::::::dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"solaris-sparcv8-gcc","gcc:-mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
# -m32 should be safe to add as long as driver recognizes -mcpu=ultrasparc
 | 
			
		||||
"solaris-sparcv9-gcc","gcc:-m32 -mcpu=ultrasparc -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:asm/des_enc-sparc.o fcrypt_b.o::asm/md5-sparcv8plus.o::::::dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"solaris-sparcv9-gcc","gcc:-m32 -mcpu=ultrasparc -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"solaris64-sparcv9-gcc31","gcc:-mcpu=ultrasparc -m64 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::asm/md5-sparcv9.o::::::dlfcn:solaris-shared:-fPIC:-m64 -shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
# gcc pre-2.8 doesn't understand -mcpu=ultrasparc, so fall down to -mv8
 | 
			
		||||
# but keep the assembler modules.
 | 
			
		||||
"solaris-sparcv9-gcc27","gcc:-mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus-gcc27.o:asm/des_enc-sparc.o fcrypt_b.o::asm/md5-sparcv8plus-gcc27.o::::::dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"solaris64-sparcv9-gcc","gcc:-m64 -mcpu=ultrasparc -O3 -Wall -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR::asm/des_enc-sparc.o fcrypt_b.o::asm/md5-sparcv9.o::::::dlfcn:solaris-shared:-fPIC:-m64 -shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"solaris-sparcv9-gcc27","gcc:-mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus-gcc27.o:::asm/md5-sparcv8plus-gcc27.o::::::dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"solaris64-sparcv9-gcc","gcc:-m64 -mcpu=ultrasparc -O3 -Wall -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::asm/md5-sparcv9.o::::::dlfcn:solaris-shared:-fPIC:-m64 -shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
 | 
			
		||||
####
 | 
			
		||||
"debug-solaris-sparcv8-gcc","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -O -g -mv8 -Wall -DB_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"debug-solaris-sparcv9-gcc","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -DPEDANTIC -O -g -mcpu=ultrasparc -pedantic -ansi -Wall -Wshadow -Wno-long-long -D__EXTENSIONS__ -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:asm/des_enc-sparc.o fcrypt_b.o::asm/md5-sparcv8plus.o::::::dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"debug-solaris-sparcv9-gcc","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -O -g -mcpu=ultrasparc -Wall -DB_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::::::::dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
 | 
			
		||||
#### SPARC Solaris with Sun C setups
 | 
			
		||||
# DO NOT use /xO[34] on sparc with SC3.0.  It is broken, and will not pass the tests
 | 
			
		||||
@@ -187,9 +189,9 @@ my %table=(
 | 
			
		||||
# SC4.2 is ok, better than gcc even on bn as long as you tell it -xarch=v8
 | 
			
		||||
# SC5.0 note: Compiler common patch 107357-01 or later is required!
 | 
			
		||||
"solaris-sparcv7-cc","cc:-xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::::::::dlfcn:solaris-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"solaris-sparcv8-cc","cc:-xarch=v8 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8.o:asm/des_enc-sparc.o fcrypt_b.o::::::::dlfcn:solaris-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"solaris-sparcv9-cc","cc:-xtarget=ultra -xarch=v8plus -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8plus.o:asm/des_enc-sparc.o fcrypt_b.o::asm/md5-sparcv8plus.o::::::dlfcn:solaris-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"solaris64-sparcv9-cc","cc:-xtarget=ultra -xarch=v9 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR::asm/des_enc-sparc.o fcrypt_b.o::asm/md5-sparcv9.o::::::dlfcn:solaris-shared:-KPIC:-xarch=v9:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):/usr/ccs/bin/ar rs",
 | 
			
		||||
"solaris-sparcv8-cc","cc:-xarch=v8 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:solaris-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"solaris-sparcv9-cc","cc:-xtarget=ultra -xarch=v8plus -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:solaris-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"solaris64-sparcv9-cc","cc:-xtarget=ultra -xarch=v9 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::asm/md5-sparcv9.o::::::dlfcn:solaris-shared:-KPIC:-xarch=v9:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):/usr/ccs/bin/ar rs",
 | 
			
		||||
####
 | 
			
		||||
"debug-solaris-sparcv8-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xarch=v8 -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:solaris-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"debug-solaris-sparcv9-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xtarget=ultra -xarch=v8plus -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:solaris-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
@@ -198,12 +200,12 @@ my %table=(
 | 
			
		||||
"linux-sparcv7","gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT:::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::",
 | 
			
		||||
# Ray Miller <ray.miller@computing-services.oxford.ac.uk> has patiently
 | 
			
		||||
# assisted with debugging of following two configs.
 | 
			
		||||
"linux-sparcv8","gcc:-mv8 -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -DBN_DIV2W::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o:asm/des_enc-sparc.o fcrypt_b.o::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"linux-sparcv8","gcc:-mv8 -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -DBN_DIV2W::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
# it's a real mess with -mcpu=ultrasparc option under Linux, but
 | 
			
		||||
# -Wa,-Av8plus should do the trick no matter what.
 | 
			
		||||
"linux-sparcv9","gcc:-mcpu=ultrasparc -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -Wa,-Av8plus -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:asm/des_enc-sparc.o fcrypt_b.o::asm/md5-sparcv8plus.o::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"linux-sparcv9","gcc:-mcpu=ultrasparc -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -Wa,-Av8plus -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
# GCC 3.1 is a requirement
 | 
			
		||||
"linux64-sparcv9","gcc:-m64 -mcpu=ultrasparc -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT:ULTRASPARC:-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::asm/des_enc-sparc.o fcrypt_b.o::asm/md5-sparcv9.o::::::dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"linux64-sparcv9","gcc:-m64 -mcpu=ultrasparc -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT:ULTRASPARC:-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::::asm/md5-sparcv9.o::::::dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
 | 
			
		||||
# Sunos configs, assuming sparc for the gcc one.
 | 
			
		||||
##"sunos-cc", "cc:-O4 -DNOPROTO -DNOCONST::(unknown):SUNOS::DES_UNROLL:::",
 | 
			
		||||
@@ -260,7 +262,7 @@ my %table=(
 | 
			
		||||
# Submitted by <ross.alexander@uk.neceur.com>
 | 
			
		||||
"hpux64-parisc-gcc","gcc:-DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT::::::::::dlfcn:hpux64-shared:-fpic::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
 | 
			
		||||
# HP/UX IA-64 targets
 | 
			
		||||
# IA-64 targets
 | 
			
		||||
"hpux-ia64-cc","cc:-Ae +DD32 +O3 +Olit=all -z -DB_ENDIAN::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:asm/ia64-cpp.o:::::::::dlfcn:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
# Frank Geurts <frank.geurts@nl.abnamro.com> has patiently assisted with
 | 
			
		||||
# with debugging of the following config.
 | 
			
		||||
@@ -373,7 +375,6 @@ my %table=(
 | 
			
		||||
 | 
			
		||||
# The intel boxes :-), It would be worth seeing if bsdi-gcc can use the
 | 
			
		||||
# bn86-elf.o file file since it is hand tweaked assembler.
 | 
			
		||||
"linux-ia32-icc",	"icc:-DL_ENDIAN -DTERMIO -O2::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"linux-elf",	"gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"linux-pentium",	"gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -mcpu=pentium -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"linux-ppro",	"gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -mcpu=pentiumpro -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
@@ -427,7 +428,7 @@ my %table=(
 | 
			
		||||
# compiler drivers and assemblers. Tim Rice <tim@multitalents.net> has
 | 
			
		||||
# patiently assisted to debug most of it.
 | 
			
		||||
#
 | 
			
		||||
# UnixWare 2.0x fails destest with -O.
 | 
			
		||||
# UnixWare 2.0x fails destest with -O
 | 
			
		||||
"unixware-2.0","cc:-DFILIO_H -DNO_STRINGS_H::-Kthread::-lsocket -lnsl -lresolv -lx:${x86_gcc_des} ${x86_gcc_opts}:::",
 | 
			
		||||
"unixware-2.1","cc:-O -DFILIO_H::-Kthread::-lsocket -lnsl -lresolv -lx:${x86_gcc_des} ${x86_gcc_opts}:::",
 | 
			
		||||
"unixware-7","cc:-O -DFILIO_H -Kalloca::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}:${x86_elf_asm}:dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
@@ -534,8 +535,8 @@ my %table=(
 | 
			
		||||
"OpenBSD-m88k",		"gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"OpenBSD-mips",		"gcc:-DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL DES_RISC2::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"OpenBSD-powerpc",	"gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"OpenBSD-sparc",	"gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL::asm/des_enc-sparc.o fcrypt_b.o::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"OpenBSD-sparc64",	"gcc:-DB_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer::(unknown):::SIXTY_FOUR_BIT_LONG DES_INT DES_PTR DES_RISC2 BF_PTR::asm/des_enc-sparc.o fcrypt_b.o::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"OpenBSD-sparc",	"gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"OpenBSD-sparc64",	"gcc:-DB_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer::(unknown):::SIXTY_FOUR_BIT_LONG DES_INT DES_PTR DES_RISC2 BF_PTR::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"OpenBSD-vax",		"gcc:-DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
"OpenBSD-hppa",		"gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 | 
			
		||||
 | 
			
		||||
@@ -560,6 +561,8 @@ my %table=(
 | 
			
		||||
"vxworks-ppc405","ccppc:-g -msoft-float -mlongcall -DCPU=PPC405 -I\$(WIND_BASE)/target/h:::VXWORKS:-r:::::",
 | 
			
		||||
"vxworks-ppc750","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h \$(DEBUG_FLAG):::VXWORKS:-r:::::",
 | 
			
		||||
"vxworks-ppc750-debug","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DDEBUG -g:::VXWORKS:-r:::::",
 | 
			
		||||
"vxworks-ppc860","ccppc:-nostdinc -msoft-float -DCPU=PPC860 -DNO_STRINGS_H -I\$(WIND_BASE)/target/h:::VXWORKS:-r:::::",
 | 
			
		||||
"vxworks-mipsle","ccmips:-B\$(WIND_BASE)/host/\$(WIND_HOST_TYPE)/lib/gcc-lib/ -DL_ENDIAN -EL -Wl,-EL -mips2 -mno-branch-likely -G 0 -fno-builtin -msoft-float -DCPU=MIPS32 -DMIPSEL -DNO_STRINGS_H -I\$(WIND_BASE)/target/h:::VXWORKS:-r::::::::::::::::ranlibmips:",
 | 
			
		||||
 | 
			
		||||
##### Compaq Non-Stop Kernel (Tandem)
 | 
			
		||||
"tandem-c89","c89:-Ww -D__TANDEM -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1 -D_TANDEM_SOURCE -DB_ENDIAN::(unknown):::THIRTY_TWO_BIT:::",
 | 
			
		||||
@@ -628,6 +631,8 @@ my $rmd160_obj="";
 | 
			
		||||
my $processor="";
 | 
			
		||||
my $default_ranlib;
 | 
			
		||||
my $perl;
 | 
			
		||||
my $fips=0;
 | 
			
		||||
my $debug=0;
 | 
			
		||||
 | 
			
		||||
my $no_ssl2=0;
 | 
			
		||||
my $no_ssl3=0;
 | 
			
		||||
@@ -688,7 +693,7 @@ PROCESS_ARGS:
 | 
			
		||||
		elsif (/^no-asm$/)
 | 
			
		||||
		 	{
 | 
			
		||||
			$no_asm=1;
 | 
			
		||||
			#$flags .= "-DOPENSSL_NO_ASM ";
 | 
			
		||||
			$flags .= "-DOPENSSL_NO_ASM ";
 | 
			
		||||
			$openssl_other_defines .= "#define OPENSSL_NO_ASM\n";
 | 
			
		||||
			}
 | 
			
		||||
		elsif (/^no-err$/)
 | 
			
		||||
@@ -700,12 +705,12 @@ PROCESS_ARGS:
 | 
			
		||||
			{
 | 
			
		||||
			my $hw=$1;
 | 
			
		||||
			$hw =~ tr/[a-z]/[A-Z]/;
 | 
			
		||||
			#$flags .= "-DOPENSSL_NO_HW_$hw ";
 | 
			
		||||
			$flags .= "-DOPENSSL_NO_HW_$hw ";
 | 
			
		||||
			$openssl_other_defines .= "#define OPENSSL_NO_HW_$hw\n";
 | 
			
		||||
			}
 | 
			
		||||
		elsif (/^no-hw$/)
 | 
			
		||||
			{
 | 
			
		||||
			#$flags .= "-DOPENSSL_NO_HW ";
 | 
			
		||||
			$flags .= "-DOPENSSL_NO_HW ";
 | 
			
		||||
			$openssl_other_defines .= "#define OPENSSL_NO_HW\n";
 | 
			
		||||
			}
 | 
			
		||||
		elsif (/^no-dso$/)
 | 
			
		||||
@@ -741,45 +746,24 @@ PROCESS_ARGS:
 | 
			
		||||
			my $algo=$1;
 | 
			
		||||
			push @skip,$algo;
 | 
			
		||||
			$algo =~ tr/[a-z]/[A-Z]/;
 | 
			
		||||
			#$flags .= "-DOPENSSL_NO_$algo ";
 | 
			
		||||
			#$depflags .= "-DOPENSSL_NO_$algo ";
 | 
			
		||||
			$flags .= "-DOPENSSL_NO_$algo ";
 | 
			
		||||
			$depflags .= "-DOPENSSL_NO_$algo ";
 | 
			
		||||
			$openssl_algorithm_defines .= "#define OPENSSL_NO_$algo\n";
 | 
			
		||||
			if ($algo eq "RIJNDAEL")
 | 
			
		||||
				{
 | 
			
		||||
				push @skip, "aes";
 | 
			
		||||
				#$flags .= "-DOPENSSL_NO_AES ";
 | 
			
		||||
				#$depflags .= "-DOPENSSL_NO_AES ";
 | 
			
		||||
				$flags .= "-DOPENSSL_NO_AES ";
 | 
			
		||||
				$depflags .= "-DOPENSSL_NO_AES ";
 | 
			
		||||
				$openssl_algorithm_defines .= "#define OPENSSL_NO_AES\n";
 | 
			
		||||
				}
 | 
			
		||||
			if ($algo eq "DES")
 | 
			
		||||
				{
 | 
			
		||||
				push @skip, "mdc2";
 | 
			
		||||
				$options .= " no-mdc2";
 | 
			
		||||
				#$flags .= "-DOPENSSL_NO_MDC2 ";
 | 
			
		||||
				#$depflags .= "-DOPENSSL_NO_MDC2 ";
 | 
			
		||||
				$flags .= "-DOPENSSL_NO_MDC2 ";
 | 
			
		||||
				$depflags .= "-DOPENSSL_NO_MDC2 ";
 | 
			
		||||
				$openssl_algorithm_defines .= "#define OPENSSL_NO_MDC2\n";
 | 
			
		||||
				}
 | 
			
		||||
			if ($algo eq "EC")
 | 
			
		||||
				{
 | 
			
		||||
				push @skip, "ecdsa";
 | 
			
		||||
				push @skip, "ecdh";
 | 
			
		||||
				$options .= " no-ecdsa";
 | 
			
		||||
				$options .= " no-ecdh";
 | 
			
		||||
				$flags .= "-DOPENSSL_NO_ECDSA ";
 | 
			
		||||
				$flags .= "-DOPENSSL_NO_ECDH ";
 | 
			
		||||
				$depflags .= "-DOPENSSL_NO_ECDSA ";
 | 
			
		||||
				$depflags .= "-DOPENSSL_NO_ECDH ";
 | 
			
		||||
				$openssl_algorithm_defines .= "#define OPENSSL_NO_ECDSA\n";
 | 
			
		||||
				$openssl_algorithm_defines .= "#define OPENSSL_NO_ECDH\n";
 | 
			
		||||
				}
 | 
			
		||||
			if ($algo eq "SHA" || $algo eq "SHA1")
 | 
			
		||||
				{
 | 
			
		||||
				push @skip, "ecdsa";
 | 
			
		||||
				$options .= " no-ecdsa";
 | 
			
		||||
				$flags .= "-DOPENSSL_NO_ECDSA ";
 | 
			
		||||
				$depflags .= "-DOPENSSL_NO_ECDSA ";
 | 
			
		||||
				$openssl_algorithm_defines .= "#define OPENSSL_NO_ECDSA\n";
 | 
			
		||||
				}
 | 
			
		||||
			if ($algo eq "MD5")
 | 
			
		||||
				{
 | 
			
		||||
				$no_md5 = 1;
 | 
			
		||||
@@ -822,6 +806,15 @@ PROCESS_ARGS:
 | 
			
		||||
			}
 | 
			
		||||
		elsif (/^386$/)
 | 
			
		||||
			{ $processor=386; }
 | 
			
		||||
		elsif (/^fips$/)
 | 
			
		||||
			{
 | 
			
		||||
			$fips=1;
 | 
			
		||||
			$openssl_other_defines.="#define OPENSSL_FIPS\n";
 | 
			
		||||
		        }
 | 
			
		||||
		elsif (/^debug$/)
 | 
			
		||||
			{
 | 
			
		||||
			$debug=1;
 | 
			
		||||
			}
 | 
			
		||||
		elsif (/^rsaref$/)
 | 
			
		||||
			{
 | 
			
		||||
			# No RSAref support any more since it's not needed.
 | 
			
		||||
@@ -892,24 +885,24 @@ $no_tls1=1 if ($no_dh);
 | 
			
		||||
if ($no_ssl2)
 | 
			
		||||
	{
 | 
			
		||||
	push @skip,"SSL2";
 | 
			
		||||
	#$flags .= "-DOPENSSL_NO_SSL2 ";
 | 
			
		||||
	#$depflags .= "-DOPENSSL_NO_SSL2 ";
 | 
			
		||||
	$flags .= "-DOPENSSL_NO_SSL2 ";
 | 
			
		||||
	$depflags .= "-DOPENSSL_NO_SSL2 ";
 | 
			
		||||
	$openssl_algorithm_defines .= "#define OPENSSL_NO_SSL2\n";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
if ($no_ssl3)
 | 
			
		||||
	{
 | 
			
		||||
	push @skip,"SSL3";
 | 
			
		||||
	#$flags .= "-DOPENSSL_NO_SSL3 ";
 | 
			
		||||
	#$depflags .= "-DOPENSSL_NO_SSL3 ";
 | 
			
		||||
	$flags .= "-DOPENSSL_NO_SSL3 ";
 | 
			
		||||
	$depflags .= "-DOPENSSL_NO_SSL3 ";
 | 
			
		||||
	$openssl_algorithm_defines .= "#define OPENSSL_NO_SSL3\n";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
if ($no_tls1)
 | 
			
		||||
	{
 | 
			
		||||
	push @skip,"TLS1";
 | 
			
		||||
	#$flags .= "-DOPENSSL_NO_TLS1 ";
 | 
			
		||||
	#$depflags .= "-DOPENSSL_NO_TLS1 ";
 | 
			
		||||
	$flags .= "-DOPENSSL_NO_TLS1 ";
 | 
			
		||||
	$depflags .= "-DOPENSSL_NO_TLS1 ";
 | 
			
		||||
	$openssl_algorithm_defines .= "#define OPENSSL_NO_TLS1\n";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -987,7 +980,7 @@ if ($no_krb5
 | 
			
		||||
	|| !defined($withargs{"krb5-flavor"})
 | 
			
		||||
	|| $withargs{"krb5-flavor"} eq "")
 | 
			
		||||
	{
 | 
			
		||||
	#$cflags="-DOPENSSL_NO_KRB5 $cflags";
 | 
			
		||||
	$cflags="-DOPENSSL_NO_KRB5 $cflags";
 | 
			
		||||
	$options.=" no-krb5" unless $no_krb5;
 | 
			
		||||
	$openssl_algorithm_defines .= "#define OPENSSL_NO_KRB5\n";
 | 
			
		||||
	}
 | 
			
		||||
@@ -1113,7 +1106,7 @@ if (!$no_shared)
 | 
			
		||||
 | 
			
		||||
if ($threads)
 | 
			
		||||
	{
 | 
			
		||||
	#$cflags=$thread_cflags;
 | 
			
		||||
	$cflags=$thread_cflags;
 | 
			
		||||
	$openssl_thread_defines .= $thread_defines;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -1135,24 +1128,13 @@ if (!$no_shared)
 | 
			
		||||
	{
 | 
			
		||||
	if ($shared_cflag ne "")
 | 
			
		||||
		{
 | 
			
		||||
		$cflags = "$shared_cflag -DOPENSSL_PIC $cflags";
 | 
			
		||||
		$cflags = "$shared_cflag $cflags";
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
if ($no_shared)
 | 
			
		||||
	{
 | 
			
		||||
	#$cflags="-DOPENSSL_NO_DYNAMIC_ENGINE $cflags";
 | 
			
		||||
	$openssl_other_defines.="#define OPENSSL_NO_DYNAMIC_ENGINE\n";
 | 
			
		||||
	}
 | 
			
		||||
else
 | 
			
		||||
	{
 | 
			
		||||
	#$cflags="-DOPENSSL_NO_STATIC_ENGINE $cflags";
 | 
			
		||||
	$openssl_other_defines.="#define OPENSSL_NO_STATIC_ENGINE\n";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
if ($sys_id ne "")
 | 
			
		||||
	{
 | 
			
		||||
	#$cflags="-DOPENSSL_SYSNAME_$sys_id $cflags";
 | 
			
		||||
	$cflags="-DOPENSSL_SYSNAME_$sys_id $cflags";
 | 
			
		||||
	$openssl_sys_defines="#define OPENSSL_SYSNAME_$sys_id\n";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -1167,10 +1149,12 @@ if ($ranlib eq "")
 | 
			
		||||
#$bn_obj="$bn1";
 | 
			
		||||
 | 
			
		||||
$bn_obj = $bn_asm unless $bn_obj ne "";
 | 
			
		||||
# bn86* is the only one implementing bn_*_part_words
 | 
			
		||||
$cflags.=" -DOPENSSL_BN_ASM_PART_WORDS" if ($bn_obj =~ /bn86/);
 | 
			
		||||
 | 
			
		||||
$des_obj=$des_enc	unless ($des_obj =~ /\.o$/);
 | 
			
		||||
if ($fips)
 | 
			
		||||
	{
 | 
			
		||||
	$des_obj=$sha1_obj="";
 | 
			
		||||
	}
 | 
			
		||||
$des_obj=$des_enc	unless (!$fips && $des_obj =~ /\.o$/);
 | 
			
		||||
$bf_obj=$bf_enc		unless ($bf_obj =~ /\.o$/);
 | 
			
		||||
$cast_obj=$cast_enc	unless ($cast_obj =~ /\.o$/);
 | 
			
		||||
$rc4_obj=$rc4_enc	unless ($rc4_obj =~ /\.o$/);
 | 
			
		||||
@@ -1191,12 +1175,17 @@ if ($rmd160_obj =~ /\.o$/)
 | 
			
		||||
	$cflags.=" -DRMD160_ASM";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
if ($debug)
 | 
			
		||||
	{
 | 
			
		||||
	$cflags.=" -g";
 | 
			
		||||
	$cflags=~s/-fomit-frame-pointer//;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
# "Stringify" the C flags string.  This permits it to be made part of a string
 | 
			
		||||
# and works as well on command lines.
 | 
			
		||||
$cflags =~ s/([\\\"])/\\\1/g;
 | 
			
		||||
 | 
			
		||||
my $version = "unknown";
 | 
			
		||||
my $version_num = "unknown";
 | 
			
		||||
my $major = "unknown";
 | 
			
		||||
my $minor = "unknown";
 | 
			
		||||
my $shlib_version_number = "unknown";
 | 
			
		||||
@@ -1208,7 +1197,6 @@ open(IN,'<crypto/opensslv.h') || die "unable to read opensslv.h:$!\n";
 | 
			
		||||
while (<IN>)
 | 
			
		||||
	{
 | 
			
		||||
	$version=$1 if /OPENSSL.VERSION.TEXT.*OpenSSL (\S+) /;
 | 
			
		||||
	$version_num=$1 if /OPENSSL.VERSION.NUMBER.*0x(\S+)/;
 | 
			
		||||
	$shlib_version_number=$1 if /SHLIB_VERSION_NUMBER *"([^"]+)"/;
 | 
			
		||||
	$shlib_version_history=$1 if /SHLIB_VERSION_HISTORY *"([^"]*)"/;
 | 
			
		||||
	}
 | 
			
		||||
@@ -1539,68 +1527,6 @@ EOF
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# create the ms/version32.rc file if needed
 | 
			
		||||
if ($IsWindows) {
 | 
			
		||||
	my ($v1, $v2, $v3, $v4);
 | 
			
		||||
	if ($version_num =~ /(^[0-9a-f]{1})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i) {
 | 
			
		||||
		$v1=hex $1;
 | 
			
		||||
		$v2=hex $2;
 | 
			
		||||
		$v3=hex $3;
 | 
			
		||||
		$v4=hex $4;
 | 
			
		||||
	}
 | 
			
		||||
	open (OUT,">ms/version32.rc") || die "Can't open ms/version32.rc";
 | 
			
		||||
	print OUT <<EOF;
 | 
			
		||||
#include <winver.h>
 | 
			
		||||
 | 
			
		||||
LANGUAGE 0x09,0x01
 | 
			
		||||
 | 
			
		||||
1 VERSIONINFO
 | 
			
		||||
  FILEVERSION $v1,$v2,$v3,$v4
 | 
			
		||||
  PRODUCTVERSION $v1,$v2,$v3,$v4
 | 
			
		||||
  FILEFLAGSMASK 0x3fL
 | 
			
		||||
#ifdef _DEBUG
 | 
			
		||||
  FILEFLAGS 0x01L
 | 
			
		||||
#else
 | 
			
		||||
  FILEFLAGS 0x00L
 | 
			
		||||
#endif
 | 
			
		||||
  FILEOS VOS__WINDOWS32
 | 
			
		||||
  FILETYPE VFT_DLL
 | 
			
		||||
  FILESUBTYPE 0x0L
 | 
			
		||||
BEGIN
 | 
			
		||||
    BLOCK "StringFileInfo"
 | 
			
		||||
    BEGIN
 | 
			
		||||
	BLOCK "040904b0"
 | 
			
		||||
	BEGIN
 | 
			
		||||
	    // Required:	    
 | 
			
		||||
	    VALUE "CompanyName", "The OpenSSL Project, http://www.openssl.org/\\0"
 | 
			
		||||
	    VALUE "FileDescription", "OpenSSL Shared Library\\0"
 | 
			
		||||
	    VALUE "FileVersion", "$version\\0"
 | 
			
		||||
#if defined(CRYPTO)
 | 
			
		||||
	    VALUE "InternalName", "libeay32\\0"
 | 
			
		||||
	    VALUE "OriginalFilename", "libeay32.dll\\0"
 | 
			
		||||
#elif defined(SSL)
 | 
			
		||||
	    VALUE "InternalName", "ssleay32\\0"
 | 
			
		||||
	    VALUE "OriginalFilename", "ssleay32.dll\\0"
 | 
			
		||||
#endif
 | 
			
		||||
	    VALUE "ProductName", "The OpenSSL Toolkit\\0"
 | 
			
		||||
	    VALUE "ProductVersion", "$version\\0"
 | 
			
		||||
	    // Optional:
 | 
			
		||||
	    //VALUE "Comments", "\\0"
 | 
			
		||||
	    VALUE "LegalCopyright", "Copyright <20> 1998-2002 The OpenSSL Project. Copyright <20> 1995-1998 Eric A. Young, Tim J. Hudson. All rights reserved.\\0"
 | 
			
		||||
	    //VALUE "LegalTrademarks", "\\0"
 | 
			
		||||
	    //VALUE "PrivateBuild", "\\0"
 | 
			
		||||
	    //VALUE "SpecialBuild", "\\0"
 | 
			
		||||
	END
 | 
			
		||||
    END
 | 
			
		||||
    BLOCK "VarFileInfo"
 | 
			
		||||
    BEGIN
 | 
			
		||||
        VALUE "Translation", 0x409, 0x4b0
 | 
			
		||||
    END
 | 
			
		||||
END
 | 
			
		||||
EOF
 | 
			
		||||
	close(OUT);
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
print <<EOF;
 | 
			
		||||
 | 
			
		||||
Configured for $target.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								FAQ
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								FAQ
									
									
									
									
									
								
							@@ -68,7 +68,7 @@ OpenSSL  -  Frequently Asked Questions
 | 
			
		||||
* Which is the current version of OpenSSL?
 | 
			
		||||
 | 
			
		||||
The current version is available from <URL: http://www.openssl.org>.
 | 
			
		||||
OpenSSL 0.9.7a was released on February 19, 2003.
 | 
			
		||||
OpenSSL 0.9.7c was released on September 30, 2003.
 | 
			
		||||
 | 
			
		||||
In addition to the current stable release, you can also access daily
 | 
			
		||||
snapshots of the OpenSSL development version at <URL:
 | 
			
		||||
 
 | 
			
		||||
@@ -225,7 +225,7 @@
 | 
			
		||||
	$ md c:\openssl\lib
 | 
			
		||||
	$ md c:\openssl\include
 | 
			
		||||
	$ md c:\openssl\include\openssl
 | 
			
		||||
	$ copy /b inc32\*               c:\openssl\include\openssl
 | 
			
		||||
	$ copy /b inc32\openssl\*       c:\openssl\include\openssl
 | 
			
		||||
	$ copy /b out32dll\ssleay32.lib c:\openssl\lib
 | 
			
		||||
	$ copy /b out32dll\libeay32.lib c:\openssl\lib
 | 
			
		||||
	$ copy /b out32dll\ssleay32.dll c:\openssl\bin
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										420
									
								
								Makefile.org
									
									
									
									
									
								
							
							
						
						
									
										420
									
								
								Makefile.org
									
									
									
									
									
								
							@@ -169,25 +169,29 @@ RMD160_ASM_OBJ= asm/rm86-out.o
 | 
			
		||||
KRB5_INCLUDES=
 | 
			
		||||
LIBKRB5=
 | 
			
		||||
 | 
			
		||||
DIRS=   crypto ssl engines apps test tools
 | 
			
		||||
SHLIBDIRS= crypto ssl
 | 
			
		||||
# When we're prepared to use shared libraries in the programs we link here
 | 
			
		||||
# we might set SHLIB_MARK to '$(SHARED_LIBS)'.
 | 
			
		||||
SHLIB_MARK=
 | 
			
		||||
 | 
			
		||||
DIRS=   crypto fips ssl $(SHLIB_MARK) sigs apps test tools
 | 
			
		||||
SHLIBDIRS= fips crypto ssl
 | 
			
		||||
 | 
			
		||||
# dirs in crypto to build
 | 
			
		||||
SDIRS=  \
 | 
			
		||||
SDIRS=  objects \
 | 
			
		||||
	md2 md4 md5 sha mdc2 hmac ripemd \
 | 
			
		||||
	des rc2 rc4 rc5 idea bf cast \
 | 
			
		||||
	bn ec rsa dsa ecdsa dh ecdh dso engine aes \
 | 
			
		||||
	buffer bio stack lhash rand err objects \
 | 
			
		||||
	evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 \
 | 
			
		||||
	store
 | 
			
		||||
	bn ec rsa dsa dh dso engine aes \
 | 
			
		||||
	buffer bio stack lhash rand err \
 | 
			
		||||
	evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5
 | 
			
		||||
 | 
			
		||||
FDIRS=	sha1 rand des aes dsa rsa
 | 
			
		||||
 | 
			
		||||
# tests to perform.  "alltests" is a special word indicating that all tests
 | 
			
		||||
# should be performed.
 | 
			
		||||
TESTS = alltests
 | 
			
		||||
 | 
			
		||||
MAKEFILE= Makefile.ssl
 | 
			
		||||
NEWMAKE=  make
 | 
			
		||||
MAKE=     $(NEWMAKE) -f Makefile.ssl
 | 
			
		||||
MAKE=     make -f Makefile.ssl
 | 
			
		||||
 | 
			
		||||
MANDIR=$(OPENSSLDIR)/man
 | 
			
		||||
MAN1=1
 | 
			
		||||
@@ -200,6 +204,7 @@ ONEDIRS=out tmp
 | 
			
		||||
EDIRS=  times doc bugs util include certs ms shlib mt demos perl sf dep VMS
 | 
			
		||||
WDIRS=  windows
 | 
			
		||||
LIBS=   libcrypto.a libssl.a
 | 
			
		||||
SIGS=	libcrypto.sha1
 | 
			
		||||
SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
 | 
			
		||||
SHARED_SSL=libssl$(SHLIB_EXT)
 | 
			
		||||
SHARED_LIBS=
 | 
			
		||||
@@ -214,33 +219,38 @@ WTARFILE=       $(NAME)-win.tar
 | 
			
		||||
EXHEADER=       e_os2.h
 | 
			
		||||
HEADER=         e_os.h
 | 
			
		||||
 | 
			
		||||
all: Makefile.ssl build_all openssl.pc
 | 
			
		||||
# When we're prepared to use shared libraries in the programs we link here
 | 
			
		||||
# we might remove 'clean-shared' from the targets to perform at this stage
 | 
			
		||||
 | 
			
		||||
BUILD_CMD=if echo " $(DIRS) " | grep " $$i " >/dev/null 2>/dev/null; then \
 | 
			
		||||
all: Makefile.ssl sub_all openssl.pc
 | 
			
		||||
 | 
			
		||||
sigs:	$(SIGS)
 | 
			
		||||
libcrypto.sha1: libcrypto.a
 | 
			
		||||
	if egrep 'define OPENSSL_FIPS' $(TOP)/include/openssl/opensslconf.h > /dev/null; then \
 | 
			
		||||
		fips/sha1/fips_standalone_sha1 libcrypto.a > libcrypto.sha1; \
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
sub_all:
 | 
			
		||||
	@for i in $(DIRS); \
 | 
			
		||||
	do \
 | 
			
		||||
	if [ -d "$$i" ]; then \
 | 
			
		||||
		(cd $$i && echo "making all in $$i..." && \
 | 
			
		||||
		$(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' AS='${AS}' ASFLAG='${ASFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' all ) || exit 1; \
 | 
			
		||||
		$(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' AS='${AS}' ASFLAG='${ASFLAG}' SDIRS='$(SDIRS)' FDIRS='$(FDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' all ) || exit 1; \
 | 
			
		||||
	else \
 | 
			
		||||
		$(MAKE) $$i; \
 | 
			
		||||
	fi; fi
 | 
			
		||||
	fi; \
 | 
			
		||||
	done;
 | 
			
		||||
 | 
			
		||||
sub_all: build_all
 | 
			
		||||
build_all: build_libs build_apps build_tests build_tools
 | 
			
		||||
 | 
			
		||||
build_libs: build_crypto build_ssl build_engines
 | 
			
		||||
 | 
			
		||||
build_crypto:
 | 
			
		||||
	@i=crypto; $(BUILD_CMD)
 | 
			
		||||
build_ssl:
 | 
			
		||||
	@i=ssl; $(BUILD_CMD)
 | 
			
		||||
build_engines:
 | 
			
		||||
	@i=engines; $(BUILD_CMD)
 | 
			
		||||
build_apps:
 | 
			
		||||
	@i=apps; $(BUILD_CMD)
 | 
			
		||||
build_tests:
 | 
			
		||||
	@i=test; $(BUILD_CMD)
 | 
			
		||||
build_tools:
 | 
			
		||||
	@i=tools; $(BUILD_CMD)
 | 
			
		||||
sub_target:
 | 
			
		||||
	@for i in $(DIRS); \
 | 
			
		||||
	do \
 | 
			
		||||
	if [ -d "$$i" ]; then \
 | 
			
		||||
		(cd $$i && echo "making $(TARGET) in $$i..." && \
 | 
			
		||||
		$(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' AS='${AS}' ASFLAG='${ASFLAG}' SDIRS='$(SDIRS)' FDIRS='$(FDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' TARGET='$(TARGET)' sub_target ) || exit 1; \
 | 
			
		||||
	else \
 | 
			
		||||
		$(MAKE) $$i; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	done;
 | 
			
		||||
 | 
			
		||||
libcrypto$(SHLIB_EXT): libcrypto.a
 | 
			
		||||
	@if [ "$(SHLIB_TARGET)" != "" ]; then \
 | 
			
		||||
@@ -266,34 +276,322 @@ clean-shared:
 | 
			
		||||
		fi; \
 | 
			
		||||
		( set -x; rm -f lib$$i$(SHLIB_EXT) ); \
 | 
			
		||||
		if [ "$(PLATFORM)" = "Cygwin" ]; then \
 | 
			
		||||
			( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
 | 
			
		||||
			( set -x; rm -f cyg$$i-$(SHLIB_VERSION_NUMBER)$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
 | 
			
		||||
		fi; \
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
link-shared:
 | 
			
		||||
	@ for i in ${SHLIBDIRS}; do \
 | 
			
		||||
		$(NEWMAKE) -f $(HERE)/Makefile.shared \
 | 
			
		||||
			LIBNAME=$$i LIBVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
			LIBCOMPATVERSIONS=";${SHLIB_VERSION_HISTORY}" \
 | 
			
		||||
			symlink.$(SHLIB_TARGET); \
 | 
			
		||||
		libs="$$libs -l$$i"; \
 | 
			
		||||
	done
 | 
			
		||||
	@if [ -n "$(SHARED_LIBS_LINK_EXTS)" ]; then \
 | 
			
		||||
		tmp="$(SHARED_LIBS_LINK_EXTS)"; \
 | 
			
		||||
		for i in $(SHLIBDIRS); do \
 | 
			
		||||
			prev=lib$$i$(SHLIB_EXT); \
 | 
			
		||||
			for j in $${tmp:-x}; do \
 | 
			
		||||
				( set -x; \
 | 
			
		||||
				rm -f lib$$i$$j; ln -s $$prev lib$$i$$j ); \
 | 
			
		||||
				prev=lib$$i$$j; \
 | 
			
		||||
			done; \
 | 
			
		||||
		done; \
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
build-shared: do_$(SHLIB_TARGET) link-shared
 | 
			
		||||
build-shared: clean-shared do_$(SHLIB_TARGET) link-shared
 | 
			
		||||
 | 
			
		||||
do_$(SHLIB_TARGET):
 | 
			
		||||
	@ libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
			
		||||
do_bsd-gcc-shared: do_gnu-shared
 | 
			
		||||
do_linux-shared: do_gnu-shared
 | 
			
		||||
do_gnu-shared:
 | 
			
		||||
	libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
			
		||||
	if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
 | 
			
		||||
		libs="$(LIBKRB5) $$libs"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
		$(NEWMAKE) -f Makefile.shared \
 | 
			
		||||
			CC="$(CC)" LDFLAGS="$(LDFLAGS)" \
 | 
			
		||||
			SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
 | 
			
		||||
			LIBNAME=$$i LIBVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
			LIBCOMPATVERSIONS=";${SHLIB_VERSION_HISTORY}" \
 | 
			
		||||
			LIBDEPS="$$libs $(EX_LIBS)" \
 | 
			
		||||
			LIBRPATH="$(INSTALLTOP)/lib" \
 | 
			
		||||
			link_a.$(SHLIB_TARGET); \
 | 
			
		||||
	( set -x; ${CC} ${SHARED_LDFLAGS} \
 | 
			
		||||
		-shared -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
		-Wl,-soname=lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
		-Wl,-Bsymbolic \
 | 
			
		||||
		-Wl,--whole-archive lib$$i.a \
 | 
			
		||||
		-Wl,--no-whole-archive $$libs ${EX_LIBS} -lc ) || exit 1; \
 | 
			
		||||
	libs="-l$$i $$libs"; \
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
DETECT_GNU_LD=(${CC} -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null
 | 
			
		||||
 | 
			
		||||
# For Darwin AKA Mac OS/X (dyld)
 | 
			
		||||
do_darwin-shared: 
 | 
			
		||||
	libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
			
		||||
	if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
 | 
			
		||||
		libs="$(LIBKRB5) $$libs"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	( set -x; ${CC} --verbose -dynamiclib -o lib$$i${SHLIB_EXT} \
 | 
			
		||||
		lib$$i.a $$libs -all_load -current_version ${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
		-compatibility_version ${SHLIB_MAJOR}.`echo ${SHLIB_MINOR} | cut -d. -f1` \
 | 
			
		||||
		-install_name ${INSTALLTOP}/lib/lib$$i${SHLIB_EXT} ) || exit 1; \
 | 
			
		||||
	libs="-l`basename $$i${SHLIB_EXT} .dylib` $$libs"; \
 | 
			
		||||
	echo "" ; \
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
do_cygwin-shared:
 | 
			
		||||
	libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
			
		||||
	if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
 | 
			
		||||
		libs="$(LIBKRB5) $$libs"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	( set -x; ${CC}  -shared -o cyg$$i-$(SHLIB_VERSION_NUMBER).dll \
 | 
			
		||||
		-Wl,-Bsymbolic \
 | 
			
		||||
		-Wl,--whole-archive lib$$i.a \
 | 
			
		||||
		-Wl,--out-implib,lib$$i.dll.a \
 | 
			
		||||
		-Wl,--no-whole-archive $$libs ) || exit 1; \
 | 
			
		||||
	libs="-l$$i $$libs"; \
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
# This assumes that GNU utilities are *not* used
 | 
			
		||||
do_alpha-osf1-shared:
 | 
			
		||||
	if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(MAKE) do_gnu-shared; \
 | 
			
		||||
	else \
 | 
			
		||||
		libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
			
		||||
		if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
 | 
			
		||||
			libs="$(LIBKRB5) $$libs"; \
 | 
			
		||||
		fi; \
 | 
			
		||||
		( set -x; ${CC} ${SHARED_LDFLAGS} \
 | 
			
		||||
			-shared -o lib$$i.so \
 | 
			
		||||
			-set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \
 | 
			
		||||
			-all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \
 | 
			
		||||
		libs="-l$$i $$libs"; \
 | 
			
		||||
		done; \
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
# This assumes that GNU utilities are *not* used
 | 
			
		||||
# The difference between alpha-osf1-shared and tru64-shared is the `-msym'
 | 
			
		||||
# option passed to the linker.
 | 
			
		||||
do_tru64-shared:
 | 
			
		||||
	if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(MAKE) do_gnu-shared; \
 | 
			
		||||
	else \
 | 
			
		||||
		libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
			
		||||
		if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
 | 
			
		||||
			libs="$(LIBKRB5) $$libs"; \
 | 
			
		||||
		fi; \
 | 
			
		||||
		( set -x; ${CC} ${SHARED_LDFLAGS} \
 | 
			
		||||
			-shared -msym -o lib$$i.so \
 | 
			
		||||
			-set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \
 | 
			
		||||
			-all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \
 | 
			
		||||
		libs="-l$$i $$libs"; \
 | 
			
		||||
		done; \
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
# This assumes that GNU utilities are *not* used
 | 
			
		||||
# The difference between tru64-shared and tru64-shared-rpath is the
 | 
			
		||||
# -rpath ${INSTALLTOP}/lib passed to the linker.
 | 
			
		||||
do_tru64-shared-rpath:
 | 
			
		||||
	if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(MAKE) do_gnu-shared; \
 | 
			
		||||
	else \
 | 
			
		||||
		libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
			
		||||
		if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
 | 
			
		||||
			libs="$(LIBKRB5) $$libs"; \
 | 
			
		||||
		fi; \
 | 
			
		||||
		( set -x; ${CC} ${SHARED_LDFLAGS} \
 | 
			
		||||
			-shared -msym -o lib$$i.so \
 | 
			
		||||
			-rpath  ${INSTALLTOP}/lib \
 | 
			
		||||
			-set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \
 | 
			
		||||
			-all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \
 | 
			
		||||
		libs="-l$$i $$libs"; \
 | 
			
		||||
		done; \
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# This assumes that GNU utilities are *not* used
 | 
			
		||||
do_solaris-shared:
 | 
			
		||||
	if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(MAKE) do_gnu-shared; \
 | 
			
		||||
	else \
 | 
			
		||||
		libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
			
		||||
		if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
 | 
			
		||||
			libs="$(LIBKRB5) $$libs"; \
 | 
			
		||||
		fi; \
 | 
			
		||||
		( PATH=/usr/ccs/bin:$$PATH ; export PATH; \
 | 
			
		||||
		  MINUSZ='-z '; \
 | 
			
		||||
		  (${CC} -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
 | 
			
		||||
		  set -x; ${CC} ${SHARED_LDFLAGS} -G -dy -z text \
 | 
			
		||||
			-o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
			-h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
			$${MINUSZ}allextract lib$$i.a $${MINUSZ}defaultextract \
 | 
			
		||||
			$$libs ${EX_LIBS} -lc ) || exit 1; \
 | 
			
		||||
		libs="-l$$i $$libs"; \
 | 
			
		||||
		done; \
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
# OpenServer 5 native compilers used
 | 
			
		||||
do_svr3-shared:
 | 
			
		||||
	if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(MAKE) do_gnu-shared; \
 | 
			
		||||
	else \
 | 
			
		||||
		libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
			
		||||
		if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
 | 
			
		||||
			libs="$(LIBKRB5) $$libs"; \
 | 
			
		||||
		fi; \
 | 
			
		||||
		( PATH=/usr/ccs/bin:$$PATH ; export PATH; \
 | 
			
		||||
		  find . -name "*.o" -print > allobjs ; \
 | 
			
		||||
		  OBJS= ; export OBJS ; \
 | 
			
		||||
		  for obj in `ar t lib$$i.a` ; do \
 | 
			
		||||
		    OBJS="$${OBJS} `grep /$$obj allobjs`" ; \
 | 
			
		||||
		  done ; \
 | 
			
		||||
		  set -x; ${CC} ${SHARED_LDFLAGS} \
 | 
			
		||||
			-G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
			-h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
			$${OBJS} $$libs ${EX_LIBS} ) || exit 1; \
 | 
			
		||||
		libs="-l$$i $$libs"; \
 | 
			
		||||
		done; \
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
# UnixWare 7 and OpenUNIX 8 native compilers used
 | 
			
		||||
do_svr5-shared:
 | 
			
		||||
	if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(MAKE) do_gnu-shared; \
 | 
			
		||||
	else \
 | 
			
		||||
		libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
			
		||||
		if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
 | 
			
		||||
			libs="$(LIBKRB5) $$libs"; \
 | 
			
		||||
		fi; \
 | 
			
		||||
		( PATH=/usr/ccs/bin:$$PATH ; export PATH; \
 | 
			
		||||
		  SHARE_FLAG='-G'; \
 | 
			
		||||
		  (${CC} -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
 | 
			
		||||
		  find . -name "*.o" -print > allobjs ; \
 | 
			
		||||
		  OBJS= ; export OBJS ; \
 | 
			
		||||
		  for obj in `ar t lib$$i.a` ; do \
 | 
			
		||||
		    OBJS="$${OBJS} `grep /$$obj allobjs`" ; \
 | 
			
		||||
		  done ; \
 | 
			
		||||
		  set -x; LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH \
 | 
			
		||||
			${CC} ${SHARED_LDFLAGS} \
 | 
			
		||||
			$${SHARE_FLAG} -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
			-h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
			$${OBJS} $$libs ${EX_LIBS} ) || exit 1; \
 | 
			
		||||
		libs="-l$$i $$libs"; \
 | 
			
		||||
		done; \
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
# This assumes that GNU utilities are *not* used
 | 
			
		||||
do_irix-shared:
 | 
			
		||||
	if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(MAKE) do_gnu-shared; \
 | 
			
		||||
	else \
 | 
			
		||||
		libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
			
		||||
		if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
 | 
			
		||||
			libs="$(LIBKRB5) $$libs"; \
 | 
			
		||||
		fi; \
 | 
			
		||||
		( set -x; ${CC} ${SHARED_LDFLAGS} \
 | 
			
		||||
			-shared -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
			-Wl,-soname,lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
			-all lib$$i.a $$libs ${EX_LIBS} -lc) || exit 1; \
 | 
			
		||||
		libs="-l$$i $$libs"; \
 | 
			
		||||
		done; \
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
# This assumes that GNU utilities are *not* used
 | 
			
		||||
# HP-UX includes the full pathname of libs we depend on, so we would get
 | 
			
		||||
# ./libcrypto (with ./ as path information) compiled into libssl, hence
 | 
			
		||||
# we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
 | 
			
		||||
# anyway.
 | 
			
		||||
# The object modules are loaded from lib$i.a using the undocumented -Fl
 | 
			
		||||
# option.
 | 
			
		||||
#
 | 
			
		||||
# WARNING: Until DSO is fixed to support a search path, we support SHLIB_PATH
 | 
			
		||||
#          by temporarily specifying "+s"!
 | 
			
		||||
#
 | 
			
		||||
do_hpux-shared:
 | 
			
		||||
	for i in ${SHLIBDIRS}; do \
 | 
			
		||||
	if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
 | 
			
		||||
		libs="$(LIBKRB5) $$libs"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	( set -x; /usr/ccs/bin/ld ${SHARED_LDFLAGS} \
 | 
			
		||||
		+vnocompatwarnings \
 | 
			
		||||
		-b -z +s \
 | 
			
		||||
		-o lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
		+h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
		-Fl lib$$i.a -ldld -lc ) || exit 1; \
 | 
			
		||||
	chmod a=rx lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR}; \
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
# This assumes that GNU utilities are *not* used
 | 
			
		||||
# HP-UX includes the full pathname of libs we depend on, so we would get
 | 
			
		||||
# ./libcrypto (with ./ as path information) compiled into libssl, hence
 | 
			
		||||
# we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
 | 
			
		||||
# anyway.
 | 
			
		||||
#
 | 
			
		||||
# HP-UX in 64bit mode has "+s" enabled by default; it will search for
 | 
			
		||||
# shared libraries along LD_LIBRARY_PATH _and_ SHLIB_PATH.
 | 
			
		||||
#
 | 
			
		||||
do_hpux64-shared:
 | 
			
		||||
	for i in ${SHLIBDIRS}; do \
 | 
			
		||||
	if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
 | 
			
		||||
		libs="$(LIBKRB5) $$libs"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	( set -x; /usr/ccs/bin/ld ${SHARED_LDFLAGS} \
 | 
			
		||||
		-b -z \
 | 
			
		||||
		-o lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
		+h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
			
		||||
		+forceload lib$$i.a -ldl -lc ) || exit 1; \
 | 
			
		||||
	chmod a=rx lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR}; \
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
# The following method is said to work on all platforms.  Tests will
 | 
			
		||||
# determine if that's how it's gong to be used.
 | 
			
		||||
# This assumes that for all but GNU systems, GNU utilities are *not* used.
 | 
			
		||||
# ALLSYMSFLAGS would be:
 | 
			
		||||
#  GNU systems: --whole-archive
 | 
			
		||||
#  Tru64 Unix:  -all
 | 
			
		||||
#  Solaris:     -z allextract
 | 
			
		||||
#  Irix:        -all
 | 
			
		||||
#  HP/UX-32bit: -Fl
 | 
			
		||||
#  HP/UX-64bit: +forceload
 | 
			
		||||
#  AIX:		-bnogc
 | 
			
		||||
# SHAREDFLAGS would be:
 | 
			
		||||
#  GNU systems: -shared -Wl,-soname=lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
 | 
			
		||||
#  Tru64 Unix:  -shared \
 | 
			
		||||
#		-set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}"
 | 
			
		||||
#  Solaris:     -G -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
 | 
			
		||||
#  Irix:        -shared -Wl,-soname,lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
 | 
			
		||||
#  HP/UX-32bit: +vnocompatwarnings -b -z +s \
 | 
			
		||||
#		+h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR}
 | 
			
		||||
#  HP/UX-64bit: -b -z +h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR}
 | 
			
		||||
#  AIX:		-G -bE:lib$$i.exp -bM:SRE
 | 
			
		||||
# SHAREDCMD would be:
 | 
			
		||||
#  GNU systems: $(CC)
 | 
			
		||||
#  Tru64 Unix:  $(CC)
 | 
			
		||||
#  Solaris:     $(CC)
 | 
			
		||||
#  Irix:        $(CC)
 | 
			
		||||
#  HP/UX-32bit: /usr/ccs/bin/ld
 | 
			
		||||
#  HP/UX-64bit: /usr/ccs/bin/ld
 | 
			
		||||
#  AIX:		$(CC)
 | 
			
		||||
ALLSYMSFLAG=-bnogc
 | 
			
		||||
SHAREDFLAGS=${SHARED_LDFLAGS} -G -bE:lib$$i.exp -bM:SRE
 | 
			
		||||
SHAREDCMD=$(CC)
 | 
			
		||||
do_aix-shared:
 | 
			
		||||
	libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
			
		||||
	if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
 | 
			
		||||
		libs="$(LIBKRB5) $$libs"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	( set -x; \
 | 
			
		||||
	  ld -r -o lib$$i.o $(ALLSYMSFLAG) lib$$i.a && \
 | 
			
		||||
	  ( nm -Pg lib$$i.o | grep ' [BD] ' | cut -f1 -d' ' > lib$$i.exp; \
 | 
			
		||||
	    $(SHAREDCMD) $(SHAREDFLAGS) \
 | 
			
		||||
		-o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} lib$$i.o \
 | 
			
		||||
		$$libs ${EX_LIBS} ) ) \
 | 
			
		||||
	|| exit 1; \
 | 
			
		||||
	libs="-l$$i $$libs"; \
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
do_reliantunix-shared:
 | 
			
		||||
	libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
			
		||||
	if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
 | 
			
		||||
		libs="$(LIBKRB5) $$libs"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	tmpdir=/tmp/openssl.$$$$ ; rm -rf $$tmpdir ; \
 | 
			
		||||
	( set -x; \
 | 
			
		||||
	  ( Opwd=`pwd` ; mkdir $$tmpdir || exit 1; \
 | 
			
		||||
	    cd $$tmpdir || exit 1 ; ar x $$Opwd/lib$$i.a ; \
 | 
			
		||||
	    ${CC} -G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} *.o \
 | 
			
		||||
	  ) || exit 1; \
 | 
			
		||||
	  cp $$tmpdir/lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} . ; \
 | 
			
		||||
	) || exit 1; \
 | 
			
		||||
	rm -rf $$tmpdir ; \
 | 
			
		||||
	libs="-l$$i $$libs"; \
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
@@ -307,7 +605,7 @@ openssl.pc: Makefile.ssl
 | 
			
		||||
	    echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
 | 
			
		||||
	    echo 'Version: '$(VERSION); \
 | 
			
		||||
	    echo 'Requires: '; \
 | 
			
		||||
	    echo 'Libs: -L$${libdir} -lssl -lcrypto $(EX_LIBS)'; \
 | 
			
		||||
	    echo 'Libs: -L$${libdir} -lssl -lcrypto $(LIBKRB5) $(EX_LIBS)'; \
 | 
			
		||||
	    echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > openssl.pc
 | 
			
		||||
 | 
			
		||||
Makefile.ssl: Makefile.org
 | 
			
		||||
@@ -433,7 +731,7 @@ tags:
 | 
			
		||||
 | 
			
		||||
errors:
 | 
			
		||||
	$(PERL) util/mkerr.pl -recurse -write
 | 
			
		||||
	(cd engines; $(MAKE) PERL=$(PERL) errors)
 | 
			
		||||
	(cd crypto/engine; $(MAKE) PERL=$(PERL) errors)
 | 
			
		||||
 | 
			
		||||
stacks:
 | 
			
		||||
	$(PERL) util/mkstack.pl -write
 | 
			
		||||
@@ -495,7 +793,6 @@ install: all install_docs
 | 
			
		||||
		$(INSTALL_PREFIX)$(INSTALLTOP)/lib \
 | 
			
		||||
		$(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig \
 | 
			
		||||
		$(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl \
 | 
			
		||||
		$(INSTALL_PREFIX)$(OPENSSLDIR)/engines \
 | 
			
		||||
		$(INSTALL_PREFIX)$(OPENSSLDIR)/misc \
 | 
			
		||||
		$(INSTALL_PREFIX)$(OPENSSLDIR)/certs \
 | 
			
		||||
		$(INSTALL_PREFIX)$(OPENSSLDIR)/private \
 | 
			
		||||
@@ -509,7 +806,7 @@ install: all install_docs
 | 
			
		||||
	do \
 | 
			
		||||
	if [ -d "$$i" ]; then \
 | 
			
		||||
		(cd $$i; echo "installing $$i..."; \
 | 
			
		||||
		$(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALL_PREFIX='${INSTALL_PREFIX}' INSTALLTOP='${INSTALLTOP}' OPENSSLDIR='${OPENSSLDIR}' EX_LIBS='${EX_LIBS}' SDIRS='${SDIRS}' RANLIB='${RANLIB}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' install ); \
 | 
			
		||||
		$(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALL_PREFIX='${INSTALL_PREFIX}' INSTALLTOP='${INSTALLTOP}' OPENSSLDIR='${OPENSSLDIR}' EX_LIBS='${EX_LIBS}' SDIRS='${SDIRS}' RANLIB='${RANLIB}' EXE_EXT='${EXE_EXT}' install ); \
 | 
			
		||||
	fi; \
 | 
			
		||||
	done
 | 
			
		||||
	@for i in $(LIBS) ;\
 | 
			
		||||
@@ -533,7 +830,7 @@ install: all install_docs
 | 
			
		||||
					chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
 | 
			
		||||
					mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i; \
 | 
			
		||||
				else \
 | 
			
		||||
					c=`echo $$i | sed 's/^lib/cyg/'`; \
 | 
			
		||||
					c=`echo $$i | sed 's/^lib\(.*\)\.dll/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
 | 
			
		||||
					cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
 | 
			
		||||
					chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
 | 
			
		||||
					mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
 | 
			
		||||
@@ -545,7 +842,8 @@ install: all install_docs
 | 
			
		||||
		done; \
 | 
			
		||||
		(	here="`pwd`"; \
 | 
			
		||||
			cd $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \
 | 
			
		||||
			$(NEWMAKE) -f $$here/Makefile HERE="$$here" link-shared ); \
 | 
			
		||||
			set $(MAKE); \
 | 
			
		||||
			$$1 -f $$here/Makefile link-shared ); \
 | 
			
		||||
		if [ "$(INSTALLTOP)" != "/usr" ]; then \
 | 
			
		||||
			echo 'OpenSSL shared libraries have been installed in:'; \
 | 
			
		||||
			echo '  $(INSTALLTOP)'; \
 | 
			
		||||
@@ -553,8 +851,16 @@ install: all install_docs
 | 
			
		||||
			sed -e '1,/^$$/d' doc/openssl-shared.txt; \
 | 
			
		||||
		fi; \
 | 
			
		||||
	fi
 | 
			
		||||
	@for i in $(SIGS) ;\
 | 
			
		||||
	do \
 | 
			
		||||
		if [ -f "$$i" ]; then \
 | 
			
		||||
		(       echo installing $$i; \
 | 
			
		||||
			cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
 | 
			
		||||
			mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \
 | 
			
		||||
		fi; \
 | 
			
		||||
	done;
 | 
			
		||||
	cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig
 | 
			
		||||
	chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig
 | 
			
		||||
	chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig/openssl.pc
 | 
			
		||||
 | 
			
		||||
install_docs:
 | 
			
		||||
	@$(PERL) $(TOP)/util/mkdir-p.pl \
 | 
			
		||||
@@ -579,6 +885,7 @@ install_docs:
 | 
			
		||||
			>  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
 | 
			
		||||
		$(PERL) util/extract-names.pl < $$i | \
 | 
			
		||||
			grep -v $$filecase "^$$fn\$$" | \
 | 
			
		||||
			grep -v "[	]" | \
 | 
			
		||||
			(cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
 | 
			
		||||
			 while read n; do \
 | 
			
		||||
				$$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
 | 
			
		||||
@@ -595,6 +902,7 @@ install_docs:
 | 
			
		||||
			>  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
 | 
			
		||||
		$(PERL) util/extract-names.pl < $$i | \
 | 
			
		||||
			grep -v $$filecase "^$$fn\$$" | \
 | 
			
		||||
			grep -v "[	]" | \
 | 
			
		||||
			(cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
 | 
			
		||||
			 while read n; do \
 | 
			
		||||
				$$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										782
									
								
								Makefile.shared
									
									
									
									
									
								
							
							
						
						
									
										782
									
								
								Makefile.shared
									
									
									
									
									
								
							@@ -1,782 +0,0 @@
 | 
			
		||||
#
 | 
			
		||||
# Helper makefile to link shared libraries in a portable way.
 | 
			
		||||
# This is much simpler than libtool, and hopefully not too error-prone.
 | 
			
		||||
#
 | 
			
		||||
# The following variables need to be set on the command line to build
 | 
			
		||||
# properly
 | 
			
		||||
 | 
			
		||||
# CC contains the current compiler.  This one MUST be defined
 | 
			
		||||
CC=cc
 | 
			
		||||
# LDFLAGS contains flags to be used when temporary object files (when building
 | 
			
		||||
# shared libraries) are created, or when an application is linked.
 | 
			
		||||
# SHARED_LDFLAGS contains flags to be used when the shared library is created.
 | 
			
		||||
LDFLAGS=
 | 
			
		||||
SHARED_LDFLAGS=
 | 
			
		||||
 | 
			
		||||
# LIBNAME contains just the name of the library, without prefix ("lib"
 | 
			
		||||
# on Unix, "cyg" for certain forms under Cygwin...) or suffix (.a, .so,
 | 
			
		||||
# .dll, ...).  This one MUST have a value when using this makefile to
 | 
			
		||||
# build shared libraries.
 | 
			
		||||
# For example, to build libfoo.so, you need to do the following:
 | 
			
		||||
#LIBNAME=foo
 | 
			
		||||
LIBNAME=
 | 
			
		||||
 | 
			
		||||
# APPNAME contains just the name of the application, without suffix (""
 | 
			
		||||
# on Unix, ".exe" on Windows, ...).  This one MUST have a value when using
 | 
			
		||||
# this makefile to build applications.
 | 
			
		||||
# For example, to build foo, you need to do the following:
 | 
			
		||||
#APPNAME=foo
 | 
			
		||||
APPNAME=
 | 
			
		||||
 | 
			
		||||
# OBJECTS contains all the object files to link together into the application.
 | 
			
		||||
# This must contain at least one object file.
 | 
			
		||||
#OBJECTS=foo.o
 | 
			
		||||
OBJECTS=
 | 
			
		||||
 | 
			
		||||
# LIBEXTRAS contains extra modules to link together with the library.
 | 
			
		||||
# For example, if a second library, say libbar.a needs to be linked into
 | 
			
		||||
# libfoo.so, you need to do the following:
 | 
			
		||||
#LIBEXTRAS=libbar.a
 | 
			
		||||
# Note that this MUST be used when using the link_o targets, to hold the
 | 
			
		||||
# names of all object files that go into the target library.
 | 
			
		||||
LIBEXTRAS=
 | 
			
		||||
 | 
			
		||||
# LIBVERSION contains the current version of the library.
 | 
			
		||||
# For example, to build libfoo.so.1.2, you need to do the following:
 | 
			
		||||
#LIBVERSION=1.2
 | 
			
		||||
LIBVERSION=
 | 
			
		||||
 | 
			
		||||
# LIBCOMPATVERSIONS contains the compatibility versions (a list) of
 | 
			
		||||
# the library.  They MUST be in decreasing order.
 | 
			
		||||
# For example, if libfoo.so.1.2.1 is backward compatible with libfoo.so.1.2
 | 
			
		||||
# and libfoo.so.1, you need to do the following:
 | 
			
		||||
#LIBCOMPATVERSIONS=1.2 1
 | 
			
		||||
# Note that on systems that use sonames, the last number will appear as
 | 
			
		||||
# part of it.
 | 
			
		||||
# It's also possible, for systems that support it (Tru64, for example),
 | 
			
		||||
# to add extra compatibility info with more precision, by adding a second
 | 
			
		||||
# list of versions, separated from the first with a semicolon, like this:
 | 
			
		||||
#LIBCOMPATVERSIONS=1.2 1;1.2.0 1.1.2 1.1.1 1.1.0 1.0.0
 | 
			
		||||
LIBCOMPATVERSIONS=
 | 
			
		||||
 | 
			
		||||
# LIBDEPS contains all the flags necessary to cover all necessary
 | 
			
		||||
# dependencies to other libraries.
 | 
			
		||||
LIBDEPS=
 | 
			
		||||
 | 
			
		||||
#------------------------------------------------------------------------------
 | 
			
		||||
# The rest is private to this makefile.
 | 
			
		||||
 | 
			
		||||
#DEBUG=:
 | 
			
		||||
DEBUG=set -x
 | 
			
		||||
 | 
			
		||||
top:
 | 
			
		||||
	echo "Trying to use this makefile interactively?  Don't."
 | 
			
		||||
 | 
			
		||||
CALC_VERSIONS=	\
 | 
			
		||||
	SHLIB_COMPAT=; SHLIB_SOVER=; \
 | 
			
		||||
	if [ -n "$(LIBVERSION)$(LIBCOMPATVERSIONS)" ]; then \
 | 
			
		||||
		prev=""; \
 | 
			
		||||
		for v in `echo "$(LIBVERSION) $(LIBCOMPATVERSIONS)" | cut -d';' -f1`; do \
 | 
			
		||||
			SHLIB_SOVER_NODOT=$$v; \
 | 
			
		||||
			SHLIB_SOVER=.$$v; \
 | 
			
		||||
			if [ -n "$$prev" ]; then \
 | 
			
		||||
				SHLIB_COMPAT="$$SHLIB_COMPAT .$$prev"; \
 | 
			
		||||
			fi; \
 | 
			
		||||
			prev=$$v; \
 | 
			
		||||
		done; \
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
LINK_APP=	\
 | 
			
		||||
  ( $(DEBUG);   \
 | 
			
		||||
    LIBPATH=`for x in $$LIBDEPS; do if echo $$x | grep '^ *-L' > /dev/null 2>&1; then echo $$x | sed -e 's/^ *-L//'; fi; done | uniq`; \
 | 
			
		||||
    LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
 | 
			
		||||
    LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
 | 
			
		||||
    $$LDCMD $(LDFLAGS) $$LDFLAGS -o $$APPNAME $(OBJECTS) $$LIBDEPS )
 | 
			
		||||
 | 
			
		||||
LINK_SO=	\
 | 
			
		||||
  ( $(DEBUG);   \
 | 
			
		||||
    nm -Pg $$SHOBJECTS | grep ' [BDT] ' | cut -f1 -d' ' > lib$(LIBNAME).exp; \
 | 
			
		||||
    LIBPATH=`for x in $$LIBDEPS; do if echo $$x | grep '^ *-L' > /dev/null 2>&1; then echo $$x | sed -e 's/^ *-L//'; fi; done | uniq`; \
 | 
			
		||||
    LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
 | 
			
		||||
    LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
 | 
			
		||||
    $$SHAREDCMD $(SHARED_LDFLAGS) $$SHAREDFLAGS -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
 | 
			
		||||
	$$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS ) && \
 | 
			
		||||
  $(SYMLINK_SO); ( $(DEBUG); rm -f lib$(LIBNAME).exp )
 | 
			
		||||
SYMLINK_SO=	\
 | 
			
		||||
	if [ -n "$$INHIBIT_SYMLINKS" ]; then :; else \
 | 
			
		||||
		prev=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
 | 
			
		||||
		if [ -n "$$SHLIB_COMPAT" ]; then \
 | 
			
		||||
			for x in $$SHLIB_COMPAT; do \
 | 
			
		||||
				( $(DEBUG); rm -f $$SHLIB$$x$$SHLIB_SUFFIX; \
 | 
			
		||||
				  ln -s $$prev $$SHLIB$$x$$SHLIB_SUFFIX ); \
 | 
			
		||||
				prev=$$SHLIB$$x$$SHLIB_SUFFIX; \
 | 
			
		||||
			done; \
 | 
			
		||||
		fi; \
 | 
			
		||||
		if [ -n "$$SHLIB_SOVER" ]; then \
 | 
			
		||||
			( $(DEBUG); rm -f $$SHLIB$$SHLIB_SUFFIX; \
 | 
			
		||||
			  ln -s $$prev $$SHLIB$$SHLIB_SUFFIX ); \
 | 
			
		||||
		fi; \
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
LINK_SO_A=	SHOBJECTS="lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
 | 
			
		||||
LINK_SO_O=	SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
 | 
			
		||||
LINK_SO_A_VIA_O=	\
 | 
			
		||||
  SHOBJECTS=lib$(LIBNAME).o; \
 | 
			
		||||
  ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \
 | 
			
		||||
  ( $(DEBUG); \
 | 
			
		||||
    ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS) ); \
 | 
			
		||||
  $(LINK_SO) && rm -f $(LIBNAME).o
 | 
			
		||||
LINK_SO_A_UNPACKED=	\
 | 
			
		||||
  UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \
 | 
			
		||||
  (cd $$UNPACKDIR; ar x ../lib$(LIBNAME).a) && \
 | 
			
		||||
  ([ -z "$(LIBEXTRAS)" ] || cp $(LIBEXTRAS) $$UNPACKDIR) && \
 | 
			
		||||
  SHOBJECTS=$$UNPACKDIR/*.o; \
 | 
			
		||||
  $(LINK_SO) && rm -rf $$UNPACKDIR
 | 
			
		||||
 | 
			
		||||
DETECT_GNU_LD=(${CC} -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null
 | 
			
		||||
 | 
			
		||||
DO_GNU_SO=$(CALC_VERSIONS); \
 | 
			
		||||
	SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
	SHLIB_SUFFIX=; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	ALLSYMSFLAGS='-Wl,--whole-archive'; \
 | 
			
		||||
	NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
 | 
			
		||||
	SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
 | 
			
		||||
	SHAREDCMD='$(CC)'
 | 
			
		||||
DO_GNU_APP=LDCMD=$(CC);\
 | 
			
		||||
	LDFLAGS="-Wl,-rpath,$(LIBRPATH)"; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	APPNAME=$(APPNAME)
 | 
			
		||||
 | 
			
		||||
#This is rather special.  It's a special target with which one can link
 | 
			
		||||
#applications without bothering with any features that have anything to
 | 
			
		||||
#do with shared libraries, for example when linking against static
 | 
			
		||||
#libraries.  It's mostly here to avoid a lot of conditionals everywhere
 | 
			
		||||
#else...
 | 
			
		||||
link_app.:
 | 
			
		||||
	LDCMD=$(CC); \
 | 
			
		||||
	LDFLAGS=""; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS)"; \
 | 
			
		||||
	APPNAME="$(APPNAME)"; \
 | 
			
		||||
	$(LINK_APP)
 | 
			
		||||
 | 
			
		||||
link_o.gnu:
 | 
			
		||||
	@ $(DO_GNU_SO); $(LINK_SO_O)
 | 
			
		||||
link_a.gnu:
 | 
			
		||||
	@ $(DO_GNU_SO); $(LINK_SO_A)
 | 
			
		||||
link_app.gnu:
 | 
			
		||||
	@ $(DO_GNU_APP); $(LINK_APP)
 | 
			
		||||
 | 
			
		||||
# For Darwin AKA Mac OS/X (dyld)
 | 
			
		||||
link_o.darwin:
 | 
			
		||||
	@ $(CALC_VERSIONS); \
 | 
			
		||||
	SHLIB=lib$(LIBNAME); \
 | 
			
		||||
	SHLIB_SUFFIX=.dylib; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	ALLSYMSFLAGS='-all_load'; \
 | 
			
		||||
	NOALLSYMSFLAGS=''; \
 | 
			
		||||
	SHAREDFLAGS="-dynamiclib"; \
 | 
			
		||||
	SHAREDCMD='$(CC)'; \
 | 
			
		||||
	if [ -n "$(LIBVERSION)" ]; then \
 | 
			
		||||
		SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
 | 
			
		||||
		SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_SO_O)
 | 
			
		||||
link_a.darwin:
 | 
			
		||||
	@ $(CALC_VERSIONS); \
 | 
			
		||||
	SHLIB=lib$(LIBNAME); \
 | 
			
		||||
	SHLIB_SUFFIX=.dylib; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	ALLSYMSFLAGS='-all_load'; \
 | 
			
		||||
	NOALLSYMSFLAGS=''; \
 | 
			
		||||
	SHAREDFLAGS="-dynamiclib"; \
 | 
			
		||||
	SHAREDCMD='$(CC)'; \
 | 
			
		||||
	if [ -n "$(LIBVERSION)" ]; then \
 | 
			
		||||
		SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
 | 
			
		||||
		SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_SO_A)
 | 
			
		||||
link_app.darwin:
 | 
			
		||||
	LDCMD=$(CC);\
 | 
			
		||||
	LDFLAGS=""; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	APPNAME="$(APPNAME)"; \
 | 
			
		||||
	$(LINK_APP)
 | 
			
		||||
 | 
			
		||||
link_o.cygwin:
 | 
			
		||||
	@ $(CALC_VERSIONS); \
 | 
			
		||||
	INHIBIT_SYMLINKS=yes; \
 | 
			
		||||
	SHLIB=cyg$(LIBNAME); \
 | 
			
		||||
	SHLIB_SUFFIX=.dll; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	SHLIB_SOVER=-$(LIBVERSION); \
 | 
			
		||||
	ALLSYMSFLAGS='-Wl,--whole-archive'; \
 | 
			
		||||
	NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
 | 
			
		||||
	SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \
 | 
			
		||||
	SHAREDCMD='${CC}'; \
 | 
			
		||||
	$(LINK_SO_O)
 | 
			
		||||
link_a.cygwin:
 | 
			
		||||
	@ $(CALC_VERSIONS); \
 | 
			
		||||
	INHIBIT_SYMLINKS=yes; \
 | 
			
		||||
	SHLIB=cyg$(LIBNAME); \
 | 
			
		||||
	SHLIB_SUFFIX=.dll; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	SHLIB_SOVER=; \
 | 
			
		||||
	ALLSYMSFLAGS='-Wl,--whole-archive'; \
 | 
			
		||||
	NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
 | 
			
		||||
	SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \
 | 
			
		||||
	SHAREDCMD='${CC}'; \
 | 
			
		||||
	$(LINK_SO_A)
 | 
			
		||||
link_app.cygwin:
 | 
			
		||||
	LDCMD=$(CC);\
 | 
			
		||||
	LDFLAGS=""; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	APPNAME="$(APPNAME).exe"
 | 
			
		||||
	$(LINK_APP)
 | 
			
		||||
 | 
			
		||||
link_o.alpha-osf1:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_SO); \
 | 
			
		||||
	else \
 | 
			
		||||
		SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
		SHLIB_SUFFIX=; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
 | 
			
		||||
		if [ -n "$$SHLIB_HIST" ]; then \
 | 
			
		||||
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
 | 
			
		||||
		else \
 | 
			
		||||
			SHLIB_HIST="$(LIBVERSION)"; \
 | 
			
		||||
		fi; \
 | 
			
		||||
		SHLIB_SOVER=; \
 | 
			
		||||
		ALLSYMSFLAGS='-all'; \
 | 
			
		||||
		NOALLSYMSFLAGS='-none'; \
 | 
			
		||||
		SHAREDFLAGS="-shared"; \
 | 
			
		||||
		SHAREDCMD='$(CC)'; \
 | 
			
		||||
		if [ -n "$$SHLIB_HIST" ]; then \
 | 
			
		||||
			SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
 | 
			
		||||
		fi; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_SO_O)
 | 
			
		||||
link_a.alpha-osf1:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_SO); \
 | 
			
		||||
	else \
 | 
			
		||||
		SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
		SHLIB_SUFFIX=; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
 | 
			
		||||
		if [ -n "$$SHLIB_HIST" ]; then \
 | 
			
		||||
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
 | 
			
		||||
		else \
 | 
			
		||||
			SHLIB_HIST="$(LIBVERSION)"; \
 | 
			
		||||
		fi; \
 | 
			
		||||
		SHLIB_SOVER=; \
 | 
			
		||||
		ALLSYMSFLAGS='-all'; \
 | 
			
		||||
		NOALLSYMSFLAGS='-none'; \
 | 
			
		||||
		SHAREDFLAGS="-shared"; \
 | 
			
		||||
		SHAREDCMD='$(CC)'; \
 | 
			
		||||
		if [ -n "$$SHLIB_HIST" ]; then \
 | 
			
		||||
			SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
 | 
			
		||||
		fi; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_SO_A)
 | 
			
		||||
link_app.alpha-osf1:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_APP); \
 | 
			
		||||
	else \
 | 
			
		||||
		LDCMD=$(CC);\
 | 
			
		||||
		LDFLAGS=""; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		APPNAME="$(APPNAME)"
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_APP)
 | 
			
		||||
 | 
			
		||||
# The difference between alpha-osf1-shared and tru64-shared is the `-msym'
 | 
			
		||||
# option passed to the linker.
 | 
			
		||||
link_o.tru64:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_SO); \
 | 
			
		||||
	else \
 | 
			
		||||
		SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
		SHLIB_SUFFIX=; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
 | 
			
		||||
		if [ -n "$$SHLIB_HIST" ]; then \
 | 
			
		||||
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
 | 
			
		||||
		else \
 | 
			
		||||
			SHLIB_HIST="$(LIBVERSION)"; \
 | 
			
		||||
		fi; \
 | 
			
		||||
		SHLIB_SOVER=; \
 | 
			
		||||
		ALLSYMSFLAGS='-all'; \
 | 
			
		||||
		NOALLSYMSFLAGS='-none'; \
 | 
			
		||||
		SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
 | 
			
		||||
		SHAREDCMD='$(CC)'; \
 | 
			
		||||
		if [ -n "$$SHLIB_HIST" ]; then \
 | 
			
		||||
			SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
 | 
			
		||||
		fi; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_SO_O)
 | 
			
		||||
link_a.tru64:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_SO); \
 | 
			
		||||
	else \
 | 
			
		||||
		SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
		SHLIB_SUFFIX=; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
 | 
			
		||||
		if [ -n "$$SHLIB_HIST" ]; then \
 | 
			
		||||
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
 | 
			
		||||
		else \
 | 
			
		||||
			SHLIB_HIST="$(LIBVERSION)"; \
 | 
			
		||||
		fi; \
 | 
			
		||||
		SHLIB_SOVER=; \
 | 
			
		||||
		ALLSYMSFLAGS='-all'; \
 | 
			
		||||
		NOALLSYMSFLAGS='-none'; \
 | 
			
		||||
		SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
 | 
			
		||||
		SHAREDCMD='$(CC)'; \
 | 
			
		||||
		if [ -n "$$SHLIB_HIST" ]; then \
 | 
			
		||||
			SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
 | 
			
		||||
		fi; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_SO_A)
 | 
			
		||||
link_app.tru64:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_APP); \
 | 
			
		||||
	else \
 | 
			
		||||
		LDCMD=$(CC);\
 | 
			
		||||
		LDFLAGS="-rpath $(LIBRPATH)"; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		APPNAME="$(APPNAME)"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_APP)
 | 
			
		||||
 | 
			
		||||
# The difference between tru64-shared and tru64-shared-rpath is the
 | 
			
		||||
# -rpath ${LIBRPATH} passed to the linker.
 | 
			
		||||
link_o.tru64-rpath:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_SO); \
 | 
			
		||||
	else \
 | 
			
		||||
		SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
		SHLIB_SUFFIX=; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
 | 
			
		||||
		if [ -n "$$SHLIB_HIST" ]; then \
 | 
			
		||||
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
 | 
			
		||||
		else \
 | 
			
		||||
			SHLIB_HIST="$(LIBVERSION)"; \
 | 
			
		||||
		fi; \
 | 
			
		||||
		SHLIB_SOVER=; \
 | 
			
		||||
		ALLSYMSFLAGS='-all'; \
 | 
			
		||||
		NOALLSYMSFLAGS='-none'; \
 | 
			
		||||
		SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
 | 
			
		||||
		SHAREDCMD='$(CC)'; \
 | 
			
		||||
		if [ -n "$$SHLIB_HIST" ]; then \
 | 
			
		||||
			SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
 | 
			
		||||
		fi; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_SO_O)
 | 
			
		||||
link_a.tru64-rpath:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_SO); \
 | 
			
		||||
	else \
 | 
			
		||||
		SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
		SHLIB_SUFFIX=; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
 | 
			
		||||
		if [ -n "$$SHLIB_HIST" ]; then \
 | 
			
		||||
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
 | 
			
		||||
		else \
 | 
			
		||||
			SHLIB_HIST="$(LIBVERSION)"; \
 | 
			
		||||
		fi; \
 | 
			
		||||
		SHLIB_SOVER=; \
 | 
			
		||||
		ALLSYMSFLAGS='-all'; \
 | 
			
		||||
		NOALLSYMSFLAGS='-none'; \
 | 
			
		||||
		SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
 | 
			
		||||
		SHAREDCMD='$(CC)'; \
 | 
			
		||||
		if [ -n "$$SHLIB_HIST" ]; then \
 | 
			
		||||
			SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
 | 
			
		||||
		fi; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_SO_A)
 | 
			
		||||
link_app.tru64-rpath:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_APP); \
 | 
			
		||||
	else \
 | 
			
		||||
		LDCMD=$(CC);\
 | 
			
		||||
		LDFLAGS="-rpath $(LIBRPATH)"; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		APPNAME="$(APPNAME)"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_APP)
 | 
			
		||||
 | 
			
		||||
link_o.solaris:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_SO); \
 | 
			
		||||
	else \
 | 
			
		||||
		$(CALC_VERSIONS); \
 | 
			
		||||
		MINUSZ='-z '; \
 | 
			
		||||
		(${CC} -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
 | 
			
		||||
		SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
		SHLIB_SUFFIX=; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		ALLSYMSFLAGS="$${MINUSZ}allextract"; \
 | 
			
		||||
		NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
 | 
			
		||||
		SHAREDFLAGS="-G -dy -z text -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -R $(LIBRPATH)"; \
 | 
			
		||||
		SHAREDCMD='$(CC)'; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_SO_O)
 | 
			
		||||
link_a.solaris:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_SO); \
 | 
			
		||||
	else \
 | 
			
		||||
		$(CALC_VERSIONS); \
 | 
			
		||||
		MINUSZ='-z '; \
 | 
			
		||||
		(${CC} -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
 | 
			
		||||
		SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
		SHLIB_SUFFIX=;\
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		ALLSYMSFLAGS="$${MINUSZ}allextract"; \
 | 
			
		||||
		NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
 | 
			
		||||
		SHAREDFLAGS="-G -dy -z text -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -R $(LIBRPATH)"; \
 | 
			
		||||
		SHAREDCMD='$(CC)'; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_SO_A)
 | 
			
		||||
link_app.solaris:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_APP); \
 | 
			
		||||
	else \
 | 
			
		||||
		LDCMD=$(CC);\
 | 
			
		||||
		LDFLAGS="-R $(LIBRPATH)"; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		APPNAME="$(APPNAME)"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_APP)
 | 
			
		||||
 | 
			
		||||
# OpenServer 5 native compilers used
 | 
			
		||||
link_o.svr3:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_SO); \
 | 
			
		||||
	else \
 | 
			
		||||
		$(CALC_VERSIONS); \
 | 
			
		||||
		SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
		SHLIB_SUFFIX=; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		ALLSYMSFLAGS=''; \
 | 
			
		||||
		NOALLSYMSFLAGS=''; \
 | 
			
		||||
		SHAREDFLAGS="-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
 | 
			
		||||
		SHAREDCMD='$(CC)'; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_SO_O)
 | 
			
		||||
link_a.svr3:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_SO); \
 | 
			
		||||
	else \
 | 
			
		||||
		$(CALC_VERSIONS); \
 | 
			
		||||
		SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
		SHLIB_SUFFIX=; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		ALLSYMSFLAGS=''; \
 | 
			
		||||
		NOALLSYMSFLAGS=''; \
 | 
			
		||||
		SHAREDFLAGS="-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
 | 
			
		||||
		SHAREDCMD='$(CC)'; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_SO_A_UNPACKED)
 | 
			
		||||
link_app.svr3:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_APP); \
 | 
			
		||||
	else \
 | 
			
		||||
		LDCMD=$(CC);\
 | 
			
		||||
		LDFLAGS=""; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		APPNAME="$(APPNAME)"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_APP)
 | 
			
		||||
 | 
			
		||||
# UnixWare 7 and OpenUNIX 8 native compilers used
 | 
			
		||||
link_o.svr5:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_SO); \
 | 
			
		||||
	else \
 | 
			
		||||
		$(CALC_VERSIONS); \
 | 
			
		||||
		SHARE_FLAG='-G'; \
 | 
			
		||||
		(${CC} -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
 | 
			
		||||
		SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
		SHLIB_SUFFIX=; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		ALLSYMSFLAGS=''; \
 | 
			
		||||
		NOALLSYMSFLAGS=''; \
 | 
			
		||||
		SHAREDFLAGS="$${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
 | 
			
		||||
		SHAREDCMD='$(CC)'; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_SO_O)
 | 
			
		||||
link_a.svr5:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_SO); \
 | 
			
		||||
	else \
 | 
			
		||||
		$(CALC_VERSIONS); \
 | 
			
		||||
		SHARE_FLAG='-G'; \
 | 
			
		||||
		(${CC} -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
 | 
			
		||||
		SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
		SHLIB_SUFFIX=; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		ALLSYMSFLAGS=''; \
 | 
			
		||||
		NOALLSYMSFLAGS=''; \
 | 
			
		||||
		SHAREDFLAGS="$${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
 | 
			
		||||
		SHAREDCMD='$(CC)'; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_SO_A_UNPACKED)
 | 
			
		||||
link_app.svr5:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_APP); \
 | 
			
		||||
	else \
 | 
			
		||||
		LDCMD=$(CC);\
 | 
			
		||||
		LDFLAGS=""; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		APPNAME="$(APPNAME)"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_APP)
 | 
			
		||||
 | 
			
		||||
link_o.irix:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_SO); \
 | 
			
		||||
	else \
 | 
			
		||||
		$(CALC_VERSIONS); \
 | 
			
		||||
		SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
		SHLIB_SUFFIX=; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		ALLSYMSFLAGS='-all'; \
 | 
			
		||||
		NOALLSYMSFLAGS=''; \
 | 
			
		||||
		SHAREDFLAGS="-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
 | 
			
		||||
		SHAREDCMD='$(CC)'; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_SO_O)
 | 
			
		||||
link_a.irix:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_SO); \
 | 
			
		||||
	else \
 | 
			
		||||
		$(CALC_VERSIONS); \
 | 
			
		||||
		SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
		SHLIB_SUFFIX=; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		ALLSYMSFLAGS='-all'; \
 | 
			
		||||
		NOALLSYMSFLAGS=''; \
 | 
			
		||||
		SHAREDFLAGS="-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
 | 
			
		||||
		SHAREDCMD='$(CC)'; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_SO_A)
 | 
			
		||||
link_app.irix:
 | 
			
		||||
	@ if ${DETECT_GNU_LD}; then \
 | 
			
		||||
		$(DO_GNU_APP); \
 | 
			
		||||
	else \
 | 
			
		||||
		LDCMD=$(CC);\
 | 
			
		||||
		LDFLAGS="-Wl,-rpath,$(LIBRPATH)"; \
 | 
			
		||||
		LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
		APPNAME="$(APPNAME)"; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	$(LINK_APP)
 | 
			
		||||
 | 
			
		||||
# HP-UX includes the full pathname of libs we depend on, so we would get
 | 
			
		||||
# ./libcrypto (with ./ as path information) compiled into libssl, hence
 | 
			
		||||
# we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
 | 
			
		||||
# anyway.
 | 
			
		||||
# The object modules are loaded from lib$i.a using the undocumented -Fl
 | 
			
		||||
# option.
 | 
			
		||||
#
 | 
			
		||||
# WARNING: Until DSO is fixed to support a search path, we support SHLIB_PATH
 | 
			
		||||
#          by temporarily specifying "+s"!
 | 
			
		||||
#
 | 
			
		||||
link_o.hpux32:
 | 
			
		||||
	@ $(CALC_VERSIONS); \
 | 
			
		||||
	SHLIB=lib$(LIBNAME).sl; \
 | 
			
		||||
	SHLIB_SUFFIX=; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	ALLSYMSFLAGS='-Fl'; \
 | 
			
		||||
	NOALLSYMSFLAGS=''; \
 | 
			
		||||
	SHAREDFLAGS="+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
 | 
			
		||||
	SHAREDCMD='/usr/ccs/bin/ld'; \
 | 
			
		||||
	$(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
 | 
			
		||||
link_a.hpux32:
 | 
			
		||||
	@ $(CALC_VERSIONS); \
 | 
			
		||||
	SHLIB=lib$(LIBNAME).sl; \
 | 
			
		||||
	SHLIB_SUFFIX=; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	ALLSYMSFLAGS='-Fl'; \
 | 
			
		||||
	NOALLSYMSFLAGS=''; \
 | 
			
		||||
	SHAREDFLAGS="+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
 | 
			
		||||
	SHAREDCMD='/usr/ccs/bin/ld'; \
 | 
			
		||||
	$(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
 | 
			
		||||
link_app.hpux32:
 | 
			
		||||
	LDCMD=$(CC);\
 | 
			
		||||
	LDFLAGS="-Wl,+b,$(LIBRPATH)"; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	APPNAME="$(APPNAME)"
 | 
			
		||||
	$(LINK_APP)
 | 
			
		||||
 | 
			
		||||
# HP-UX includes the full pathname of libs we depend on, so we would get
 | 
			
		||||
# ./libcrypto (with ./ as path information) compiled into libssl, hence
 | 
			
		||||
# we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
 | 
			
		||||
# anyway.
 | 
			
		||||
#
 | 
			
		||||
# HP-UX in 64bit mode has "+s" enabled by default; it will search for
 | 
			
		||||
# shared libraries along LD_LIBRARY_PATH _and_ SHLIB_PATH.
 | 
			
		||||
#
 | 
			
		||||
link_o.hpux64:
 | 
			
		||||
	@ $(CALC_VERSIONS); \
 | 
			
		||||
	SHLIB=lib$(LIBNAME).sl; \
 | 
			
		||||
	SHLIB_SUFFIX=; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	ALLSYMSFLAGS='+forceload'; \
 | 
			
		||||
	NOALLSYMSFLAGS=''; \
 | 
			
		||||
	SHAREDFLAGS="-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
 | 
			
		||||
	SHAREDCMD='/usr/ccs/bin/ld'; \
 | 
			
		||||
	$(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
 | 
			
		||||
link_a.hpux64:
 | 
			
		||||
	@ $(CALC_VERSIONS); \
 | 
			
		||||
	SHLIB=lib$(LIBNAME).sl; \
 | 
			
		||||
	SHLIB_SUFFIX=; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	ALLSYMSFLAGS='+forceload'; \
 | 
			
		||||
	NOALLSYMSFLAGS=''; \
 | 
			
		||||
	SHAREDFLAGS="-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
 | 
			
		||||
	SHAREDCMD='/usr/ccs/bin/ld'; \
 | 
			
		||||
	$(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
 | 
			
		||||
link_app.hpux64:
 | 
			
		||||
	LDCMD=$(CC);\
 | 
			
		||||
	LDFLAGS="-Wl,+b,$(LIBRPATH)"; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	APPNAME="$(APPNAME)"
 | 
			
		||||
	$(LINK_APP)
 | 
			
		||||
 | 
			
		||||
link_o.aix:
 | 
			
		||||
	@ $(CALC_VERSIONS); \
 | 
			
		||||
	SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
	SHLIB_SUFFIX=; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	ALLSYMSFLAGS='-bnogc'; \
 | 
			
		||||
	NOALLSYMSFLAGS=''; \
 | 
			
		||||
	SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE -blibpath:$(LIBRPATH)'; \
 | 
			
		||||
	SHAREDCMD='$(CC)'; \
 | 
			
		||||
	$(LINK_SO_O)
 | 
			
		||||
link_a.aix:
 | 
			
		||||
	@ $(CALC_VERSIONS); \
 | 
			
		||||
	SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
	SHLIB_SUFFIX=; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	ALLSYMSFLAGS='-bnogc'; \
 | 
			
		||||
	NOALLSYMSFLAGS=''; \
 | 
			
		||||
	SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE -blibpath:$(LIBRPATH)'; \
 | 
			
		||||
	SHAREDCMD='$(CC)'; \
 | 
			
		||||
	$(LINK_SO_A_VIA_O)
 | 
			
		||||
link_app.aix:
 | 
			
		||||
	LDCMD=$(CC);\
 | 
			
		||||
	LDFLAGS="-blibpath:$(LIBRPATH)"; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	APPNAME="$(APPNAME)"
 | 
			
		||||
	$(LINK_APP)
 | 
			
		||||
 | 
			
		||||
link_o.reliantunix:
 | 
			
		||||
	@ $(CALC_VERSIONS); \
 | 
			
		||||
	SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
	SHLIB_SUFFIX=; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	ALLSYMSFLAGS=; \
 | 
			
		||||
	NOALLSYMSFLAGS=''; \
 | 
			
		||||
	SHAREDFLAGS='-G'; \
 | 
			
		||||
	SHAREDCMD='$(CC)'; \
 | 
			
		||||
	$(LINK_SO_O)
 | 
			
		||||
link_a.reliantunix:
 | 
			
		||||
	@ $(CALC_VERSIONS); \
 | 
			
		||||
	SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
	SHLIB_SUFFIX=; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	ALLSYMSFLAGS=; \
 | 
			
		||||
	NOALLSYMSFLAGS=''; \
 | 
			
		||||
	SHAREDFLAGS='-G'; \
 | 
			
		||||
	SHAREDCMD='$(CC)'; \
 | 
			
		||||
	$(LINK_SO_A_UNPACKED)
 | 
			
		||||
link_app.reliantunix:
 | 
			
		||||
	LDCMD=$(CC);\
 | 
			
		||||
	LDFLAGS=""; \
 | 
			
		||||
	LIBDEPS="$(LIBDEPS) -lc"; \
 | 
			
		||||
	APPNAME="$(APPNAME)"
 | 
			
		||||
	$(LINK_APP)
 | 
			
		||||
 | 
			
		||||
# Targets to build symbolic links when needed
 | 
			
		||||
symlink.gnu symlink.solaris symlink.svr3 symlink.svr5 symlink.irix \
 | 
			
		||||
symlink.aix symlink.reliantunix:
 | 
			
		||||
	@ $(CALC_VERSIONS); \
 | 
			
		||||
	SHLIB=lib$(LIBNAME).so; \
 | 
			
		||||
	$(SYMLINK_SO)
 | 
			
		||||
symlink.darwin:
 | 
			
		||||
	@ $(CALC_VERSIONS); \
 | 
			
		||||
	SHLIB=lib$(LIBNAME); \
 | 
			
		||||
	SHLIB_SUFFIX=.dylib; \
 | 
			
		||||
	$(SYMLINK_SO)
 | 
			
		||||
symlink.hpux32 symlink.hpux64:
 | 
			
		||||
	@ $(CALC_VERSIONS); \
 | 
			
		||||
	SHLIB=lib$(LIBNAME).sl; \
 | 
			
		||||
	$(SYMLINK_SO)
 | 
			
		||||
# The following lines means those specific architectures do no symlinks
 | 
			
		||||
symlink.cygwin symlib.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
 | 
			
		||||
 | 
			
		||||
# Compatibility targets
 | 
			
		||||
link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
 | 
			
		||||
link_a.bsd-gcc-shared link_a.linux-shared link_a.gnu-shared: link_a.gnu
 | 
			
		||||
link_app.bsd-gcc-shared link_app.linux-shared link_app.gnu-shared: link_app.gnu
 | 
			
		||||
symlink.bsd-gcc-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
 | 
			
		||||
link_o.darwin-shared: link_o.darwin
 | 
			
		||||
link_a.darwin-shared: link_a.darwin
 | 
			
		||||
link_app.darwin-shared: link_app.darwin
 | 
			
		||||
symlink.darwin-shared: symlink.darwin
 | 
			
		||||
link_o.cygwin-shared: link_o.cygwin
 | 
			
		||||
link_a.cygwin-shared: link_a.cygwin
 | 
			
		||||
link_app.cygwin-shared: link_app.cygwin
 | 
			
		||||
symlink.cygwin-shared: symlink.cygwin
 | 
			
		||||
link_o.alpha-osf1-shared: link_o.alpha-osf1
 | 
			
		||||
link_a.alpha-osf1-shared: link_a.alpha-osf1
 | 
			
		||||
link_app.alpha-osf1-shared: link_app.alpha-osf1
 | 
			
		||||
symlink.alpha-osf1-shared: symlink.alpha-osf1
 | 
			
		||||
link_o.tru64-shared: link_o.tru64
 | 
			
		||||
link_a.tru64-shared: link_a.tru64
 | 
			
		||||
link_app.tru64-shared: link_app.tru64
 | 
			
		||||
symlink.tru64-shared: symlink.tru64
 | 
			
		||||
link_o.tru64-shared-rpath: link_o.tru64-rpath
 | 
			
		||||
link_a.tru64-shared-rpath: link_a.tru64-rpath
 | 
			
		||||
link_app.tru64-shared-rpath: link_app.tru64-rpath
 | 
			
		||||
symlink.tru64-shared-rpath: symlink.tru64-rpath
 | 
			
		||||
link_o.solaris-shared: link_o.solaris
 | 
			
		||||
link_a.solaris-shared: link_a.solaris
 | 
			
		||||
link_app.solaris-shared: link_app.solaris
 | 
			
		||||
symlink.solaris-shared: symlink.solaris
 | 
			
		||||
link_o.svr3-shared: link_o.svr3
 | 
			
		||||
link_a.svr3-shared: link_a.svr3
 | 
			
		||||
link_app.svr3-shared: link_app.svr3
 | 
			
		||||
symlink.svr3-shared: symlink.svr3
 | 
			
		||||
link_o.svr5-shared: link_o.svr5
 | 
			
		||||
link_a.svr5-shared: link_a.svr5
 | 
			
		||||
link_app.svr5-shared: link_app.svr5
 | 
			
		||||
symlink.svr5-shared: symlink.svr5
 | 
			
		||||
link_o.irix-shared: link_o.irix
 | 
			
		||||
link_a.irix-shared: link_a.irix
 | 
			
		||||
link_app.irix-shared: link_app.irix
 | 
			
		||||
symlink.irix-shared: symlink.irix
 | 
			
		||||
link_o.hpux-shared: link_o.hpux32
 | 
			
		||||
link_a.hpux-shared: link_a.hpux32
 | 
			
		||||
link_app.hpux-shared: link_app.hpux32
 | 
			
		||||
symlink.hpux-shared: symlink.hpux32
 | 
			
		||||
link_o.hpux64-shared: link_o.hpux64
 | 
			
		||||
link_a.hpux64-shared: link_a.hpux64
 | 
			
		||||
link_app.hpux64-shared: link_app.hpux64
 | 
			
		||||
symlink.hpux64-shared: symlink.hpux64
 | 
			
		||||
link_o.aix-shared: link_o.aix
 | 
			
		||||
link_a.aix-shared: link_a.aix
 | 
			
		||||
link_app.aix-shared: link_app.aix
 | 
			
		||||
symlink.aix-shared: symlink.aix
 | 
			
		||||
link_o.reliantunix-shared: link_o.reliantunix
 | 
			
		||||
link_a.reliantunix-shared: link_a.reliantunix
 | 
			
		||||
link_app.reliantunix-shared: link_app.reliantunix
 | 
			
		||||
symlink.reliantunix-shared: symlink.reliantunix
 | 
			
		||||
							
								
								
									
										17
									
								
								NEWS
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								NEWS
									
									
									
									
									
								
							@@ -5,6 +5,13 @@
 | 
			
		||||
  This file gives a brief overview of the major changes between each OpenSSL
 | 
			
		||||
  release. For more details please read the CHANGES file.
 | 
			
		||||
 | 
			
		||||
  Major changes between OpenSSL 0.9.7b and OpenSSL 0.9.7c:
 | 
			
		||||
 | 
			
		||||
      o Security: fix various ASN1 parsing bugs.
 | 
			
		||||
      o New -ignore_err option to OCSP utility.
 | 
			
		||||
      o Various interop and bug fixes in S/MIME code.
 | 
			
		||||
      o SSL/TLS protocol fix for unrequested client certificates.
 | 
			
		||||
 | 
			
		||||
  Major changes between OpenSSL 0.9.7a and OpenSSL 0.9.7b:
 | 
			
		||||
 | 
			
		||||
      o Security: counter the Klima-Pokorny-Rosa extension of
 | 
			
		||||
@@ -40,11 +47,14 @@
 | 
			
		||||
      o New elliptic curve library section.
 | 
			
		||||
      o New AES (Rijndael) library section.
 | 
			
		||||
      o Support for new platforms: Windows CE, Tandem OSS, A/UX, AIX 64-bit,
 | 
			
		||||
        Linux x86_64
 | 
			
		||||
        Linux x86_64, Linux 64-bit on Sparc v9
 | 
			
		||||
      o Extended support for some platforms: VxWorks
 | 
			
		||||
      o Enhanced support for shared libraries.
 | 
			
		||||
      o Now only builds PIC code when shared library support is requested.
 | 
			
		||||
      o Support for pkg-config.
 | 
			
		||||
      o Lots of new manuals.
 | 
			
		||||
      o Makes symbolic links to or copies of manuals to cover all described
 | 
			
		||||
        functions.
 | 
			
		||||
      o Change DES API to clean up the namespace (some applications link also
 | 
			
		||||
        against libdes providing similar functions having the same name).
 | 
			
		||||
        Provide macros for backward compatibility (will be removed in the
 | 
			
		||||
@@ -70,6 +80,11 @@
 | 
			
		||||
      o SSL/TLS: add callback to retrieve SSL/TLS messages.
 | 
			
		||||
      o SSL/TLS: support AES cipher suites (RFC3268).
 | 
			
		||||
 | 
			
		||||
  Major changes between OpenSSL 0.9.6j and OpenSSL 0.9.6k:
 | 
			
		||||
 | 
			
		||||
      o Security: fix various ASN1 parsing bugs.
 | 
			
		||||
      o SSL/TLS protocol fix for unrequested client certificates.
 | 
			
		||||
 | 
			
		||||
  Major changes between OpenSSL 0.9.6i and OpenSSL 0.9.6j:
 | 
			
		||||
 | 
			
		||||
      o Security: counter the Klima-Pokorny-Rosa extension of
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										7
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								README
									
									
									
									
									
								
							@@ -1,7 +1,7 @@
 | 
			
		||||
 | 
			
		||||
 OpenSSL 0.9.8-dev XX xxx XXXX
 | 
			
		||||
 OpenSSL 0.9.7c 30 Sep 2003
 | 
			
		||||
 | 
			
		||||
 Copyright (c) 1998-2002 The OpenSSL Project
 | 
			
		||||
 Copyright (c) 1998-2003 The OpenSSL Project
 | 
			
		||||
 Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
 | 
			
		||||
 All rights reserved.
 | 
			
		||||
 | 
			
		||||
@@ -154,7 +154,7 @@
 | 
			
		||||
    - Stack Traceback (if the application dumps core)
 | 
			
		||||
 | 
			
		||||
 Report the bug to the OpenSSL project via the Request Tracker
 | 
			
		||||
 (http://www.openssl.org/rt2.html) by mail to:
 | 
			
		||||
 (http://www.openssl.org/support/rt2.html) by mail to:
 | 
			
		||||
 | 
			
		||||
    openssl-bugs@openssl.org
 | 
			
		||||
 | 
			
		||||
@@ -185,4 +185,3 @@
 | 
			
		||||
 # ./Configure dist; make clean
 | 
			
		||||
 # cd ..
 | 
			
		||||
 # diff -ur openssl-orig openssl-work > mydiffs.patch
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								STATUS
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								STATUS
									
									
									
									
									
								
							@@ -1,12 +1,16 @@
 | 
			
		||||
 | 
			
		||||
  OpenSSL STATUS                           Last modified at
 | 
			
		||||
  ______________                           $Date: 2003/02/28 15:17:45 $
 | 
			
		||||
  ______________                           $Date: 2003/10/02 10:55:20 $
 | 
			
		||||
 | 
			
		||||
  DEVELOPMENT STATE
 | 
			
		||||
 | 
			
		||||
    o  OpenSSL 0.9.8:  Under development...
 | 
			
		||||
    o  OpenSSL 0.9.7c: Released on September 30th, 2003
 | 
			
		||||
    o  OpenSSL 0.9.7b: Released on April     10th, 2003
 | 
			
		||||
    o  OpenSSL 0.9.7a: Released on February  19th, 2003
 | 
			
		||||
    o  OpenSSL 0.9.7:  Released on December  31st, 2002
 | 
			
		||||
    o  OpenSSL 0.9.6k: Released on September 30th, 2003
 | 
			
		||||
    o  OpenSSL 0.9.6j: Released on April     10th, 2003
 | 
			
		||||
    o  OpenSSL 0.9.6i: Released on February  19th, 2003
 | 
			
		||||
    o  OpenSSL 0.9.6h: Released on December   5th, 2002
 | 
			
		||||
    o  OpenSSL 0.9.6g: Released on August     9th, 2002
 | 
			
		||||
@@ -54,17 +58,9 @@
 | 
			
		||||
	Shared library support for VMS.
 | 
			
		||||
	Kerberos 5 authentication (Heimdal)
 | 
			
		||||
	Constification
 | 
			
		||||
	Compression
 | 
			
		||||
	Attribute Certificate support
 | 
			
		||||
	Certificate Pair support
 | 
			
		||||
	Storage Engines (primarly an LDAP storage engine)
 | 
			
		||||
	Certificate chain validation with full RFC 3280 compatibility
 | 
			
		||||
 | 
			
		||||
  NEEDS PATCH
 | 
			
		||||
 | 
			
		||||
    o  0.9.8-dev: COMPLEMENTOFALL and COMPLEMENTOFDEFAULT do not
 | 
			
		||||
       handle ECCdraft cipher suites correctly.
 | 
			
		||||
 | 
			
		||||
    o  apps/ca.c: "Sign the certificate?" - "n" creates empty certificate file
 | 
			
		||||
 | 
			
		||||
    o  "OpenSSL STATUS" is never up-to-date.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										190
									
								
								TABLE
									
									
									
									
									
								
							
							
						
						
									
										190
									
								
								TABLE
									
									
									
									
									
								
							@@ -634,7 +634,7 @@ $sys_id       =
 | 
			
		||||
$lflags       = 
 | 
			
		||||
$bn_ops       = BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL
 | 
			
		||||
$bn_obj       = 
 | 
			
		||||
$des_obj      = asm/des_enc-sparc.o fcrypt_b.o
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = 
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
@@ -659,7 +659,7 @@ $sys_id       =
 | 
			
		||||
$lflags       = 
 | 
			
		||||
$bn_ops       = SIXTY_FOUR_BIT_LONG DES_INT DES_PTR DES_RISC2 BF_PTR
 | 
			
		||||
$bn_obj       = 
 | 
			
		||||
$des_obj      = asm/des_enc-sparc.o fcrypt_b.o
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = 
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
@@ -1502,7 +1502,7 @@ $arflags      =
 | 
			
		||||
 | 
			
		||||
*** debug-ben
 | 
			
		||||
$cc           = gcc
 | 
			
		||||
$cflags       = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -O2 -pedantic -Wall -Wshadow -Werror -pipe
 | 
			
		||||
$cflags       = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -O2 -Wall -Wshadow -Werror -pipe
 | 
			
		||||
$unistd       = 
 | 
			
		||||
$thread_cflag = (unknown)
 | 
			
		||||
$sys_id       = 
 | 
			
		||||
@@ -1527,7 +1527,7 @@ $arflags      =
 | 
			
		||||
 | 
			
		||||
*** debug-ben-debug
 | 
			
		||||
$cc           = gcc
 | 
			
		||||
$cflags       = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe
 | 
			
		||||
$cflags       = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -g3 -O2 -Wall -Wshadow -Werror -pipe
 | 
			
		||||
$unistd       = 
 | 
			
		||||
$thread_cflag = (unknown)
 | 
			
		||||
$sys_id       = 
 | 
			
		||||
@@ -1550,6 +1550,31 @@ $shared_extension =
 | 
			
		||||
$ranlib       = 
 | 
			
		||||
$arflags      = 
 | 
			
		||||
 | 
			
		||||
*** debug-ben-fips-debug
 | 
			
		||||
$cc           = gcc
 | 
			
		||||
$cflags       = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DFIPS -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe
 | 
			
		||||
$unistd       = 
 | 
			
		||||
$thread_cflag = (unknown)
 | 
			
		||||
$sys_id       = 
 | 
			
		||||
$lflags       = 
 | 
			
		||||
$bn_ops       = 
 | 
			
		||||
$bn_obj       = asm/bn86-elf.o asm/co86-elf.o
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = 
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
$cast_obj     = 
 | 
			
		||||
$rc4_obj      = 
 | 
			
		||||
$rmd160_obj   = 
 | 
			
		||||
$rc5_obj      = 
 | 
			
		||||
$dso_scheme   = 
 | 
			
		||||
$shared_target= 
 | 
			
		||||
$shared_cflag = 
 | 
			
		||||
$shared_ldflag = 
 | 
			
		||||
$shared_extension = 
 | 
			
		||||
$ranlib       = 
 | 
			
		||||
$arflags      = 
 | 
			
		||||
 | 
			
		||||
*** debug-ben-openbsd
 | 
			
		||||
$cc           = gcc
 | 
			
		||||
$cflags       = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -O2 -pedantic -Wall -Wshadow -Werror -pipe
 | 
			
		||||
@@ -1952,16 +1977,16 @@ $arflags      =
 | 
			
		||||
 | 
			
		||||
*** debug-solaris-sparcv9-gcc
 | 
			
		||||
$cc           = gcc
 | 
			
		||||
$cflags       = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -DPEDANTIC -O -g -mcpu=ultrasparc -pedantic -ansi -Wall -Wshadow -Wno-long-long -D__EXTENSIONS__ -DB_ENDIAN -DBN_DIV2W
 | 
			
		||||
$cflags       = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -O -g -mcpu=ultrasparc -Wall -DB_ENDIAN
 | 
			
		||||
$unistd       = 
 | 
			
		||||
$thread_cflag = -D_REENTRANT
 | 
			
		||||
$sys_id       = ULTRASPARC
 | 
			
		||||
$sys_id       = 
 | 
			
		||||
$lflags       = -lsocket -lnsl -ldl
 | 
			
		||||
$bn_ops       = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
 | 
			
		||||
$bn_obj       = asm/sparcv8plus.o
 | 
			
		||||
$des_obj      = asm/des_enc-sparc.o fcrypt_b.o
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = asm/md5-sparcv8plus.o
 | 
			
		||||
$md5_obj      = 
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
$cast_obj     = 
 | 
			
		||||
$rc4_obj      = 
 | 
			
		||||
@@ -1993,7 +2018,7 @@ $rc4_obj      = asm/rx86-elf.o
 | 
			
		||||
$rmd160_obj   = asm/rm86-elf.o
 | 
			
		||||
$rc5_obj      = asm/r586-elf.o
 | 
			
		||||
$dso_scheme   = dlfcn
 | 
			
		||||
$shared_target= linux-shared
 | 
			
		||||
$shared_target= 
 | 
			
		||||
$shared_cflag = 
 | 
			
		||||
$shared_ldflag = 
 | 
			
		||||
$shared_extension = 
 | 
			
		||||
@@ -2010,7 +2035,7 @@ $lflags       = -rdynamic -ldl
 | 
			
		||||
$bn_ops       = SIXTY_FOUR_BIT
 | 
			
		||||
$bn_obj       = 
 | 
			
		||||
$des_obj      = dlfcn
 | 
			
		||||
$bf_obj       = linux-shared
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = 
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
$cast_obj     = 
 | 
			
		||||
@@ -3000,31 +3025,6 @@ $shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
 | 
			
		||||
$ranlib       = 
 | 
			
		||||
$arflags      = 
 | 
			
		||||
 | 
			
		||||
*** linux-ia32-icc
 | 
			
		||||
$cc           = icc
 | 
			
		||||
$cflags       = -DL_ENDIAN -DTERMIO -O2
 | 
			
		||||
$unistd       = 
 | 
			
		||||
$thread_cflag = -D_REENTRANT
 | 
			
		||||
$sys_id       = 
 | 
			
		||||
$lflags       = -ldl
 | 
			
		||||
$bn_ops       = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
 | 
			
		||||
$bn_obj       = asm/bn86-elf.o asm/co86-elf.o
 | 
			
		||||
$des_obj      = asm/dx86-elf.o asm/yx86-elf.o
 | 
			
		||||
$bf_obj       = asm/bx86-elf.o
 | 
			
		||||
$md5_obj      = asm/mx86-elf.o
 | 
			
		||||
$sha1_obj     = asm/sx86-elf.o
 | 
			
		||||
$cast_obj     = asm/cx86-elf.o
 | 
			
		||||
$rc4_obj      = asm/rx86-elf.o
 | 
			
		||||
$rmd160_obj   = asm/rm86-elf.o
 | 
			
		||||
$rc5_obj      = asm/r586-elf.o
 | 
			
		||||
$dso_scheme   = dlfcn
 | 
			
		||||
$shared_target= linux-shared
 | 
			
		||||
$shared_cflag = -KPIC
 | 
			
		||||
$shared_ldflag = 
 | 
			
		||||
$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
 | 
			
		||||
$ranlib       = 
 | 
			
		||||
$arflags      = 
 | 
			
		||||
 | 
			
		||||
*** linux-ia64
 | 
			
		||||
$cc           = gcc
 | 
			
		||||
$cflags       = -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall
 | 
			
		||||
@@ -3359,7 +3359,7 @@ $sys_id       =
 | 
			
		||||
$lflags       = -ldl
 | 
			
		||||
$bn_ops       = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
 | 
			
		||||
$bn_obj       = asm/sparcv8.o
 | 
			
		||||
$des_obj      = asm/des_enc-sparc.o fcrypt_b.o
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = 
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
@@ -3384,7 +3384,7 @@ $sys_id       = ULTRASPARC
 | 
			
		||||
$lflags       = -ldl
 | 
			
		||||
$bn_ops       = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
 | 
			
		||||
$bn_obj       = asm/sparcv8plus.o
 | 
			
		||||
$des_obj      = asm/des_enc-sparc.o fcrypt_b.o
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = asm/md5-sparcv8plus.o
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
@@ -3434,7 +3434,7 @@ $sys_id       = ULTRASPARC
 | 
			
		||||
$lflags       = -ldl
 | 
			
		||||
$bn_ops       = SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
 | 
			
		||||
$bn_obj       = 
 | 
			
		||||
$des_obj      = asm/des_enc-sparc.o fcrypt_b.o
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = asm/md5-sparcv9.o
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
@@ -3834,7 +3834,7 @@ $sys_id       =
 | 
			
		||||
$lflags       = -lsocket -lnsl -ldl
 | 
			
		||||
$bn_ops       = BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR
 | 
			
		||||
$bn_obj       = asm/sparcv8.o
 | 
			
		||||
$des_obj      = asm/des_enc-sparc.o fcrypt_b.o
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = 
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
@@ -3859,7 +3859,7 @@ $sys_id       =
 | 
			
		||||
$lflags       = -lsocket -lnsl -ldl
 | 
			
		||||
$bn_ops       = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
 | 
			
		||||
$bn_obj       = asm/sparcv8.o
 | 
			
		||||
$des_obj      = asm/des_enc-sparc.o fcrypt_b.o
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = 
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
@@ -3884,7 +3884,7 @@ $sys_id       = ULTRASPARC
 | 
			
		||||
$lflags       = -lsocket -lnsl -ldl
 | 
			
		||||
$bn_ops       = BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR
 | 
			
		||||
$bn_obj       = asm/sparcv8plus.o
 | 
			
		||||
$des_obj      = asm/des_enc-sparc.o fcrypt_b.o
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = asm/md5-sparcv8plus.o
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
@@ -3909,7 +3909,7 @@ $sys_id       = ULTRASPARC
 | 
			
		||||
$lflags       = -lsocket -lnsl -ldl
 | 
			
		||||
$bn_ops       = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
 | 
			
		||||
$bn_obj       = asm/sparcv8plus.o
 | 
			
		||||
$des_obj      = asm/des_enc-sparc.o fcrypt_b.o
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = asm/md5-sparcv8plus.o
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
@@ -3934,7 +3934,7 @@ $sys_id       = ULTRASPARC
 | 
			
		||||
$lflags       = -lsocket -lnsl -ldl
 | 
			
		||||
$bn_ops       = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
 | 
			
		||||
$bn_obj       = asm/sparcv8plus-gcc27.o
 | 
			
		||||
$des_obj      = asm/des_enc-sparc.o fcrypt_b.o
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = asm/md5-sparcv8plus-gcc27.o
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
@@ -4009,7 +4009,7 @@ $sys_id       = ULTRASPARC
 | 
			
		||||
$lflags       = -lsocket -lnsl -ldl
 | 
			
		||||
$bn_ops       = SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR
 | 
			
		||||
$bn_obj       = 
 | 
			
		||||
$des_obj      = asm/des_enc-sparc.o fcrypt_b.o
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = asm/md5-sparcv9.o
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
@@ -4034,7 +4034,32 @@ $sys_id       = ULTRASPARC
 | 
			
		||||
$lflags       = -lsocket -lnsl -ldl
 | 
			
		||||
$bn_ops       = SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR
 | 
			
		||||
$bn_obj       = 
 | 
			
		||||
$des_obj      = asm/des_enc-sparc.o fcrypt_b.o
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = asm/md5-sparcv9.o
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
$cast_obj     = 
 | 
			
		||||
$rc4_obj      = 
 | 
			
		||||
$rmd160_obj   = 
 | 
			
		||||
$rc5_obj      = 
 | 
			
		||||
$dso_scheme   = dlfcn
 | 
			
		||||
$shared_target= solaris-shared
 | 
			
		||||
$shared_cflag = -fPIC
 | 
			
		||||
$shared_ldflag = -m64 -shared
 | 
			
		||||
$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
 | 
			
		||||
$ranlib       = 
 | 
			
		||||
$arflags      = 
 | 
			
		||||
 | 
			
		||||
*** solaris64-sparcv9-gcc31
 | 
			
		||||
$cc           = gcc
 | 
			
		||||
$cflags       = -mcpu=ultrasparc -m64 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN
 | 
			
		||||
$unistd       = 
 | 
			
		||||
$thread_cflag = -D_REENTRANT
 | 
			
		||||
$sys_id       = ULTRASPARC
 | 
			
		||||
$lflags       = -lsocket -lnsl -ldl
 | 
			
		||||
$bn_ops       = SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR
 | 
			
		||||
$bn_obj       = 
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = asm/md5-sparcv9.o
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
@@ -4250,6 +4275,31 @@ $shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
 | 
			
		||||
$ranlib       = 
 | 
			
		||||
$arflags      = 
 | 
			
		||||
 | 
			
		||||
*** vxworks-mipsle
 | 
			
		||||
$cc           = ccmips
 | 
			
		||||
$cflags       = -B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ -DL_ENDIAN -EL -Wl,-EL -mips2 -mno-branch-likely -G 0 -fno-builtin -msoft-float -DCPU=MIPS32 -DMIPSEL -DNO_STRINGS_H -I$(WIND_BASE)/target/h
 | 
			
		||||
$unistd       = 
 | 
			
		||||
$thread_cflag = 
 | 
			
		||||
$sys_id       = VXWORKS
 | 
			
		||||
$lflags       = -r
 | 
			
		||||
$bn_ops       = 
 | 
			
		||||
$bn_obj       = 
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = 
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
$cast_obj     = 
 | 
			
		||||
$rc4_obj      = 
 | 
			
		||||
$rmd160_obj   = 
 | 
			
		||||
$rc5_obj      = 
 | 
			
		||||
$dso_scheme   = 
 | 
			
		||||
$shared_target= 
 | 
			
		||||
$shared_cflag = 
 | 
			
		||||
$shared_ldflag = 
 | 
			
		||||
$shared_extension = 
 | 
			
		||||
$ranlib       = ranlibmips
 | 
			
		||||
$arflags      = 
 | 
			
		||||
 | 
			
		||||
*** vxworks-ppc405
 | 
			
		||||
$cc           = ccppc
 | 
			
		||||
$cflags       = -g -msoft-float -mlongcall -DCPU=PPC405 -I$(WIND_BASE)/target/h
 | 
			
		||||
@@ -4324,3 +4374,53 @@ $shared_ldflag =
 | 
			
		||||
$shared_extension = 
 | 
			
		||||
$ranlib       = 
 | 
			
		||||
$arflags      = 
 | 
			
		||||
 | 
			
		||||
*** vxworks-ppc860
 | 
			
		||||
$cc           = ccppc
 | 
			
		||||
$cflags       = -g -msoft-float -DCPU=PPC860 -DNO_STRINGS_H -I$(WIND_BASE)/target/h
 | 
			
		||||
$unistd       = 
 | 
			
		||||
$thread_cflag = 
 | 
			
		||||
$sys_id       = VXWORKS
 | 
			
		||||
$lflags       = -r
 | 
			
		||||
$bn_ops       = 
 | 
			
		||||
$bn_obj       = 
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = 
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
$cast_obj     = 
 | 
			
		||||
$rc4_obj      = 
 | 
			
		||||
$rmd160_obj   = 
 | 
			
		||||
$rc5_obj      = 
 | 
			
		||||
$dso_scheme   = 
 | 
			
		||||
$shared_target= 
 | 
			
		||||
$shared_cflag = 
 | 
			
		||||
$shared_ldflag = 
 | 
			
		||||
$shared_extension = 
 | 
			
		||||
$ranlib       = 
 | 
			
		||||
$arflags      = 
 | 
			
		||||
 | 
			
		||||
*** vxworks-ppc860
 | 
			
		||||
$cc           = ccppc
 | 
			
		||||
$cflags       = -nostdinc -msoft-float -DCPU=PPC860 -DNO_STRINGS_H -I$(WIND_BASE)/target/h
 | 
			
		||||
$unistd       = 
 | 
			
		||||
$thread_cflag = 
 | 
			
		||||
$sys_id       = VXWORKS
 | 
			
		||||
$lflags       = -r
 | 
			
		||||
$bn_ops       = 
 | 
			
		||||
$bn_obj       = 
 | 
			
		||||
$des_obj      = 
 | 
			
		||||
$bf_obj       = 
 | 
			
		||||
$md5_obj      = 
 | 
			
		||||
$sha1_obj     = 
 | 
			
		||||
$cast_obj     = 
 | 
			
		||||
$rc4_obj      = 
 | 
			
		||||
$rmd160_obj   = 
 | 
			
		||||
$rc5_obj      = 
 | 
			
		||||
$dso_scheme   = 
 | 
			
		||||
$shared_target= 
 | 
			
		||||
$shared_cflag = 
 | 
			
		||||
$shared_ldflag = 
 | 
			
		||||
$shared_extension = 
 | 
			
		||||
$ranlib       = 
 | 
			
		||||
$arflags      = 
 | 
			
		||||
 
 | 
			
		||||
@@ -285,7 +285,6 @@ $       if alg_entry .eqs. "" then goto loop2
 | 
			
		||||
$       if alg_entry .nes. ","
 | 
			
		||||
$       then
 | 
			
		||||
$         if alg_entry .eqs. "KRB5" then goto loop ! Special for now
 | 
			
		||||
$	  if alg_entry .eqs. "STATIC_ENGINE" then goto loop ! Special for now
 | 
			
		||||
$         if f$trnlnm("OPENSSL_NO_"+alg_entry) .nes. "" then goto loop
 | 
			
		||||
$	  goto loop2
 | 
			
		||||
$       endif
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								VMS/tcpip_shr_decc.opt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								VMS/tcpip_shr_decc.opt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
sys$share:tcpip$ipc_shr.exe/share
 | 
			
		||||
@@ -37,8 +37,7 @@
 | 
			
		||||
# demoCA ... where everything is stored
 | 
			
		||||
 | 
			
		||||
$SSLEAY_CONFIG=$ENV{"SSLEAY_CONFIG"};
 | 
			
		||||
$DAYS="-days 365";	# 1 year
 | 
			
		||||
$CADAYS="-days 1095";	# 3 years
 | 
			
		||||
$DAYS="-days 365";
 | 
			
		||||
$REQ="openssl req $SSLEAY_CONFIG";
 | 
			
		||||
$CA="openssl ca $SSLEAY_CONFIG";
 | 
			
		||||
$VERIFY="openssl verify";
 | 
			
		||||
@@ -47,7 +46,6 @@ $PKCS12="openssl pkcs12";
 | 
			
		||||
 | 
			
		||||
$CATOP="./demoCA";
 | 
			
		||||
$CAKEY="cakey.pem";
 | 
			
		||||
$CAREQ="careq.pem";
 | 
			
		||||
$CACERT="cacert.pem";
 | 
			
		||||
 | 
			
		||||
$DIRMODE = 0777;
 | 
			
		||||
@@ -103,11 +101,8 @@ foreach (@ARGV) {
 | 
			
		||||
		    $RET=$?;
 | 
			
		||||
		} else {
 | 
			
		||||
		    print "Making CA certificate ...\n";
 | 
			
		||||
		    system ("$REQ -new -keyout " .
 | 
			
		||||
			"${CATOP}/private/$CAKEY -out ${CATOP}/$CAREQ");
 | 
			
		||||
		    system ("$CA -out ${CATOP}/$CACERT $CADAYS -batch " . 
 | 
			
		||||
			"-keyfile ${CATOP}/private/$CAKEY -selfsign " .
 | 
			
		||||
			"-infiles ${CATOP}/$CAREQ ");
 | 
			
		||||
		    system ("$REQ -new -x509 -keyout " .
 | 
			
		||||
			"${CATOP}/private/$CAKEY -out ${CATOP}/$CACERT $DAYS");
 | 
			
		||||
		    $RET=$?;
 | 
			
		||||
		}
 | 
			
		||||
	    }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										13
									
								
								apps/CA.sh
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								apps/CA.sh
									
									
									
									
									
								
							@@ -30,8 +30,7 @@
 | 
			
		||||
# default openssl.cnf file has setup as per the following
 | 
			
		||||
# demoCA ... where everything is stored
 | 
			
		||||
 | 
			
		||||
DAYS="-days 365"	# 1 year
 | 
			
		||||
CADAYS="-days 1095"	# 3 years
 | 
			
		||||
DAYS="-days 365"
 | 
			
		||||
REQ="openssl req $SSLEAY_CONFIG"
 | 
			
		||||
CA="openssl ca $SSLEAY_CONFIG"
 | 
			
		||||
VERIFY="openssl verify"
 | 
			
		||||
@@ -39,7 +38,6 @@ X509="openssl x509"
 | 
			
		||||
 | 
			
		||||
CATOP=./demoCA
 | 
			
		||||
CAKEY=./cakey.pem
 | 
			
		||||
CAREQ=./careq.pem
 | 
			
		||||
CACERT=./cacert.pem
 | 
			
		||||
 | 
			
		||||
for i
 | 
			
		||||
@@ -72,7 +70,7 @@ case $i in
 | 
			
		||||
	mkdir ${CATOP}/crl 
 | 
			
		||||
	mkdir ${CATOP}/newcerts
 | 
			
		||||
	mkdir ${CATOP}/private
 | 
			
		||||
	echo "00" > ${CATOP}/serial
 | 
			
		||||
	echo "01" > ${CATOP}/serial
 | 
			
		||||
	touch ${CATOP}/index.txt
 | 
			
		||||
    fi
 | 
			
		||||
    if [ ! -f ${CATOP}/private/$CAKEY ]; then
 | 
			
		||||
@@ -85,11 +83,8 @@ case $i in
 | 
			
		||||
	    RET=$?
 | 
			
		||||
	else
 | 
			
		||||
	    echo "Making CA certificate ..."
 | 
			
		||||
	    $REQ -new -keyout ${CATOP}/private/$CAKEY \
 | 
			
		||||
			   -out ${CATOP}/$CAREQ
 | 
			
		||||
	    $CA -out ${CATOP}/$CACERT $CADAYS -batch \
 | 
			
		||||
			   -keyfile ${CATOP}/private/$CAKEY -selfsign \
 | 
			
		||||
			   -infiles ${CATOP}/$CAREQ 
 | 
			
		||||
	    $REQ -new -x509 -keyout ${CATOP}/private/$CAKEY \
 | 
			
		||||
			   -out ${CATOP}/$CACERT $DAYS
 | 
			
		||||
	    RET=$?
 | 
			
		||||
	fi
 | 
			
		||||
    fi
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1536
									
								
								apps/Makefile.ssl
									
									
									
									
									
								
							
							
						
						
									
										1536
									
								
								apps/Makefile.ssl
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										554
									
								
								apps/apps.c
									
									
									
									
									
								
							
							
						
						
									
										554
									
								
								apps/apps.c
									
									
									
									
									
								
							@@ -1396,557 +1396,3 @@ char *make_config_name()
 | 
			
		||||
 | 
			
		||||
	return p;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static unsigned long index_serial_hash(const char **a)
 | 
			
		||||
	{
 | 
			
		||||
	const char *n;
 | 
			
		||||
 | 
			
		||||
	n=a[DB_serial];
 | 
			
		||||
	while (*n == '0') n++;
 | 
			
		||||
	return(lh_strhash(n));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int index_serial_cmp(const char **a, const char **b)
 | 
			
		||||
	{
 | 
			
		||||
	const char *aa,*bb;
 | 
			
		||||
 | 
			
		||||
	for (aa=a[DB_serial]; *aa == '0'; aa++);
 | 
			
		||||
	for (bb=b[DB_serial]; *bb == '0'; bb++);
 | 
			
		||||
	return(strcmp(aa,bb));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int index_name_qual(char **a)
 | 
			
		||||
	{ return(a[0][0] == 'V'); }
 | 
			
		||||
 | 
			
		||||
static unsigned long index_name_hash(const char **a)
 | 
			
		||||
	{ return(lh_strhash(a[DB_name])); }
 | 
			
		||||
 | 
			
		||||
int index_name_cmp(const char **a, const char **b)
 | 
			
		||||
	{ return(strcmp(a[DB_name],
 | 
			
		||||
	     b[DB_name])); }
 | 
			
		||||
 | 
			
		||||
static IMPLEMENT_LHASH_HASH_FN(index_serial_hash,const char **)
 | 
			
		||||
static IMPLEMENT_LHASH_COMP_FN(index_serial_cmp,const char **)
 | 
			
		||||
static IMPLEMENT_LHASH_HASH_FN(index_name_hash,const char **)
 | 
			
		||||
static IMPLEMENT_LHASH_COMP_FN(index_name_cmp,const char **)
 | 
			
		||||
 | 
			
		||||
#undef BSIZE
 | 
			
		||||
#define BSIZE 256
 | 
			
		||||
 | 
			
		||||
BIGNUM *load_serial(char *serialfile, int create, ASN1_INTEGER **retai)
 | 
			
		||||
	{
 | 
			
		||||
	BIO *in=NULL;
 | 
			
		||||
	BIGNUM *ret=NULL;
 | 
			
		||||
	MS_STATIC char buf[1024];
 | 
			
		||||
	ASN1_INTEGER *ai=NULL;
 | 
			
		||||
 | 
			
		||||
	ai=ASN1_INTEGER_new();
 | 
			
		||||
	if (ai == NULL) goto err;
 | 
			
		||||
 | 
			
		||||
	if ((in=BIO_new(BIO_s_file())) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		ERR_print_errors(bio_err);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (BIO_read_filename(in,serialfile) <= 0)
 | 
			
		||||
		{
 | 
			
		||||
		if (!create)
 | 
			
		||||
			{
 | 
			
		||||
			perror(serialfile);
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			ASN1_INTEGER_set(ai,1);
 | 
			
		||||
			ret=BN_new();
 | 
			
		||||
			if (ret == NULL)
 | 
			
		||||
				BIO_printf(bio_err, "Out of memory\n");
 | 
			
		||||
			else
 | 
			
		||||
				BN_one(ret);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
		if (!a2i_ASN1_INTEGER(in,ai,buf,1024))
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,"unable to load number from %s\n",
 | 
			
		||||
				serialfile);
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		ret=ASN1_INTEGER_to_BN(ai,NULL);
 | 
			
		||||
		if (ret == NULL)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,"error converting number from bin to BIGNUM\n");
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (ret && retai)
 | 
			
		||||
		{
 | 
			
		||||
		*retai = ai;
 | 
			
		||||
		ai = NULL;
 | 
			
		||||
		}
 | 
			
		||||
 err:
 | 
			
		||||
	if (in != NULL) BIO_free(in);
 | 
			
		||||
	if (ai != NULL) ASN1_INTEGER_free(ai);
 | 
			
		||||
	return(ret);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int save_serial(char *serialfile, char *suffix, BIGNUM *serial, ASN1_INTEGER **retai)
 | 
			
		||||
	{
 | 
			
		||||
	char buf[1][BSIZE];
 | 
			
		||||
	BIO *out = NULL;
 | 
			
		||||
	int ret=0;
 | 
			
		||||
	ASN1_INTEGER *ai=NULL;
 | 
			
		||||
	int j;
 | 
			
		||||
 | 
			
		||||
	if (suffix == NULL)
 | 
			
		||||
		j = strlen(serialfile);
 | 
			
		||||
	else
 | 
			
		||||
		j = strlen(serialfile) + strlen(suffix) + 1;
 | 
			
		||||
	if (j >= BSIZE)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"file name too long\n");
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (suffix == NULL)
 | 
			
		||||
		BUF_strlcpy(buf[0], serialfile, BSIZE);
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
#ifndef OPENSSL_SYS_VMS
 | 
			
		||||
		j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", serialfile, suffix);
 | 
			
		||||
#else
 | 
			
		||||
		j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", serialfile, suffix);
 | 
			
		||||
#endif
 | 
			
		||||
		}
 | 
			
		||||
#ifdef RL_DEBUG
 | 
			
		||||
	BIO_printf(bio_err, "DEBUG: writing \"%s\"\n", buf[0]);
 | 
			
		||||
#endif
 | 
			
		||||
	out=BIO_new(BIO_s_file());
 | 
			
		||||
	if (out == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		ERR_print_errors(bio_err);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	if (BIO_write_filename(out,buf[0]) <= 0)
 | 
			
		||||
		{
 | 
			
		||||
		perror(serialfile);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if ((ai=BN_to_ASN1_INTEGER(serial,NULL)) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"error converting serial to ASN.1 format\n");
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	i2a_ASN1_INTEGER(out,ai);
 | 
			
		||||
	BIO_puts(out,"\n");
 | 
			
		||||
	ret=1;
 | 
			
		||||
	if (retai)
 | 
			
		||||
		{
 | 
			
		||||
		*retai = ai;
 | 
			
		||||
		ai = NULL;
 | 
			
		||||
		}
 | 
			
		||||
err:
 | 
			
		||||
	if (out != NULL) BIO_free_all(out);
 | 
			
		||||
	if (ai != NULL) ASN1_INTEGER_free(ai);
 | 
			
		||||
	return(ret);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int rotate_serial(char *serialfile, char *new_suffix, char *old_suffix)
 | 
			
		||||
	{
 | 
			
		||||
	char buf[5][BSIZE];
 | 
			
		||||
	int i,j;
 | 
			
		||||
	struct stat sb;
 | 
			
		||||
 | 
			
		||||
	i = strlen(serialfile) + strlen(old_suffix);
 | 
			
		||||
	j = strlen(serialfile) + strlen(new_suffix);
 | 
			
		||||
	if (i > j) j = i;
 | 
			
		||||
	if (j + 1 >= BSIZE)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"file name too long\n");
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_SYS_VMS
 | 
			
		||||
	j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s",
 | 
			
		||||
		serialfile, new_suffix);
 | 
			
		||||
#else
 | 
			
		||||
	j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s",
 | 
			
		||||
		serialfile, new_suffix);
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_SYS_VMS
 | 
			
		||||
	j = BIO_snprintf(buf[1], sizeof buf[1], "%s.%s",
 | 
			
		||||
		serialfile, old_suffix);
 | 
			
		||||
#else
 | 
			
		||||
	j = BIO_snprintf(buf[1], sizeof buf[1], "%s-%s",
 | 
			
		||||
		serialfile, old_suffix);
 | 
			
		||||
#endif
 | 
			
		||||
	if (stat(serialfile,&sb) < 0)
 | 
			
		||||
		{
 | 
			
		||||
		if (errno != ENOENT 
 | 
			
		||||
#ifdef ENOTDIR
 | 
			
		||||
			&& errno != ENOTDIR)
 | 
			
		||||
#endif
 | 
			
		||||
			goto err;
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
#ifdef RL_DEBUG
 | 
			
		||||
		BIO_printf(bio_err, "DEBUG: renaming \"%s\" to \"%s\"\n",
 | 
			
		||||
			serialfile, buf[1]);
 | 
			
		||||
#endif
 | 
			
		||||
		if (rename(serialfile,buf[1]) < 0)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,
 | 
			
		||||
				"unable to rename %s to %s\n",
 | 
			
		||||
				serialfile, buf[1]);
 | 
			
		||||
			perror("reason");
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
#ifdef RL_DEBUG
 | 
			
		||||
	BIO_printf(bio_err, "DEBUG: renaming \"%s\" to \"%s\"\n",
 | 
			
		||||
		buf[0],serialfile);
 | 
			
		||||
#endif
 | 
			
		||||
	if (rename(buf[0],serialfile) < 0)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,
 | 
			
		||||
			"unable to rename %s to %s\n",
 | 
			
		||||
			buf[0],serialfile);
 | 
			
		||||
		perror("reason");
 | 
			
		||||
		rename(buf[1],serialfile);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	return 1;
 | 
			
		||||
 err:
 | 
			
		||||
	return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
CA_DB *load_index(char *dbfile, DB_ATTR *db_attr)
 | 
			
		||||
	{
 | 
			
		||||
	CA_DB *retdb = NULL;
 | 
			
		||||
	TXT_DB *tmpdb = NULL;
 | 
			
		||||
	BIO *in = BIO_new(BIO_s_file());
 | 
			
		||||
	CONF *dbattr_conf = NULL;
 | 
			
		||||
	char buf[1][BSIZE];
 | 
			
		||||
	long errorline= -1;
 | 
			
		||||
 | 
			
		||||
	if (in == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		ERR_print_errors(bio_err);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	if (BIO_read_filename(in,dbfile) <= 0)
 | 
			
		||||
		{
 | 
			
		||||
		perror(dbfile);
 | 
			
		||||
		BIO_printf(bio_err,"unable to open '%s'\n",dbfile);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	if ((tmpdb = TXT_DB_read(in,DB_NUMBER)) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		if (tmpdb != NULL) TXT_DB_free(tmpdb);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_SYS_VMS
 | 
			
		||||
	BIO_snprintf(buf[0], sizeof buf[0], "%s.attr", dbfile);
 | 
			
		||||
#else
 | 
			
		||||
	BIO_snprintf(buf[0], sizeof buf[0], "%s-attr", dbfile);
 | 
			
		||||
#endif
 | 
			
		||||
	dbattr_conf = NCONF_new(NULL);
 | 
			
		||||
	if (NCONF_load(dbattr_conf,buf[0],&errorline) <= 0)
 | 
			
		||||
		{
 | 
			
		||||
		if (errorline > 0)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,
 | 
			
		||||
				"error on line %ld of db attribute file '%s'\n"
 | 
			
		||||
				,errorline,buf[0]);
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			NCONF_free(dbattr_conf);
 | 
			
		||||
			dbattr_conf = NULL;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if ((retdb = OPENSSL_malloc(sizeof(CA_DB))) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		fprintf(stderr, "Out of memory\n");
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	retdb->db = tmpdb;
 | 
			
		||||
	tmpdb = NULL;
 | 
			
		||||
	if (db_attr)
 | 
			
		||||
		retdb->attributes = *db_attr;
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
		retdb->attributes.unique_subject = 1;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (dbattr_conf)
 | 
			
		||||
		{
 | 
			
		||||
		char *p = NCONF_get_string(dbattr_conf,NULL,"unique_subject");
 | 
			
		||||
		if (p)
 | 
			
		||||
			{
 | 
			
		||||
#ifdef RL_DEBUG
 | 
			
		||||
			BIO_printf(bio_err, "DEBUG[load_index]: unique_subject = \"%s\"\n", p);
 | 
			
		||||
#endif
 | 
			
		||||
			switch(*p)
 | 
			
		||||
				{
 | 
			
		||||
			case 'f': /* false */
 | 
			
		||||
			case 'F': /* FALSE */
 | 
			
		||||
			case 'n': /* no */
 | 
			
		||||
			case 'N': /* NO */
 | 
			
		||||
				retdb->attributes.unique_subject = 0;
 | 
			
		||||
				break;
 | 
			
		||||
			case 't': /* true */
 | 
			
		||||
			case 'T': /* TRUE */
 | 
			
		||||
			case 'y': /* yes */
 | 
			
		||||
			case 'Y': /* YES */
 | 
			
		||||
			default:
 | 
			
		||||
				retdb->attributes.unique_subject = 1;
 | 
			
		||||
				break;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 err:
 | 
			
		||||
	if (dbattr_conf) NCONF_free(dbattr_conf);
 | 
			
		||||
	if (tmpdb) TXT_DB_free(tmpdb);
 | 
			
		||||
	if (in) BIO_free_all(in);
 | 
			
		||||
	return retdb;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int index_index(CA_DB *db)
 | 
			
		||||
	{
 | 
			
		||||
	if (!TXT_DB_create_index(db->db, DB_serial, NULL,
 | 
			
		||||
				LHASH_HASH_FN(index_serial_hash),
 | 
			
		||||
				LHASH_COMP_FN(index_serial_cmp)))
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,
 | 
			
		||||
		  "error creating serial number index:(%ld,%ld,%ld)\n",
 | 
			
		||||
		  			db->db->error,db->db->arg1,db->db->arg2);
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (db->attributes.unique_subject
 | 
			
		||||
		&& !TXT_DB_create_index(db->db, DB_name, index_name_qual,
 | 
			
		||||
			LHASH_HASH_FN(index_name_hash),
 | 
			
		||||
			LHASH_COMP_FN(index_name_cmp)))
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"error creating name index:(%ld,%ld,%ld)\n",
 | 
			
		||||
			db->db->error,db->db->arg1,db->db->arg2);
 | 
			
		||||
		return 0;
 | 
			
		||||
		}
 | 
			
		||||
	return 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int save_index(char *dbfile, char *suffix, CA_DB *db)
 | 
			
		||||
	{
 | 
			
		||||
	char buf[3][BSIZE];
 | 
			
		||||
	BIO *out = BIO_new(BIO_s_file());
 | 
			
		||||
	int j;
 | 
			
		||||
 | 
			
		||||
	if (out == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		ERR_print_errors(bio_err);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	j = strlen(dbfile) + strlen(suffix);
 | 
			
		||||
	if (j + 6 >= BSIZE)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"file name too long\n");
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_SYS_VMS
 | 
			
		||||
	j = BIO_snprintf(buf[2], sizeof buf[2], "%s.attr", dbfile);
 | 
			
		||||
#else
 | 
			
		||||
	j = BIO_snprintf(buf[2], sizeof buf[2], "%s-attr", dbfile);
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_SYS_VMS
 | 
			
		||||
	j = BIO_snprintf(buf[1], sizeof buf[1], "%s.attr.%s", dbfile, suffix);
 | 
			
		||||
#else
 | 
			
		||||
	j = BIO_snprintf(buf[1], sizeof buf[1], "%s-attr-%s", dbfile, suffix);
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_SYS_VMS
 | 
			
		||||
	j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", dbfile, suffix);
 | 
			
		||||
#else
 | 
			
		||||
	j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", dbfile, suffix);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef RL_DEBUG
 | 
			
		||||
	BIO_printf(bio_err, "DEBUG: writing \"%s\"\n", buf[0]);
 | 
			
		||||
#endif
 | 
			
		||||
	if (BIO_write_filename(out,buf[0]) <= 0)
 | 
			
		||||
		{
 | 
			
		||||
		perror(dbfile);
 | 
			
		||||
		BIO_printf(bio_err,"unable to open '%s'\n", dbfile);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	j=TXT_DB_write(out,db->db);
 | 
			
		||||
	if (j <= 0) goto err;
 | 
			
		||||
			
 | 
			
		||||
	BIO_free(out);
 | 
			
		||||
 | 
			
		||||
	out = BIO_new(BIO_s_file());
 | 
			
		||||
#ifdef RL_DEBUG
 | 
			
		||||
	BIO_printf(bio_err, "DEBUG: writing \"%s\"\n", buf[1]);
 | 
			
		||||
#endif
 | 
			
		||||
	if (BIO_write_filename(out,buf[1]) <= 0)
 | 
			
		||||
		{
 | 
			
		||||
		perror(buf[2]);
 | 
			
		||||
		BIO_printf(bio_err,"unable to open '%s'\n", buf[2]);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	BIO_printf(out,"unique_subject = %s\n",
 | 
			
		||||
		db->attributes.unique_subject ? "yes" : "no");
 | 
			
		||||
	BIO_free(out);
 | 
			
		||||
 | 
			
		||||
	return 1;
 | 
			
		||||
 err:
 | 
			
		||||
	return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int rotate_index(char *dbfile, char *new_suffix, char *old_suffix)
 | 
			
		||||
	{
 | 
			
		||||
	char buf[5][BSIZE];
 | 
			
		||||
	int i,j;
 | 
			
		||||
	struct stat sb;
 | 
			
		||||
 | 
			
		||||
	i = strlen(dbfile) + strlen(old_suffix);
 | 
			
		||||
	j = strlen(dbfile) + strlen(new_suffix);
 | 
			
		||||
	if (i > j) j = i;
 | 
			
		||||
	if (j + 6 >= BSIZE)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"file name too long\n");
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_SYS_VMS
 | 
			
		||||
	j = BIO_snprintf(buf[4], sizeof buf[4], "%s.attr", dbfile);
 | 
			
		||||
#else
 | 
			
		||||
	j = BIO_snprintf(buf[4], sizeof buf[4], "%s-attr", dbfile);
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_SYS_VMS
 | 
			
		||||
	j = BIO_snprintf(buf[2], sizeof buf[2], "%s.attr.%s",
 | 
			
		||||
		dbfile, new_suffix);
 | 
			
		||||
#else
 | 
			
		||||
	j = BIO_snprintf(buf[2], sizeof buf[2], "%s-attr-%s",
 | 
			
		||||
		dbfile, new_suffix);
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_SYS_VMS
 | 
			
		||||
	j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s",
 | 
			
		||||
		dbfile, new_suffix);
 | 
			
		||||
#else
 | 
			
		||||
	j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s",
 | 
			
		||||
		dbfile, new_suffix);
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_SYS_VMS
 | 
			
		||||
	j = BIO_snprintf(buf[1], sizeof buf[1], "%s.%s",
 | 
			
		||||
		dbfile, old_suffix);
 | 
			
		||||
#else
 | 
			
		||||
	j = BIO_snprintf(buf[1], sizeof buf[1], "%s-%s",
 | 
			
		||||
		dbfile, old_suffix);
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_SYS_VMS
 | 
			
		||||
	j = BIO_snprintf(buf[3], sizeof buf[3], "%s.attr.%s",
 | 
			
		||||
		dbfile, old_suffix);
 | 
			
		||||
#else
 | 
			
		||||
	j = BIO_snprintf(buf[3], sizeof buf[3], "%s-attr-%s",
 | 
			
		||||
		dbfile, old_suffix);
 | 
			
		||||
#endif
 | 
			
		||||
	if (stat(dbfile,&sb) < 0)
 | 
			
		||||
		{
 | 
			
		||||
		if (errno != ENOENT 
 | 
			
		||||
#ifdef ENOTDIR
 | 
			
		||||
			&& errno != ENOTDIR)
 | 
			
		||||
#endif
 | 
			
		||||
			goto err;
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
#ifdef RL_DEBUG
 | 
			
		||||
		BIO_printf(bio_err, "DEBUG: renaming \"%s\" to \"%s\"\n",
 | 
			
		||||
			dbfile, buf[1]);
 | 
			
		||||
#endif
 | 
			
		||||
		if (rename(dbfile,buf[1]) < 0)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,
 | 
			
		||||
				"unable to rename %s to %s\n",
 | 
			
		||||
				dbfile, buf[1]);
 | 
			
		||||
			perror("reason");
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
#ifdef RL_DEBUG
 | 
			
		||||
	BIO_printf(bio_err, "DEBUG: renaming \"%s\" to \"%s\"\n",
 | 
			
		||||
		buf[0],dbfile);
 | 
			
		||||
#endif
 | 
			
		||||
	if (rename(buf[0],dbfile) < 0)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,
 | 
			
		||||
			"unable to rename %s to %s\n",
 | 
			
		||||
			buf[0],dbfile);
 | 
			
		||||
		perror("reason");
 | 
			
		||||
		rename(buf[1],dbfile);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	if (stat(buf[4],&sb) < 0)
 | 
			
		||||
		{
 | 
			
		||||
		if (errno != ENOENT 
 | 
			
		||||
#ifdef ENOTDIR
 | 
			
		||||
			&& errno != ENOTDIR)
 | 
			
		||||
#endif
 | 
			
		||||
			goto err;
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
#ifdef RL_DEBUG
 | 
			
		||||
		BIO_printf(bio_err, "DEBUG: renaming \"%s\" to \"%s\"\n",
 | 
			
		||||
			buf[4],buf[3]);
 | 
			
		||||
#endif
 | 
			
		||||
		if (rename(buf[4],buf[3]) < 0)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,
 | 
			
		||||
				"unable to rename %s to %s\n",
 | 
			
		||||
				buf[4], buf[3]);
 | 
			
		||||
			perror("reason");
 | 
			
		||||
			rename(dbfile,buf[0]);
 | 
			
		||||
			rename(buf[1],dbfile);
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
#ifdef RL_DEBUG
 | 
			
		||||
	BIO_printf(bio_err, "DEBUG: renaming \"%s\" to \"%s\"\n",
 | 
			
		||||
		buf[2],buf[4]);
 | 
			
		||||
#endif
 | 
			
		||||
	if (rename(buf[2],buf[4]) < 0)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,
 | 
			
		||||
			"unable to rename %s to %s\n",
 | 
			
		||||
			buf[2],buf[4]);
 | 
			
		||||
		perror("reason");
 | 
			
		||||
		rename(buf[3],buf[4]);
 | 
			
		||||
		rename(dbfile,buf[0]);
 | 
			
		||||
		rename(buf[1],dbfile);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	return 1;
 | 
			
		||||
 err:
 | 
			
		||||
	return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
void free_index(CA_DB *db)
 | 
			
		||||
	{
 | 
			
		||||
	if (db)
 | 
			
		||||
		{
 | 
			
		||||
		if (db->db) TXT_DB_free(db->db);
 | 
			
		||||
		OPENSSL_free(db);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										33
									
								
								apps/apps.h
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								apps/apps.h
									
									
									
									
									
								
							@@ -281,38 +281,7 @@ char *make_config_name(void);
 | 
			
		||||
/* Functions defined in ca.c and also used in ocsp.c */
 | 
			
		||||
int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
 | 
			
		||||
			ASN1_GENERALIZEDTIME **pinvtm, char *str);
 | 
			
		||||
 | 
			
		||||
#define DB_type         0
 | 
			
		||||
#define DB_exp_date     1
 | 
			
		||||
#define DB_rev_date     2
 | 
			
		||||
#define DB_serial       3       /* index - unique */
 | 
			
		||||
#define DB_file         4       
 | 
			
		||||
#define DB_name         5       /* index - unique when active and not disabled */
 | 
			
		||||
#define DB_NUMBER       6
 | 
			
		||||
 | 
			
		||||
#define DB_TYPE_REV	'R'
 | 
			
		||||
#define DB_TYPE_EXP	'E'
 | 
			
		||||
#define DB_TYPE_VAL	'V'
 | 
			
		||||
 | 
			
		||||
typedef struct db_attr_st
 | 
			
		||||
	{
 | 
			
		||||
	int unique_subject;
 | 
			
		||||
	} DB_ATTR;
 | 
			
		||||
typedef struct ca_db_st
 | 
			
		||||
	{
 | 
			
		||||
	DB_ATTR attributes;
 | 
			
		||||
	TXT_DB *db;
 | 
			
		||||
	} CA_DB;
 | 
			
		||||
 | 
			
		||||
BIGNUM *load_serial(char *serialfile, int create, ASN1_INTEGER **retai);
 | 
			
		||||
int save_serial(char *serialfile, char *suffix, BIGNUM *serial, ASN1_INTEGER **retai);
 | 
			
		||||
int rotate_serial(char *serialfile, char *new_suffix, char *old_suffix);
 | 
			
		||||
CA_DB *load_index(char *dbfile, DB_ATTR *dbattr);
 | 
			
		||||
int index_index(CA_DB *db);
 | 
			
		||||
int save_index(char *dbfile, char *suffix, CA_DB *db);
 | 
			
		||||
int rotate_index(char *dbfile, char *new_suffix, char *old_suffix);
 | 
			
		||||
void free_index(CA_DB *db);
 | 
			
		||||
int index_name_cmp(const char **a, const char **b);
 | 
			
		||||
int make_serial_index(TXT_DB *db);
 | 
			
		||||
 | 
			
		||||
X509_NAME *do_subject(char *str, long chtype);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -82,8 +82,6 @@
 | 
			
		||||
 | 
			
		||||
int MAIN(int, char **);
 | 
			
		||||
 | 
			
		||||
static int do_generate(BIO *bio, char *genstr, char *genconf, BUF_MEM *buf);
 | 
			
		||||
 | 
			
		||||
int MAIN(int argc, char **argv)
 | 
			
		||||
	{
 | 
			
		||||
	int i,badops=0,offset=0,ret=1,j;
 | 
			
		||||
@@ -92,7 +90,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
	BIO *in=NULL,*out=NULL,*b64=NULL, *derout = NULL;
 | 
			
		||||
	int informat,indent=0, noout = 0, dump = 0;
 | 
			
		||||
	char *infile=NULL,*str=NULL,*prog,*oidfile=NULL, *derfile=NULL;
 | 
			
		||||
	char *genstr=NULL, *genconf=NULL;
 | 
			
		||||
	unsigned char *tmpbuf;
 | 
			
		||||
	BUF_MEM *buf=NULL;
 | 
			
		||||
	STACK *osk=NULL;
 | 
			
		||||
@@ -170,16 +167,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			sk_push(osk,*(++argv));
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv,"-genstr") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			genstr= *(++argv);
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv,"-genconf") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			genconf= *(++argv);
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,"unknown option %s\n",*argv);
 | 
			
		||||
@@ -208,8 +195,6 @@ bad:
 | 
			
		||||
		BIO_printf(bio_err," -strparse offset\n");
 | 
			
		||||
		BIO_printf(bio_err,"               a series of these can be used to 'dig' into multiple\n");
 | 
			
		||||
		BIO_printf(bio_err,"               ASN1 blob wrappings\n");
 | 
			
		||||
		BIO_printf(bio_err," -genstr str   string to generate ASN1 structure from\n");
 | 
			
		||||
		BIO_printf(bio_err," -genconf file file to generate ASN1 structure from\n");
 | 
			
		||||
		goto end;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@@ -263,19 +248,6 @@ bad:
 | 
			
		||||
	if ((buf=BUF_MEM_new()) == NULL) goto end;
 | 
			
		||||
	if (!BUF_MEM_grow(buf,BUFSIZ*8)) goto end; /* Pre-allocate :-) */
 | 
			
		||||
 | 
			
		||||
	if (genstr || genconf)
 | 
			
		||||
		{
 | 
			
		||||
		num = do_generate(bio_err, genstr, genconf, buf);
 | 
			
		||||
		if (num < 0)
 | 
			
		||||
			{
 | 
			
		||||
			ERR_print_errors(bio_err);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
 | 
			
		||||
	if (informat == FORMAT_PEM)
 | 
			
		||||
		{
 | 
			
		||||
		BIO *tmp;
 | 
			
		||||
@@ -296,7 +268,6 @@ bad:
 | 
			
		||||
		if (i <= 0) break;
 | 
			
		||||
		num+=i;
 | 
			
		||||
		}
 | 
			
		||||
		}
 | 
			
		||||
	str=buf->data;
 | 
			
		||||
 | 
			
		||||
	/* If any structs to parse go through in sequence */
 | 
			
		||||
@@ -364,61 +335,3 @@ end:
 | 
			
		||||
	OPENSSL_EXIT(ret);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int do_generate(BIO *bio, char *genstr, char *genconf, BUF_MEM *buf)
 | 
			
		||||
	{
 | 
			
		||||
	CONF *cnf = NULL;
 | 
			
		||||
	int len;
 | 
			
		||||
	long errline;
 | 
			
		||||
	unsigned char *p;
 | 
			
		||||
	ASN1_TYPE *atyp = NULL;
 | 
			
		||||
 | 
			
		||||
	if (genconf)
 | 
			
		||||
		{
 | 
			
		||||
		cnf = NCONF_new(NULL);
 | 
			
		||||
		if (!NCONF_load(cnf, genconf, &errline))
 | 
			
		||||
			goto conferr;
 | 
			
		||||
		if (!genstr)
 | 
			
		||||
			genstr = NCONF_get_string(cnf, "default", "asn1");
 | 
			
		||||
		if (!genstr)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio, "Can't find 'asn1' in '%s'\n", genconf);
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	atyp = ASN1_generate_nconf(genstr, cnf);
 | 
			
		||||
	NCONF_free(cnf);
 | 
			
		||||
 | 
			
		||||
	if (!atyp)
 | 
			
		||||
		return -1;
 | 
			
		||||
 | 
			
		||||
	len = i2d_ASN1_TYPE(atyp, NULL);
 | 
			
		||||
 | 
			
		||||
	if (len <= 0)
 | 
			
		||||
		goto err;
 | 
			
		||||
 | 
			
		||||
	if (!BUF_MEM_grow(buf,len))
 | 
			
		||||
		goto err;
 | 
			
		||||
 | 
			
		||||
	p=(unsigned char *)buf->data;
 | 
			
		||||
 | 
			
		||||
	i2d_ASN1_TYPE(atyp, &p);
 | 
			
		||||
 | 
			
		||||
	ASN1_TYPE_free(atyp);
 | 
			
		||||
	return len;
 | 
			
		||||
 | 
			
		||||
	conferr:
 | 
			
		||||
 | 
			
		||||
	if (errline > 0)
 | 
			
		||||
		BIO_printf(bio, "Error on line %ld of config file '%s'\n",
 | 
			
		||||
							errline, genconf);
 | 
			
		||||
	else
 | 
			
		||||
		BIO_printf(bio, "Error loading config file '%s'\n", genconf);
 | 
			
		||||
 | 
			
		||||
	err:
 | 
			
		||||
	NCONF_free(cnf);
 | 
			
		||||
	ASN1_TYPE_free(atyp);
 | 
			
		||||
 | 
			
		||||
	return -1;
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										576
									
								
								apps/ca.c
									
									
									
									
									
								
							
							
						
						
									
										576
									
								
								apps/ca.c
									
									
									
									
									
								
							@@ -112,7 +112,6 @@
 | 
			
		||||
#define ENV_NEW_CERTS_DIR	"new_certs_dir"
 | 
			
		||||
#define ENV_CERTIFICATE 	"certificate"
 | 
			
		||||
#define ENV_SERIAL		"serial"
 | 
			
		||||
#define ENV_CRLNUMBER		"crlnumber"
 | 
			
		||||
#define ENV_CRL			"crl"
 | 
			
		||||
#define ENV_PRIVATE_KEY		"private_key"
 | 
			
		||||
#define ENV_RANDFILE		"RANDFILE"
 | 
			
		||||
@@ -134,6 +133,18 @@
 | 
			
		||||
 | 
			
		||||
#define ENV_DATABASE		"database"
 | 
			
		||||
 | 
			
		||||
#define DB_type         0
 | 
			
		||||
#define DB_exp_date     1
 | 
			
		||||
#define DB_rev_date     2
 | 
			
		||||
#define DB_serial       3       /* index - unique */
 | 
			
		||||
#define DB_file         4       
 | 
			
		||||
#define DB_name         5       /* index - unique for active */
 | 
			
		||||
#define DB_NUMBER       6
 | 
			
		||||
 | 
			
		||||
#define DB_TYPE_REV	'R'
 | 
			
		||||
#define DB_TYPE_EXP	'E'
 | 
			
		||||
#define DB_TYPE_VAL	'V'
 | 
			
		||||
 | 
			
		||||
/* Additional revocation information types */
 | 
			
		||||
 | 
			
		||||
#define REV_NONE		0	/* No addditional information */
 | 
			
		||||
@@ -160,7 +171,6 @@ static char *ca_usage[]={
 | 
			
		||||
" -keyform arg    - private key file format (PEM or ENGINE)\n",
 | 
			
		||||
" -key arg        - key to decode the private key if it is encrypted\n",
 | 
			
		||||
" -cert file      - The CA certificate\n",
 | 
			
		||||
" -selfsign       - sign a certificate with the key associated with it\n",
 | 
			
		||||
" -in file        - The input PEM encoded certificate request(s)\n",
 | 
			
		||||
" -out file       - Where to put the output file(s)\n",
 | 
			
		||||
" -outdir dir     - Where to put output certificates\n",
 | 
			
		||||
@@ -191,36 +201,43 @@ extern int EF_ALIGNMENT;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static void lookup_fail(char *name,char *tag);
 | 
			
		||||
static unsigned long index_serial_hash(const char **a);
 | 
			
		||||
static int index_serial_cmp(const char **a, const char **b);
 | 
			
		||||
static unsigned long index_name_hash(const char **a);
 | 
			
		||||
static int index_name_qual(char **a);
 | 
			
		||||
static int index_name_cmp(const char **a,const char **b);
 | 
			
		||||
static BIGNUM *load_serial(char *serialfile);
 | 
			
		||||
static int save_serial(char *serialfile, BIGNUM *serial);
 | 
			
		||||
static int certify(X509 **xret, char *infile,EVP_PKEY *pkey,X509 *x509,
 | 
			
		||||
		   const EVP_MD *dgst,STACK_OF(CONF_VALUE) *policy,CA_DB *db,
 | 
			
		||||
		   const EVP_MD *dgst,STACK_OF(CONF_VALUE) *policy,TXT_DB *db,
 | 
			
		||||
		   BIGNUM *serial, char *subj, int email_dn, char *startdate,
 | 
			
		||||
		   char *enddate, long days, int batch, char *ext_sect, CONF *conf,
 | 
			
		||||
		   int verbose, unsigned long certopt, unsigned long nameopt,
 | 
			
		||||
		   int default_op, int ext_copy, int selfsign);
 | 
			
		||||
		   int default_op, int ext_copy);
 | 
			
		||||
static int certify_cert(X509 **xret, char *infile,EVP_PKEY *pkey,X509 *x509,
 | 
			
		||||
			const EVP_MD *dgst,STACK_OF(CONF_VALUE) *policy,
 | 
			
		||||
			CA_DB *db, BIGNUM *serial, char *subj, int email_dn,
 | 
			
		||||
			TXT_DB *db, BIGNUM *serial, char *subj, int email_dn,
 | 
			
		||||
			char *startdate, char *enddate, long days, int batch,
 | 
			
		||||
			char *ext_sect, CONF *conf,int verbose, unsigned long certopt,
 | 
			
		||||
			unsigned long nameopt, int default_op, int ext_copy,
 | 
			
		||||
			ENGINE *e);
 | 
			
		||||
static int certify_spkac(X509 **xret, char *infile,EVP_PKEY *pkey,X509 *x509,
 | 
			
		||||
			 const EVP_MD *dgst,STACK_OF(CONF_VALUE) *policy,
 | 
			
		||||
			 CA_DB *db, BIGNUM *serial,char *subj, int email_dn,
 | 
			
		||||
			 TXT_DB *db, BIGNUM *serial,char *subj, int email_dn,
 | 
			
		||||
			 char *startdate, char *enddate, long days, char *ext_sect,
 | 
			
		||||
			 CONF *conf, int verbose, unsigned long certopt, 
 | 
			
		||||
			 unsigned long nameopt, int default_op, int ext_copy);
 | 
			
		||||
static int fix_data(int nid, int *type);
 | 
			
		||||
static void write_new_certificate(BIO *bp, X509 *x, int output_der, int notext);
 | 
			
		||||
static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst,
 | 
			
		||||
	STACK_OF(CONF_VALUE) *policy, CA_DB *db, BIGNUM *serial,char *subj,
 | 
			
		||||
	STACK_OF(CONF_VALUE) *policy, TXT_DB *db, BIGNUM *serial,char *subj,
 | 
			
		||||
	int email_dn, char *startdate, char *enddate, long days, int batch,
 | 
			
		||||
       	int verbose, X509_REQ *req, char *ext_sect, CONF *conf,
 | 
			
		||||
	unsigned long certopt, unsigned long nameopt, int default_op,
 | 
			
		||||
	int ext_copy, int selfsign);
 | 
			
		||||
static int do_revoke(X509 *x509, CA_DB *db, int ext, char *extval);
 | 
			
		||||
static int get_certificate_status(const char *ser_status, CA_DB *db);
 | 
			
		||||
static int do_updatedb(CA_DB *db);
 | 
			
		||||
	int ext_copy);
 | 
			
		||||
static int do_revoke(X509 *x509, TXT_DB *db, int ext, char *extval);
 | 
			
		||||
static int get_certificate_status(const char *ser_status, TXT_DB *db);
 | 
			
		||||
static int do_updatedb(TXT_DB *db);
 | 
			
		||||
static int check_time_format(char *str);
 | 
			
		||||
char *make_revocation_str(int rev_type, char *rev_arg);
 | 
			
		||||
int make_revoked(X509_REVOKED *rev, char *str);
 | 
			
		||||
@@ -232,6 +249,11 @@ static char *section=NULL;
 | 
			
		||||
static int preserve=0;
 | 
			
		||||
static int msie_hack=0;
 | 
			
		||||
 | 
			
		||||
static IMPLEMENT_LHASH_HASH_FN(index_serial_hash,const char **)
 | 
			
		||||
static IMPLEMENT_LHASH_COMP_FN(index_serial_cmp,const char **)
 | 
			
		||||
static IMPLEMENT_LHASH_HASH_FN(index_name_hash,const char **)
 | 
			
		||||
static IMPLEMENT_LHASH_COMP_FN(index_name_cmp,const char **)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int MAIN(int, char **);
 | 
			
		||||
 | 
			
		||||
@@ -268,7 +290,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
	char *outfile=NULL;
 | 
			
		||||
	char *outdir=NULL;
 | 
			
		||||
	char *serialfile=NULL;
 | 
			
		||||
	char *crlnumberfile=NULL;
 | 
			
		||||
	char *extensions=NULL;
 | 
			
		||||
	char *extfile=NULL;
 | 
			
		||||
	char *subj=NULL;
 | 
			
		||||
@@ -277,7 +298,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
	int rev_type = REV_NONE;
 | 
			
		||||
	char *rev_arg = NULL;
 | 
			
		||||
	BIGNUM *serial=NULL;
 | 
			
		||||
	BIGNUM *crlnumber=NULL;
 | 
			
		||||
	char *startdate=NULL;
 | 
			
		||||
	char *enddate=NULL;
 | 
			
		||||
	long days=0;
 | 
			
		||||
@@ -286,18 +306,18 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
	unsigned long nameopt = 0, certopt = 0;
 | 
			
		||||
	int default_op = 1;
 | 
			
		||||
	int ext_copy = EXT_COPY_NONE;
 | 
			
		||||
	int selfsign = 0;
 | 
			
		||||
	X509 *x509=NULL, *x509p = NULL;
 | 
			
		||||
	X509 *x509=NULL;
 | 
			
		||||
	X509 *x=NULL;
 | 
			
		||||
	BIO *in=NULL,*out=NULL,*Sout=NULL,*Cout=NULL;
 | 
			
		||||
	char *dbfile=NULL;
 | 
			
		||||
	CA_DB *db=NULL;
 | 
			
		||||
	TXT_DB *db=NULL;
 | 
			
		||||
	X509_CRL *crl=NULL;
 | 
			
		||||
	X509_REVOKED *r=NULL;
 | 
			
		||||
	ASN1_TIME *tmptm;
 | 
			
		||||
	ASN1_INTEGER *tmpser;
 | 
			
		||||
	char **pp,*p,*f;
 | 
			
		||||
	int i,j;
 | 
			
		||||
	long l;
 | 
			
		||||
	const EVP_MD *dgst=NULL;
 | 
			
		||||
	STACK_OF(CONF_VALUE) *attribs=NULL;
 | 
			
		||||
	STACK_OF(X509) *cert_sk=NULL;
 | 
			
		||||
@@ -309,7 +329,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
	char *engine = NULL;
 | 
			
		||||
#endif
 | 
			
		||||
	char *tofree=NULL;
 | 
			
		||||
	DB_ATTR db_attr;
 | 
			
		||||
 | 
			
		||||
#ifdef EFENCE
 | 
			
		||||
EF_PROTECT_FREE=1;
 | 
			
		||||
@@ -401,8 +420,6 @@ EF_ALIGNMENT=0;
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			certfile= *(++argv);
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv,"-selfsign") == 0)
 | 
			
		||||
			selfsign=1;
 | 
			
		||||
		else if (strcmp(*argv,"-in") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
@@ -633,39 +650,6 @@ bad:
 | 
			
		||||
		ERR_clear_error();
 | 
			
		||||
	app_RAND_load_file(randfile, bio_err, 0);
 | 
			
		||||
	
 | 
			
		||||
	db_attr.unique_subject = 1;
 | 
			
		||||
	p = NCONF_get_string(conf, section, "unique_subject");
 | 
			
		||||
	if (p)
 | 
			
		||||
		{
 | 
			
		||||
#ifdef RL_DEBUG
 | 
			
		||||
		BIO_printf(bio_err, "DEBUG: unique_subject = \"%s\"\n", p);
 | 
			
		||||
#endif
 | 
			
		||||
		switch(*p)
 | 
			
		||||
			{
 | 
			
		||||
		case 'f': /* false */
 | 
			
		||||
		case 'F': /* FALSE */
 | 
			
		||||
		case 'n': /* no */
 | 
			
		||||
		case 'N': /* NO */
 | 
			
		||||
			db_attr.unique_subject = 0;
 | 
			
		||||
			break;
 | 
			
		||||
		case 't': /* true */
 | 
			
		||||
		case 'T': /* TRUE */
 | 
			
		||||
		case 'y': /* yes */
 | 
			
		||||
		case 'Y': /* YES */
 | 
			
		||||
		default:
 | 
			
		||||
			db_attr.unique_subject = 1;
 | 
			
		||||
			break;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
#ifdef RL_DEBUG
 | 
			
		||||
	else
 | 
			
		||||
		BIO_printf(bio_err, "DEBUG: unique_subject undefined\n", p);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef RL_DEBUG
 | 
			
		||||
	BIO_printf(bio_err, "DEBUG: configured unique_subject is %d\n",
 | 
			
		||||
		db_attr.unique_subject);
 | 
			
		||||
#endif
 | 
			
		||||
	
 | 
			
		||||
	in=BIO_new(BIO_s_file());
 | 
			
		||||
	out=BIO_new(BIO_s_file());
 | 
			
		||||
	Sout=BIO_new(BIO_s_file());
 | 
			
		||||
@@ -685,10 +669,17 @@ bad:
 | 
			
		||||
			lookup_fail(section,ENV_DATABASE);
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		db = load_index(dbfile,&db_attr);
 | 
			
		||||
		if (BIO_read_filename(in,dbfile) <= 0)
 | 
			
		||||
			{
 | 
			
		||||
			perror(dbfile);
 | 
			
		||||
			BIO_printf(bio_err,"unable to open '%s'\n",dbfile);
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		db=TXT_DB_read(in,DB_NUMBER);
 | 
			
		||||
		if (db == NULL) goto err;
 | 
			
		||||
 | 
			
		||||
		if (!index_index(db)) goto err;
 | 
			
		||||
		if (!make_serial_index(db))
 | 
			
		||||
			goto err;
 | 
			
		||||
 | 
			
		||||
		if (get_certificate_status(ser_status,db) != 1)
 | 
			
		||||
			BIO_printf(bio_err,"Error verifying serial %s!\n",
 | 
			
		||||
@@ -697,7 +688,7 @@ bad:
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/*****************************************************************/
 | 
			
		||||
	/* we definitely need a private key, so let's get it */
 | 
			
		||||
	/* we definitely need a public key, so let's get it */
 | 
			
		||||
 | 
			
		||||
	if ((keyfile == NULL) && ((keyfile=NCONF_get_string(conf,
 | 
			
		||||
		section,ENV_PRIVATE_KEY)) == NULL))
 | 
			
		||||
@@ -725,10 +716,7 @@ bad:
 | 
			
		||||
 | 
			
		||||
	/*****************************************************************/
 | 
			
		||||
	/* we need a certificate */
 | 
			
		||||
	if (!selfsign || spkac_file || ss_cert_file || gencrl)
 | 
			
		||||
		{
 | 
			
		||||
		if ((certfile == NULL)
 | 
			
		||||
			&& ((certfile=NCONF_get_string(conf,
 | 
			
		||||
	if ((certfile == NULL) && ((certfile=NCONF_get_string(conf,
 | 
			
		||||
		section,ENV_CERTIFICATE)) == NULL))
 | 
			
		||||
		{
 | 
			
		||||
		lookup_fail(section,ENV_CERTIFICATE);
 | 
			
		||||
@@ -744,8 +732,6 @@ bad:
 | 
			
		||||
		BIO_printf(bio_err,"CA certificate and CA private key do not match\n");
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
		}
 | 
			
		||||
	if (!selfsign) x509p = x509;
 | 
			
		||||
 | 
			
		||||
	f=NCONF_get_string(conf,BASE_SECTION,ENV_PRESERVE);
 | 
			
		||||
	if (f == NULL)
 | 
			
		||||
@@ -853,13 +839,19 @@ bad:
 | 
			
		||||
		lookup_fail(section,ENV_DATABASE);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	db = load_index(dbfile, &db_attr);
 | 
			
		||||
	if (BIO_read_filename(in,dbfile) <= 0)
 | 
			
		||||
		{
 | 
			
		||||
		perror(dbfile);
 | 
			
		||||
		BIO_printf(bio_err,"unable to open '%s'\n",dbfile);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	db=TXT_DB_read(in,DB_NUMBER);
 | 
			
		||||
	if (db == NULL) goto err;
 | 
			
		||||
 | 
			
		||||
	/* Lets check some fields */
 | 
			
		||||
	for (i=0; i<sk_num(db->db->data); i++)
 | 
			
		||||
	for (i=0; i<sk_num(db->data); i++)
 | 
			
		||||
		{
 | 
			
		||||
		pp=(char **)sk_value(db->db->data,i);
 | 
			
		||||
		pp=(char **)sk_value(db->data,i);
 | 
			
		||||
		if ((pp[DB_type][0] != DB_TYPE_REV) &&
 | 
			
		||||
			(pp[DB_rev_date][0] != '\0'))
 | 
			
		||||
			{
 | 
			
		||||
@@ -910,13 +902,23 @@ bad:
 | 
			
		||||
		out = BIO_push(tmpbio, out);
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
		TXT_DB_write(out,db->db);
 | 
			
		||||
		TXT_DB_write(out,db);
 | 
			
		||||
		BIO_printf(bio_err,"%d entries loaded from the database\n",
 | 
			
		||||
			db->db->data->num);
 | 
			
		||||
			db->data->num);
 | 
			
		||||
		BIO_printf(bio_err,"generating index\n");
 | 
			
		||||
		}
 | 
			
		||||
	
 | 
			
		||||
	if (!index_index(db)) goto err;
 | 
			
		||||
	if (!make_serial_index(db))
 | 
			
		||||
		goto err;
 | 
			
		||||
 | 
			
		||||
	if (!TXT_DB_create_index(db, DB_name, index_name_qual,
 | 
			
		||||
			LHASH_HASH_FN(index_name_hash),
 | 
			
		||||
			LHASH_COMP_FN(index_name_cmp)))
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"error creating name index:(%ld,%ld,%ld)\n",
 | 
			
		||||
			db->error,db->arg1,db->arg2);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	/*****************************************************************/
 | 
			
		||||
	/* Update the db file for expired certificates */
 | 
			
		||||
@@ -939,9 +941,62 @@ bad:
 | 
			
		||||
			}
 | 
			
		||||
	    	else
 | 
			
		||||
			{
 | 
			
		||||
			if (!save_index(dbfile,"new",db)) goto err;
 | 
			
		||||
			out = BIO_new(BIO_s_file());
 | 
			
		||||
			if (out == NULL)
 | 
			
		||||
				{
 | 
			
		||||
				ERR_print_errors(bio_err);
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
			if (!rotate_index(dbfile,"new","old")) goto err;
 | 
			
		||||
#ifndef OPENSSL_SYS_VMS
 | 
			
		||||
			j = BIO_snprintf(buf[0], sizeof buf[0], "%s.new", dbfile);
 | 
			
		||||
#else
 | 
			
		||||
			j = BIO_snprintf(buf[0], sizeof buf[0], "%s-new", dbfile);
 | 
			
		||||
#endif
 | 
			
		||||
			if (j < 0 || j >= sizeof buf[0])
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err, "file name too long\n");
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			if (BIO_write_filename(out,buf[0]) <= 0)
 | 
			
		||||
		  		{
 | 
			
		||||
		    		perror(dbfile);
 | 
			
		||||
		    		BIO_printf(bio_err,"unable to open '%s'\n",
 | 
			
		||||
									dbfile);
 | 
			
		||||
		    		goto err;
 | 
			
		||||
		  		}
 | 
			
		||||
			j=TXT_DB_write(out,db);
 | 
			
		||||
			if (j <= 0) goto err;
 | 
			
		||||
			
 | 
			
		||||
			BIO_free(out);
 | 
			
		||||
			out = NULL;
 | 
			
		||||
#ifndef OPENSSL_SYS_VMS
 | 
			
		||||
			j = BIO_snprintf(buf[1], sizeof buf[1], "%s.old", dbfile);
 | 
			
		||||
#else
 | 
			
		||||
			j = BIO_snprintf(buf[1], sizeof buf[1], "%s-old", dbfile);
 | 
			
		||||
#endif
 | 
			
		||||
			if (j < 0 || j >= sizeof buf[1])
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err, "file name too long\n");
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			if (rename(dbfile,buf[1]) < 0)
 | 
			
		||||
		  		{
 | 
			
		||||
		    		BIO_printf(bio_err,
 | 
			
		||||
						"unable to rename %s to %s\n",
 | 
			
		||||
						dbfile, buf[1]);
 | 
			
		||||
		    		perror("reason");
 | 
			
		||||
		    		goto err;
 | 
			
		||||
		  		}
 | 
			
		||||
			if (rename(buf[0],dbfile) < 0)
 | 
			
		||||
				{
 | 
			
		||||
		    		BIO_printf(bio_err,
 | 
			
		||||
						"unable to rename %s to %s\n",
 | 
			
		||||
						buf[0],dbfile);
 | 
			
		||||
		    		perror("reason");
 | 
			
		||||
		    		rename(buf[1],dbfile);
 | 
			
		||||
		    		goto err;
 | 
			
		||||
		  		}
 | 
			
		||||
				
 | 
			
		||||
			if (verbose) BIO_printf(bio_err,
 | 
			
		||||
				"Done. %d entries marked as expired\n",i); 
 | 
			
		||||
@@ -1102,7 +1157,7 @@ bad:
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		if ((serial=load_serial(serialfile, 0, NULL)) == NULL)
 | 
			
		||||
		if ((serial=load_serial(serialfile)) == NULL)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,"error while loading serial number\n");
 | 
			
		||||
			goto err;
 | 
			
		||||
@@ -1177,10 +1232,10 @@ bad:
 | 
			
		||||
		if (infile != NULL)
 | 
			
		||||
			{
 | 
			
		||||
			total++;
 | 
			
		||||
			j=certify(&x,infile,pkey,x509p,dgst,attribs,db,
 | 
			
		||||
			j=certify(&x,infile,pkey,x509,dgst,attribs,db,
 | 
			
		||||
				serial,subj,email_dn,startdate,enddate,days,batch,
 | 
			
		||||
				extensions,conf,verbose, certopt, nameopt,
 | 
			
		||||
				default_op, ext_copy, selfsign);
 | 
			
		||||
				default_op, ext_copy);
 | 
			
		||||
			if (j < 0) goto err;
 | 
			
		||||
			if (j > 0)
 | 
			
		||||
				{
 | 
			
		||||
@@ -1197,10 +1252,10 @@ bad:
 | 
			
		||||
		for (i=0; i<argc; i++)
 | 
			
		||||
			{
 | 
			
		||||
			total++;
 | 
			
		||||
			j=certify(&x,argv[i],pkey,x509p,dgst,attribs,db,
 | 
			
		||||
			j=certify(&x,argv[i],pkey,x509,dgst,attribs,db,
 | 
			
		||||
				serial,subj,email_dn,startdate,enddate,days,batch,
 | 
			
		||||
				extensions,conf,verbose, certopt, nameopt,
 | 
			
		||||
				default_op, ext_copy, selfsign);
 | 
			
		||||
				default_op, ext_copy);
 | 
			
		||||
			if (j < 0) goto err;
 | 
			
		||||
			if (j > 0)
 | 
			
		||||
				{
 | 
			
		||||
@@ -1236,9 +1291,38 @@ bad:
 | 
			
		||||
 | 
			
		||||
			BIO_printf(bio_err,"Write out database with %d new entries\n",sk_X509_num(cert_sk));
 | 
			
		||||
 | 
			
		||||
			if (!save_serial(serialfile,"new",serial,NULL)) goto err;
 | 
			
		||||
			if(strlen(serialfile) > BSIZE-5 || strlen(dbfile) > BSIZE-5)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err,"file name too long\n");
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
			if (!save_index(dbfile, "new", db)) goto err;
 | 
			
		||||
			strcpy(buf[0],serialfile);
 | 
			
		||||
 | 
			
		||||
#ifdef OPENSSL_SYS_VMS
 | 
			
		||||
			strcat(buf[0],"-new");
 | 
			
		||||
#else
 | 
			
		||||
			strcat(buf[0],".new");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
			if (!save_serial(buf[0],serial)) goto err;
 | 
			
		||||
 | 
			
		||||
			strcpy(buf[1],dbfile);
 | 
			
		||||
 | 
			
		||||
#ifdef OPENSSL_SYS_VMS
 | 
			
		||||
			strcat(buf[1],"-new");
 | 
			
		||||
#else
 | 
			
		||||
			strcat(buf[1],".new");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
			if (BIO_write_filename(out,buf[1]) <= 0)
 | 
			
		||||
				{
 | 
			
		||||
				perror(dbfile);
 | 
			
		||||
				BIO_printf(bio_err,"unable to open '%s'\n",dbfile);
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			l=TXT_DB_write(out,db);
 | 
			
		||||
			if (l <= 0) goto err;
 | 
			
		||||
			}
 | 
			
		||||
	
 | 
			
		||||
		if (verbose)
 | 
			
		||||
@@ -1296,10 +1380,59 @@ bad:
 | 
			
		||||
		if (sk_X509_num(cert_sk))
 | 
			
		||||
			{
 | 
			
		||||
			/* Rename the database and the serial file */
 | 
			
		||||
			if (!rotate_serial(serialfile,"new","old")) goto err;
 | 
			
		||||
			strncpy(buf[2],serialfile,BSIZE-4);
 | 
			
		||||
			buf[2][BSIZE-4]='\0';
 | 
			
		||||
 | 
			
		||||
			if (!rotate_index(dbfile,"new","old")) goto err;
 | 
			
		||||
#ifdef OPENSSL_SYS_VMS
 | 
			
		||||
			strcat(buf[2],"-old");
 | 
			
		||||
#else
 | 
			
		||||
			strcat(buf[2],".old");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
			BIO_free(in);
 | 
			
		||||
			BIO_free_all(out);
 | 
			
		||||
			in=NULL;
 | 
			
		||||
			out=NULL;
 | 
			
		||||
			if (rename(serialfile,buf[2]) < 0)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err,"unable to rename %s to %s\n",
 | 
			
		||||
					serialfile,buf[2]);
 | 
			
		||||
				perror("reason");
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			if (rename(buf[0],serialfile) < 0)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err,"unable to rename %s to %s\n",
 | 
			
		||||
					buf[0],serialfile);
 | 
			
		||||
				perror("reason");
 | 
			
		||||
				rename(buf[2],serialfile);
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
			strncpy(buf[2],dbfile,BSIZE-4);
 | 
			
		||||
			buf[2][BSIZE-4]='\0';
 | 
			
		||||
 | 
			
		||||
#ifdef OPENSSL_SYS_VMS
 | 
			
		||||
			strcat(buf[2],"-old");
 | 
			
		||||
#else
 | 
			
		||||
			strcat(buf[2],".old");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
			if (rename(dbfile,buf[2]) < 0)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err,"unable to rename %s to %s\n",
 | 
			
		||||
					dbfile,buf[2]);
 | 
			
		||||
				perror("reason");
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			if (rename(buf[1],dbfile) < 0)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err,"unable to rename %s to %s\n",
 | 
			
		||||
					buf[1],dbfile);
 | 
			
		||||
				perror("reason");
 | 
			
		||||
				rename(buf[2],dbfile);
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			BIO_printf(bio_err,"Data Base Updated\n");
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@@ -1330,14 +1463,6 @@ bad:
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		if ((crlnumberfile=NCONF_get_string(conf,section,ENV_CRLNUMBER))
 | 
			
		||||
			!= NULL)
 | 
			
		||||
			if ((crlnumber=load_serial(crlnumberfile,0,NULL)) == NULL)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err,"error while loading CRL number\n");
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
		if (!crldays && !crlhours)
 | 
			
		||||
			{
 | 
			
		||||
			if (!NCONF_get_number(conf,section,
 | 
			
		||||
@@ -1366,9 +1491,9 @@ bad:
 | 
			
		||||
 | 
			
		||||
		ASN1_TIME_free(tmptm);
 | 
			
		||||
 | 
			
		||||
		for (i=0; i<sk_num(db->db->data); i++)
 | 
			
		||||
		for (i=0; i<sk_num(db->data); i++)
 | 
			
		||||
			{
 | 
			
		||||
			pp=(char **)sk_value(db->db->data,i);
 | 
			
		||||
			pp=(char **)sk_value(db->data,i);
 | 
			
		||||
			if (pp[DB_type][0] == DB_TYPE_REV)
 | 
			
		||||
				{
 | 
			
		||||
				if ((r=X509_REVOKED_new()) == NULL) goto err;
 | 
			
		||||
@@ -1408,35 +1533,20 @@ bad:
 | 
			
		||||
			if (pkey->type == EVP_PKEY_DSA) 
 | 
			
		||||
				dgst=EVP_dss1();
 | 
			
		||||
			else
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
			if (pkey->type == EVP_PKEY_EC)
 | 
			
		||||
				dgst=EVP_ecdsa();
 | 
			
		||||
			else
 | 
			
		||||
#endif
 | 
			
		||||
				dgst=EVP_md5();
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		/* Add any extensions asked for */
 | 
			
		||||
 | 
			
		||||
		if (crl_ext || crlnumberfile != NULL)
 | 
			
		||||
		if (crl_ext)
 | 
			
		||||
			{
 | 
			
		||||
			X509V3_CTX crlctx;
 | 
			
		||||
			X509V3_set_ctx(&crlctx, x509, NULL, NULL, crl, 0);
 | 
			
		||||
			X509V3_set_nconf(&crlctx, conf);
 | 
			
		||||
 | 
			
		||||
			if (crl_ext)
 | 
			
		||||
			if (!X509V3_EXT_CRL_add_nconf(conf, &crlctx,
 | 
			
		||||
				crl_ext, crl)) goto err;
 | 
			
		||||
			if (crlnumberfile != NULL)
 | 
			
		||||
				{
 | 
			
		||||
				tmpser = BN_to_ASN1_INTEGER(crlnumber, NULL);
 | 
			
		||||
				if (!tmpser) goto err;
 | 
			
		||||
				X509_CRL_add1_ext_i2d(crl,NID_crl_number,tmpser,0,0);
 | 
			
		||||
				ASN1_INTEGER_free(tmpser);
 | 
			
		||||
				crl_v2 = 1;
 | 
			
		||||
				if (!BN_add_word(crlnumber,1)) goto err;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		if (crl_ext || crl_v2)
 | 
			
		||||
			{
 | 
			
		||||
@@ -1444,17 +1554,9 @@ bad:
 | 
			
		||||
				goto err; /* version 2 CRL */
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		
 | 
			
		||||
		if (crlnumberfile != NULL)	/* we have a CRL number that need updating */
 | 
			
		||||
			if (!save_serial(crlnumberfile,"new",crlnumber,NULL)) goto err;
 | 
			
		||||
 | 
			
		||||
		if (!X509_CRL_sign(crl,pkey,dgst)) goto err;
 | 
			
		||||
 | 
			
		||||
		PEM_write_bio_X509_CRL(Sout,crl);
 | 
			
		||||
 | 
			
		||||
		if (crlnumberfile != NULL)	/* Rename the crlnumber file */
 | 
			
		||||
			if (!rotate_serial(crlnumberfile,"new","old")) goto err;
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
	/*****************************************************************/
 | 
			
		||||
	if (dorevoke)
 | 
			
		||||
@@ -1475,10 +1577,50 @@ bad:
 | 
			
		||||
			if (j <= 0) goto err;
 | 
			
		||||
			X509_free(revcert);
 | 
			
		||||
 | 
			
		||||
			if (!save_index(dbfile, "new", db)) goto err;
 | 
			
		||||
 | 
			
		||||
			if (!rotate_index(dbfile, "new", "old")) goto err;
 | 
			
		||||
			if(strlen(dbfile) > BSIZE-5)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err,"filename too long\n");
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
			strcpy(buf[0],dbfile);
 | 
			
		||||
#ifndef OPENSSL_SYS_VMS
 | 
			
		||||
			strcat(buf[0],".new");
 | 
			
		||||
#else
 | 
			
		||||
			strcat(buf[0],"-new");
 | 
			
		||||
#endif
 | 
			
		||||
			if (BIO_write_filename(out,buf[0]) <= 0)
 | 
			
		||||
				{
 | 
			
		||||
				perror(dbfile);
 | 
			
		||||
				BIO_printf(bio_err,"unable to open '%s'\n",dbfile);
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			j=TXT_DB_write(out,db);
 | 
			
		||||
			if (j <= 0) goto err;
 | 
			
		||||
			BIO_free_all(out);
 | 
			
		||||
			out = NULL;
 | 
			
		||||
			BIO_free_all(in);
 | 
			
		||||
			in = NULL;
 | 
			
		||||
			strncpy(buf[1],dbfile,BSIZE-4);
 | 
			
		||||
			buf[1][BSIZE-4]='\0';
 | 
			
		||||
#ifndef OPENSSL_SYS_VMS
 | 
			
		||||
			strcat(buf[1],".old");
 | 
			
		||||
#else
 | 
			
		||||
			strcat(buf[1],"-old");
 | 
			
		||||
#endif
 | 
			
		||||
			if (rename(dbfile,buf[1]) < 0)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err,"unable to rename %s to %s\n", dbfile, buf[1]);
 | 
			
		||||
				perror("reason");
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			if (rename(buf[0],dbfile) < 0)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err,"unable to rename %s to %s\n", buf[0],dbfile);
 | 
			
		||||
				perror("reason");
 | 
			
		||||
				rename(buf[1],dbfile);
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			BIO_printf(bio_err,"Data Base Updated\n"); 
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@@ -1500,9 +1642,9 @@ err:
 | 
			
		||||
	if (free_key && key)
 | 
			
		||||
		OPENSSL_free(key);
 | 
			
		||||
	BN_free(serial);
 | 
			
		||||
	free_index(db);
 | 
			
		||||
	TXT_DB_free(db);
 | 
			
		||||
	EVP_PKEY_free(pkey);
 | 
			
		||||
	if (x509) X509_free(x509);
 | 
			
		||||
	X509_free(x509);
 | 
			
		||||
	X509_CRL_free(crl);
 | 
			
		||||
	NCONF_free(conf);
 | 
			
		||||
	OBJ_cleanup();
 | 
			
		||||
@@ -1515,12 +1657,110 @@ static void lookup_fail(char *name, char *tag)
 | 
			
		||||
	BIO_printf(bio_err,"variable lookup failed for %s::%s\n",name,tag);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static unsigned long index_serial_hash(const char **a)
 | 
			
		||||
	{
 | 
			
		||||
	const char *n;
 | 
			
		||||
 | 
			
		||||
	n=a[DB_serial];
 | 
			
		||||
	while (*n == '0') n++;
 | 
			
		||||
	return(lh_strhash(n));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int index_serial_cmp(const char **a, const char **b)
 | 
			
		||||
	{
 | 
			
		||||
	const char *aa,*bb;
 | 
			
		||||
 | 
			
		||||
	for (aa=a[DB_serial]; *aa == '0'; aa++);
 | 
			
		||||
	for (bb=b[DB_serial]; *bb == '0'; bb++);
 | 
			
		||||
	return(strcmp(aa,bb));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static unsigned long index_name_hash(const char **a)
 | 
			
		||||
	{ return(lh_strhash(a[DB_name])); }
 | 
			
		||||
 | 
			
		||||
static int index_name_qual(char **a)
 | 
			
		||||
	{ return(a[0][0] == 'V'); }
 | 
			
		||||
 | 
			
		||||
static int index_name_cmp(const char **a, const char **b)
 | 
			
		||||
	{ return(strcmp(a[DB_name],
 | 
			
		||||
	     b[DB_name])); }
 | 
			
		||||
 | 
			
		||||
static BIGNUM *load_serial(char *serialfile)
 | 
			
		||||
	{
 | 
			
		||||
	BIO *in=NULL;
 | 
			
		||||
	BIGNUM *ret=NULL;
 | 
			
		||||
	MS_STATIC char buf[1024];
 | 
			
		||||
	ASN1_INTEGER *ai=NULL;
 | 
			
		||||
 | 
			
		||||
	if ((in=BIO_new(BIO_s_file())) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		ERR_print_errors(bio_err);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (BIO_read_filename(in,serialfile) <= 0)
 | 
			
		||||
		{
 | 
			
		||||
		perror(serialfile);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	ai=ASN1_INTEGER_new();
 | 
			
		||||
	if (ai == NULL) goto err;
 | 
			
		||||
	if (!a2i_ASN1_INTEGER(in,ai,buf,1024))
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"unable to load number from %s\n",
 | 
			
		||||
			serialfile);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	ret=ASN1_INTEGER_to_BN(ai,NULL);
 | 
			
		||||
	if (ret == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"error converting number from bin to BIGNUM\n");
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
err:
 | 
			
		||||
	if (in != NULL) BIO_free(in);
 | 
			
		||||
	if (ai != NULL) ASN1_INTEGER_free(ai);
 | 
			
		||||
	return(ret);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int save_serial(char *serialfile, BIGNUM *serial)
 | 
			
		||||
	{
 | 
			
		||||
	BIO *out;
 | 
			
		||||
	int ret=0;
 | 
			
		||||
	ASN1_INTEGER *ai=NULL;
 | 
			
		||||
 | 
			
		||||
	out=BIO_new(BIO_s_file());
 | 
			
		||||
	if (out == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		ERR_print_errors(bio_err);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	if (BIO_write_filename(out,serialfile) <= 0)
 | 
			
		||||
		{
 | 
			
		||||
		perror(serialfile);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if ((ai=BN_to_ASN1_INTEGER(serial,NULL)) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"error converting serial to ASN.1 format\n");
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	i2a_ASN1_INTEGER(out,ai);
 | 
			
		||||
	BIO_puts(out,"\n");
 | 
			
		||||
	ret=1;
 | 
			
		||||
err:
 | 
			
		||||
	if (out != NULL) BIO_free_all(out);
 | 
			
		||||
	if (ai != NULL) ASN1_INTEGER_free(ai);
 | 
			
		||||
	return(ret);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int certify(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
 | 
			
		||||
	     const EVP_MD *dgst, STACK_OF(CONF_VALUE) *policy, CA_DB *db,
 | 
			
		||||
	     const EVP_MD *dgst, STACK_OF(CONF_VALUE) *policy, TXT_DB *db,
 | 
			
		||||
	     BIGNUM *serial, char *subj, int email_dn, char *startdate, char *enddate,
 | 
			
		||||
	     long days, int batch, char *ext_sect, CONF *lconf, int verbose,
 | 
			
		||||
	     unsigned long certopt, unsigned long nameopt, int default_op,
 | 
			
		||||
	     int ext_copy, int selfsign)
 | 
			
		||||
	     int ext_copy)
 | 
			
		||||
	{
 | 
			
		||||
	X509_REQ *req=NULL;
 | 
			
		||||
	BIO *in=NULL;
 | 
			
		||||
@@ -1545,12 +1785,6 @@ static int certify(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
 | 
			
		||||
 | 
			
		||||
	BIO_printf(bio_err,"Check that the request matches the signature\n");
 | 
			
		||||
 | 
			
		||||
	if (selfsign && !X509_REQ_check_private_key(req,pkey))
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"Certificate request and CA private key do not match\n");
 | 
			
		||||
		ok=0;
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	if ((pktmp=X509_REQ_get_pubkey(req)) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"error unpacking public key\n");
 | 
			
		||||
@@ -1575,7 +1809,7 @@ static int certify(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
 | 
			
		||||
 | 
			
		||||
	ok=do_body(xret,pkey,x509,dgst,policy,db,serial,subj, email_dn,
 | 
			
		||||
		startdate,enddate,days,batch,verbose,req,ext_sect,lconf,
 | 
			
		||||
		certopt, nameopt, default_op, ext_copy, selfsign);
 | 
			
		||||
		certopt, nameopt, default_op, ext_copy);
 | 
			
		||||
 | 
			
		||||
err:
 | 
			
		||||
	if (req != NULL) X509_REQ_free(req);
 | 
			
		||||
@@ -1584,7 +1818,7 @@ err:
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int certify_cert(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
 | 
			
		||||
	     const EVP_MD *dgst, STACK_OF(CONF_VALUE) *policy, CA_DB *db,
 | 
			
		||||
	     const EVP_MD *dgst, STACK_OF(CONF_VALUE) *policy, TXT_DB *db,
 | 
			
		||||
	     BIGNUM *serial, char *subj, int email_dn, char *startdate, char *enddate,
 | 
			
		||||
	     long days, int batch, char *ext_sect, CONF *lconf, int verbose,
 | 
			
		||||
	     unsigned long certopt, unsigned long nameopt, int default_op,
 | 
			
		||||
@@ -1629,7 +1863,7 @@ static int certify_cert(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
 | 
			
		||||
 | 
			
		||||
	ok=do_body(xret,pkey,x509,dgst,policy,db,serial,subj,email_dn,startdate,enddate,
 | 
			
		||||
		days,batch,verbose,rreq,ext_sect,lconf, certopt, nameopt, default_op,
 | 
			
		||||
		ext_copy, 0);
 | 
			
		||||
		ext_copy);
 | 
			
		||||
 | 
			
		||||
err:
 | 
			
		||||
	if (rreq != NULL) X509_REQ_free(rreq);
 | 
			
		||||
@@ -1638,11 +1872,11 @@ err:
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst,
 | 
			
		||||
	     STACK_OF(CONF_VALUE) *policy, CA_DB *db, BIGNUM *serial, char *subj,
 | 
			
		||||
	     STACK_OF(CONF_VALUE) *policy, TXT_DB *db, BIGNUM *serial, char *subj,
 | 
			
		||||
	     int email_dn, char *startdate, char *enddate, long days, int batch,
 | 
			
		||||
	     int verbose, X509_REQ *req, char *ext_sect, CONF *lconf,
 | 
			
		||||
	     unsigned long certopt, unsigned long nameopt, int default_op,
 | 
			
		||||
	     int ext_copy, int selfsign)
 | 
			
		||||
	     int ext_copy)
 | 
			
		||||
	{
 | 
			
		||||
	X509_NAME *name=NULL,*CAname=NULL,*subject=NULL, *dn_subject=NULL;
 | 
			
		||||
	ASN1_UTCTIME *tm,*tmptm;
 | 
			
		||||
@@ -1656,7 +1890,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst,
 | 
			
		||||
	int ok= -1,i,j,last,nid;
 | 
			
		||||
	char *p;
 | 
			
		||||
	CONF_VALUE *cv;
 | 
			
		||||
	char *row[DB_NUMBER],**rrow=NULL,**irow=NULL;
 | 
			
		||||
	char *row[DB_NUMBER],**rrow,**irow=NULL;
 | 
			
		||||
	char buf[25];
 | 
			
		||||
 | 
			
		||||
	tmptm=ASN1_UTCTIME_new();
 | 
			
		||||
@@ -1746,9 +1980,6 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	/* take a copy of the issuer name before we mess with it. */
 | 
			
		||||
	if (selfsign)
 | 
			
		||||
		CAname=X509_NAME_dup(name);
 | 
			
		||||
	else
 | 
			
		||||
	CAname=X509_NAME_dup(x509->cert_info->subject);
 | 
			
		||||
	if (CAname == NULL) goto err;
 | 
			
		||||
	str=str2=NULL;
 | 
			
		||||
@@ -1896,19 +2127,15 @@ again2:
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (db->attributes.unique_subject)
 | 
			
		||||
		{
 | 
			
		||||
		rrow=TXT_DB_get_by_index(db->db,DB_name,row);
 | 
			
		||||
	rrow=TXT_DB_get_by_index(db,DB_name,row);
 | 
			
		||||
	if (rrow != NULL)
 | 
			
		||||
		{
 | 
			
		||||
			BIO_printf(bio_err,
 | 
			
		||||
				"ERROR:There is already a certificate for %s\n",
 | 
			
		||||
		BIO_printf(bio_err,"ERROR:There is already a certificate for %s\n",
 | 
			
		||||
			row[DB_name]);
 | 
			
		||||
		}
 | 
			
		||||
		}
 | 
			
		||||
	if (rrow == NULL)
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
		rrow=TXT_DB_get_by_index(db->db,DB_serial,row);
 | 
			
		||||
		rrow=TXT_DB_get_by_index(db,DB_serial,row);
 | 
			
		||||
		if (rrow != NULL)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,"ERROR:Serial number %s has already been issued,\n",
 | 
			
		||||
@@ -1961,16 +2188,8 @@ again2:
 | 
			
		||||
 | 
			
		||||
	if (BN_to_ASN1_INTEGER(serial,ci->serialNumber) == NULL)
 | 
			
		||||
		goto err;
 | 
			
		||||
	if (selfsign)
 | 
			
		||||
		{
 | 
			
		||||
		if (!X509_set_issuer_name(ret,subject))
 | 
			
		||||
			goto err;
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
	if (!X509_set_issuer_name(ret,X509_get_subject_name(x509)))
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (strcmp(startdate,"today") == 0)
 | 
			
		||||
		X509_gmtime_adj(X509_get_notBefore(ret),0);
 | 
			
		||||
@@ -2005,9 +2224,6 @@ again2:
 | 
			
		||||
		ci->extensions = NULL;
 | 
			
		||||
 | 
			
		||||
		/* Initialize the context structure */
 | 
			
		||||
		if (selfsign)
 | 
			
		||||
			X509V3_set_ctx(&ctx, ret, ret, req, NULL, 0);
 | 
			
		||||
		else
 | 
			
		||||
		X509V3_set_ctx(&ctx, x509, ret, req, NULL, 0);
 | 
			
		||||
 | 
			
		||||
		if (extconf)
 | 
			
		||||
@@ -2075,7 +2291,7 @@ again2:
 | 
			
		||||
 | 
			
		||||
	BIO_printf(bio_err,"Certificate is to be certified until ");
 | 
			
		||||
	ASN1_UTCTIME_print(bio_err,X509_get_notAfter(ret));
 | 
			
		||||
	if (days) BIO_printf(bio_err," (%ld days)",days);
 | 
			
		||||
	if (days) BIO_printf(bio_err," (%d days)",days);
 | 
			
		||||
	BIO_printf(bio_err, "\n");
 | 
			
		||||
 | 
			
		||||
	if (!batch)
 | 
			
		||||
@@ -2102,16 +2318,6 @@ again2:
 | 
			
		||||
		EVP_PKEY_copy_parameters(pktmp,pkey);
 | 
			
		||||
	EVP_PKEY_free(pktmp);
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
	if (pkey->type == EVP_PKEY_EC)
 | 
			
		||||
		dgst = EVP_ecdsa();
 | 
			
		||||
	pktmp = X509_get_pubkey(ret);
 | 
			
		||||
	if (EVP_PKEY_missing_parameters(pktmp) &&
 | 
			
		||||
		!EVP_PKEY_missing_parameters(pkey))
 | 
			
		||||
		EVP_PKEY_copy_parameters(pktmp, pkey);
 | 
			
		||||
	EVP_PKEY_free(pktmp);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	if (!X509_sign(ret,pkey,dgst))
 | 
			
		||||
		goto err;
 | 
			
		||||
@@ -2153,10 +2359,10 @@ again2:
 | 
			
		||||
		}
 | 
			
		||||
	irow[DB_NUMBER]=NULL;
 | 
			
		||||
 | 
			
		||||
	if (!TXT_DB_insert(db->db,irow))
 | 
			
		||||
	if (!TXT_DB_insert(db,irow))
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"failed to update database\n");
 | 
			
		||||
		BIO_printf(bio_err,"TXT_DB error number %ld\n",db->db->error);
 | 
			
		||||
		BIO_printf(bio_err,"TXT_DB error number %ld\n",db->error);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	ok=1;
 | 
			
		||||
@@ -2207,7 +2413,7 @@ static void write_new_certificate(BIO *bp, X509 *x, int output_der, int notext)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
 | 
			
		||||
	     const EVP_MD *dgst, STACK_OF(CONF_VALUE) *policy, CA_DB *db,
 | 
			
		||||
	     const EVP_MD *dgst, STACK_OF(CONF_VALUE) *policy, TXT_DB *db,
 | 
			
		||||
	     BIGNUM *serial, char *subj, int email_dn, char *startdate, char *enddate,
 | 
			
		||||
	     long days, char *ext_sect, CONF *lconf, int verbose, unsigned long certopt,
 | 
			
		||||
	     unsigned long nameopt, int default_op, int ext_copy)
 | 
			
		||||
@@ -2351,7 +2557,7 @@ static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
 | 
			
		||||
	EVP_PKEY_free(pktmp);
 | 
			
		||||
	ok=do_body(xret,pkey,x509,dgst,policy,db,serial,subj,email_dn,startdate,enddate,
 | 
			
		||||
		   days,1,verbose,req,ext_sect,lconf, certopt, nameopt, default_op,
 | 
			
		||||
			ext_copy, 0);
 | 
			
		||||
			ext_copy);
 | 
			
		||||
err:
 | 
			
		||||
	if (req != NULL) X509_REQ_free(req);
 | 
			
		||||
	if (parms != NULL) CONF_free(parms);
 | 
			
		||||
@@ -2386,7 +2592,7 @@ static int check_time_format(char *str)
 | 
			
		||||
	return(ASN1_UTCTIME_check(&tm));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
 | 
			
		||||
static int do_revoke(X509 *x509, TXT_DB *db, int type, char *value)
 | 
			
		||||
	{
 | 
			
		||||
	ASN1_UTCTIME *tm=NULL;
 | 
			
		||||
	char *row[DB_NUMBER],**rrow,**irow;
 | 
			
		||||
@@ -2411,10 +2617,10 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
 | 
			
		||||
	/* We have to lookup by serial number because name lookup
 | 
			
		||||
	 * skips revoked certs
 | 
			
		||||
 	 */
 | 
			
		||||
	rrow=TXT_DB_get_by_index(db->db,DB_serial,row);
 | 
			
		||||
	rrow=TXT_DB_get_by_index(db,DB_serial,row);
 | 
			
		||||
	if (rrow == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"Adding Entry with serial number %s to DB for %s\n", row[DB_serial], row[DB_name]);
 | 
			
		||||
		BIO_printf(bio_err,"Adding Entry to DB for %s\n", row[DB_name]);
 | 
			
		||||
 | 
			
		||||
		/* We now just add it to the database */
 | 
			
		||||
		row[DB_type]=(char *)OPENSSL_malloc(2);
 | 
			
		||||
@@ -2454,10 +2660,10 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
 | 
			
		||||
			}
 | 
			
		||||
		irow[DB_NUMBER]=NULL;
 | 
			
		||||
 | 
			
		||||
		if (!TXT_DB_insert(db->db,irow))
 | 
			
		||||
		if (!TXT_DB_insert(db,irow))
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,"failed to update database\n");
 | 
			
		||||
			BIO_printf(bio_err,"TXT_DB error number %ld\n",db->db->error);
 | 
			
		||||
			BIO_printf(bio_err,"TXT_DB error number %ld\n",db->error);
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@@ -2502,7 +2708,7 @@ err:
 | 
			
		||||
	return(ok);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int get_certificate_status(const char *serial, CA_DB *db)
 | 
			
		||||
static int get_certificate_status(const char *serial, TXT_DB *db)
 | 
			
		||||
	{
 | 
			
		||||
	char *row[DB_NUMBER],**rrow;
 | 
			
		||||
	int ok=-1,i;
 | 
			
		||||
@@ -2543,7 +2749,7 @@ static int get_certificate_status(const char *serial, CA_DB *db)
 | 
			
		||||
	ok=1;
 | 
			
		||||
 | 
			
		||||
	/* Search for the certificate */
 | 
			
		||||
	rrow=TXT_DB_get_by_index(db->db,DB_serial,row);
 | 
			
		||||
	rrow=TXT_DB_get_by_index(db,DB_serial,row);
 | 
			
		||||
	if (rrow == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"Serial %s not present in db.\n",
 | 
			
		||||
@@ -2590,7 +2796,7 @@ err:
 | 
			
		||||
	return(ok);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int do_updatedb (CA_DB *db)
 | 
			
		||||
static int do_updatedb (TXT_DB *db)
 | 
			
		||||
	{
 | 
			
		||||
	ASN1_UTCTIME	*a_tm = NULL;
 | 
			
		||||
	int i, cnt = 0;
 | 
			
		||||
@@ -2616,9 +2822,9 @@ static int do_updatedb (CA_DB *db)
 | 
			
		||||
	else
 | 
			
		||||
		a_y2k = 0;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < sk_num(db->db->data); i++)
 | 
			
		||||
	for (i = 0; i < sk_num(db->data); i++)
 | 
			
		||||
		{
 | 
			
		||||
		rrow = (char **) sk_value(db->db->data, i);
 | 
			
		||||
		rrow = (char **) sk_value(db->data, i);
 | 
			
		||||
 | 
			
		||||
		if (rrow[DB_type][0] == 'V')
 | 
			
		||||
		 	{
 | 
			
		||||
@@ -3105,3 +3311,17 @@ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold, ASN1_G
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int make_serial_index(TXT_DB *db)
 | 
			
		||||
	{
 | 
			
		||||
	if (!TXT_DB_create_index(db, DB_serial, NULL,
 | 
			
		||||
				LHASH_HASH_FN(index_serial_hash),
 | 
			
		||||
				LHASH_COMP_FN(index_serial_cmp)))
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,
 | 
			
		||||
		  "error creating serial number index:(%ld,%ld,%ld)\n",
 | 
			
		||||
		  			db->error,db->arg1,db->arg2);
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
	return 1;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -56,12 +56,6 @@
 | 
			
		||||
 * [including the GNU Public Licence.]
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* Until the key-gen callbacks are modified to use newer prototypes, we allow
 | 
			
		||||
 * deprecated functions for openssl-internal code */
 | 
			
		||||
#ifdef OPENSSL_NO_DEPRECATED
 | 
			
		||||
#undef OPENSSL_NO_DEPRECATED
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
@@ -88,23 +82,9 @@
 | 
			
		||||
 * -C
 | 
			
		||||
 * -noout
 | 
			
		||||
 * -genkey
 | 
			
		||||
 *  #ifdef GENCB_TEST
 | 
			
		||||
 * -timebomb n  - interrupt keygen after <n> seconds
 | 
			
		||||
 *  #endif
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifdef GENCB_TEST
 | 
			
		||||
 | 
			
		||||
static int stop_keygen_flag = 0;
 | 
			
		||||
 | 
			
		||||
static void timebomb_sigalarm(int foo)
 | 
			
		||||
	{
 | 
			
		||||
	stop_keygen_flag = 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static int MS_CALLBACK dsa_cb(int p, int n, BN_GENCB *cb);
 | 
			
		||||
static void MS_CALLBACK dsa_cb(int p, int n, void *arg);
 | 
			
		||||
 | 
			
		||||
int MAIN(int, char **);
 | 
			
		||||
 | 
			
		||||
@@ -123,9 +103,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
#ifndef OPENSSL_NO_ENGINE
 | 
			
		||||
	char *engine=NULL;
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef GENCB_TEST
 | 
			
		||||
	int timebomb=0;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	apps_startup();
 | 
			
		||||
 | 
			
		||||
@@ -172,13 +149,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			engine = *(++argv);
 | 
			
		||||
			}
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef GENCB_TEST
 | 
			
		||||
		else if(strcmp(*argv, "-timebomb") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			timebomb = atoi(*(++argv));
 | 
			
		||||
			}
 | 
			
		||||
#endif
 | 
			
		||||
		else if (strcmp(*argv,"-text") == 0)
 | 
			
		||||
			text=1;
 | 
			
		||||
@@ -229,9 +199,6 @@ bad:
 | 
			
		||||
		BIO_printf(bio_err," -rand         files to use for random number input\n");
 | 
			
		||||
#ifndef OPENSSL_NO_ENGINE
 | 
			
		||||
		BIO_printf(bio_err," -engine e     use engine e, possibly a hardware device.\n");
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef GENCB_TEST
 | 
			
		||||
		BIO_printf(bio_err," -timebomb n   interrupt keygen after <n> seconds\n");
 | 
			
		||||
#endif
 | 
			
		||||
		BIO_printf(bio_err," number        number of bits to use for generating private key\n");
 | 
			
		||||
		goto end;
 | 
			
		||||
@@ -290,47 +257,10 @@ bad:
 | 
			
		||||
 | 
			
		||||
	if (numbits > 0)
 | 
			
		||||
		{
 | 
			
		||||
		BN_GENCB cb;
 | 
			
		||||
		BN_GENCB_set(&cb, dsa_cb, bio_err);
 | 
			
		||||
		assert(need_rand);
 | 
			
		||||
		dsa = DSA_new();
 | 
			
		||||
		if(!dsa)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,"Error allocating DSA object\n");
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		BIO_printf(bio_err,"Generating DSA parameters, %d bit long prime\n",num);
 | 
			
		||||
	        BIO_printf(bio_err,"This could take some time\n");
 | 
			
		||||
#ifdef GENCB_TEST
 | 
			
		||||
		if(timebomb > 0)
 | 
			
		||||
	{
 | 
			
		||||
		struct sigaction act;
 | 
			
		||||
		act.sa_handler = timebomb_sigalarm;
 | 
			
		||||
		act.sa_flags = 0;
 | 
			
		||||
		BIO_printf(bio_err,"(though I'll stop it if not done within %d secs)\n",
 | 
			
		||||
				timebomb);
 | 
			
		||||
		if(sigaction(SIGALRM, &act, NULL) != 0)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,"Error, couldn't set SIGALRM handler\n");
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		alarm(timebomb);
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
	        if(!DSA_generate_parameters_ex(dsa,num,NULL,0,NULL,NULL, &cb))
 | 
			
		||||
			{
 | 
			
		||||
#ifdef GENCB_TEST
 | 
			
		||||
			if(stop_keygen_flag)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err,"DSA key generation time-stopped\n");
 | 
			
		||||
				/* This is an asked-for behaviour! */
 | 
			
		||||
				ret = 0;
 | 
			
		||||
				goto end;
 | 
			
		||||
				}
 | 
			
		||||
#endif
 | 
			
		||||
			BIO_printf(bio_err,"Error, DSA key generation failed\n");
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
	        dsa=DSA_generate_parameters(num,NULL,0,NULL,NULL, dsa_cb,bio_err);
 | 
			
		||||
		}
 | 
			
		||||
	else if	(informat == FORMAT_ASN1)
 | 
			
		||||
		dsa=d2i_DSAparams_bio(in,NULL);
 | 
			
		||||
@@ -455,7 +385,7 @@ end:
 | 
			
		||||
	OPENSSL_EXIT(ret);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int MS_CALLBACK dsa_cb(int p, int n, BN_GENCB *cb)
 | 
			
		||||
static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
 | 
			
		||||
	{
 | 
			
		||||
	char c='*';
 | 
			
		||||
 | 
			
		||||
@@ -463,15 +393,10 @@ static int MS_CALLBACK dsa_cb(int p, int n, BN_GENCB *cb)
 | 
			
		||||
	if (p == 1) c='+';
 | 
			
		||||
	if (p == 2) c='*';
 | 
			
		||||
	if (p == 3) c='\n';
 | 
			
		||||
	BIO_write(cb->arg,&c,1);
 | 
			
		||||
	(void)BIO_flush(cb->arg);
 | 
			
		||||
	BIO_write(arg,&c,1);
 | 
			
		||||
	(void)BIO_flush(arg);
 | 
			
		||||
#ifdef LINT
 | 
			
		||||
	p=n;
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef GENCB_TEST
 | 
			
		||||
	if(stop_keygen_flag)
 | 
			
		||||
		return 0;
 | 
			
		||||
#endif
 | 
			
		||||
	return 1;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										395
									
								
								apps/ec.c
									
									
									
									
									
								
							
							
						
						
									
										395
									
								
								apps/ec.c
									
									
									
									
									
								
							@@ -1,395 +0,0 @@
 | 
			
		||||
/* apps/ec.c */
 | 
			
		||||
/*
 | 
			
		||||
 * Written by Nils Larsch for the OpenSSL project.
 | 
			
		||||
 */
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *
 | 
			
		||||
 * 1. Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer. 
 | 
			
		||||
 *
 | 
			
		||||
 * 2. Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * 3. All advertising materials mentioning features or use of this
 | 
			
		||||
 *    software must display the following acknowledgment:
 | 
			
		||||
 *    "This product includes software developed by the OpenSSL Project
 | 
			
		||||
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 | 
			
		||||
 *
 | 
			
		||||
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 | 
			
		||||
 *    endorse or promote products derived from this software without
 | 
			
		||||
 *    prior written permission. For written permission, please contact
 | 
			
		||||
 *    openssl-core@openssl.org.
 | 
			
		||||
 *
 | 
			
		||||
 * 5. Products derived from this software may not be called "OpenSSL"
 | 
			
		||||
 *    nor may "OpenSSL" appear in their names without prior written
 | 
			
		||||
 *    permission of the OpenSSL Project.
 | 
			
		||||
 *
 | 
			
		||||
 * 6. Redistributions of any form whatsoever must retain the following
 | 
			
		||||
 *    acknowledgment:
 | 
			
		||||
 *    "This product includes software developed by the OpenSSL Project
 | 
			
		||||
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 | 
			
		||||
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 | 
			
		||||
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
 | 
			
		||||
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 | 
			
		||||
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 | 
			
		||||
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 | 
			
		||||
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 | 
			
		||||
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 | 
			
		||||
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 | 
			
		||||
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 | 
			
		||||
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
 * ====================================================================
 | 
			
		||||
 *
 | 
			
		||||
 * This product includes cryptographic software written by Eric Young
 | 
			
		||||
 * (eay@cryptsoft.com).  This product includes software written by Tim
 | 
			
		||||
 * Hudson (tjh@cryptsoft.com).
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include "apps.h"
 | 
			
		||||
#include <openssl/bio.h>
 | 
			
		||||
#include <openssl/err.h>
 | 
			
		||||
#include <openssl/evp.h>
 | 
			
		||||
#include <openssl/pem.h>
 | 
			
		||||
 | 
			
		||||
#undef PROG
 | 
			
		||||
#define PROG	ec_main
 | 
			
		||||
 | 
			
		||||
/* -inform arg    - input format - default PEM (one of DER, NET or PEM)
 | 
			
		||||
 * -outform arg   - output format - default PEM
 | 
			
		||||
 * -in arg        - input file - default stdin
 | 
			
		||||
 * -out arg       - output file - default stdout
 | 
			
		||||
 * -des           - encrypt output if PEM format with DES in cbc mode
 | 
			
		||||
 * -text          - print a text version
 | 
			
		||||
 * -param_out     - print the elliptic curve parameters
 | 
			
		||||
 * -conv_form arg - specifies the point encoding form
 | 
			
		||||
 * -param_enc arg - specifies the parameter encoding
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
int MAIN(int, char **);
 | 
			
		||||
 | 
			
		||||
int MAIN(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
	ENGINE 	*e = NULL;
 | 
			
		||||
	int 	ret = 1;
 | 
			
		||||
	EC_KEY 	*eckey = NULL;
 | 
			
		||||
	int 	i, badops = 0;
 | 
			
		||||
	const EVP_CIPHER *enc = NULL;
 | 
			
		||||
	BIO 	*in = NULL, *out = NULL;
 | 
			
		||||
	int 	informat, outformat, text=0, noout=0;
 | 
			
		||||
	int  	pubin = 0, pubout = 0, param_out = 0;
 | 
			
		||||
	char 	*infile, *outfile, *prog, *engine;
 | 
			
		||||
	char 	*passargin = NULL, *passargout = NULL;
 | 
			
		||||
	char 	*passin = NULL, *passout = NULL;
 | 
			
		||||
	point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED;
 | 
			
		||||
	int	new_form = 0;
 | 
			
		||||
	int	asn1_flag = OPENSSL_EC_NAMED_CURVE;
 | 
			
		||||
	int 	new_asn1_flag = 0;
 | 
			
		||||
 | 
			
		||||
	apps_startup();
 | 
			
		||||
 | 
			
		||||
	if (bio_err == NULL)
 | 
			
		||||
		if ((bio_err=BIO_new(BIO_s_file())) != NULL)
 | 
			
		||||
			BIO_set_fp(bio_err, stderr, BIO_NOCLOSE|BIO_FP_TEXT);
 | 
			
		||||
 | 
			
		||||
	if (!load_config(bio_err, NULL))
 | 
			
		||||
		goto end;
 | 
			
		||||
 | 
			
		||||
	engine = NULL;
 | 
			
		||||
	infile = NULL;
 | 
			
		||||
	outfile = NULL;
 | 
			
		||||
	informat = FORMAT_PEM;
 | 
			
		||||
	outformat = FORMAT_PEM;
 | 
			
		||||
 | 
			
		||||
	prog = argv[0];
 | 
			
		||||
	argc--;
 | 
			
		||||
	argv++;
 | 
			
		||||
	while (argc >= 1)
 | 
			
		||||
		{
 | 
			
		||||
		if (strcmp(*argv,"-inform") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			informat=str2fmt(*(++argv));
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv,"-outform") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			outformat=str2fmt(*(++argv));
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv,"-in") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			infile= *(++argv);
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv,"-out") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			outfile= *(++argv);
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv,"-passin") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			passargin= *(++argv);
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv,"-passout") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			passargout= *(++argv);
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv, "-engine") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			engine= *(++argv);
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv, "-noout") == 0)
 | 
			
		||||
			noout = 1;
 | 
			
		||||
		else if (strcmp(*argv, "-text") == 0)
 | 
			
		||||
			text = 1;
 | 
			
		||||
		else if (strcmp(*argv, "-conv_form") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1)
 | 
			
		||||
				goto bad;
 | 
			
		||||
			++argv;
 | 
			
		||||
			new_form = 1;
 | 
			
		||||
			if (strcmp(*argv, "compressed") == 0)
 | 
			
		||||
				form = POINT_CONVERSION_COMPRESSED;
 | 
			
		||||
			else if (strcmp(*argv, "uncompressed") == 0)
 | 
			
		||||
				form = POINT_CONVERSION_UNCOMPRESSED;
 | 
			
		||||
			else if (strcmp(*argv, "hybrid") == 0)
 | 
			
		||||
				form = POINT_CONVERSION_HYBRID;
 | 
			
		||||
			else
 | 
			
		||||
				goto bad;
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv, "-param_enc") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1)
 | 
			
		||||
				goto bad;
 | 
			
		||||
			++argv;
 | 
			
		||||
			new_asn1_flag = 1;
 | 
			
		||||
			if (strcmp(*argv, "named_curve") == 0)
 | 
			
		||||
				asn1_flag = OPENSSL_EC_NAMED_CURVE;
 | 
			
		||||
			else if (strcmp(*argv, "explicit") == 0)
 | 
			
		||||
				asn1_flag = 0;
 | 
			
		||||
			else
 | 
			
		||||
				goto bad;
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv, "-param_out") == 0)
 | 
			
		||||
			param_out = 1;
 | 
			
		||||
		else if (strcmp(*argv, "-pubin") == 0)
 | 
			
		||||
			pubin=1;
 | 
			
		||||
		else if (strcmp(*argv, "-pubout") == 0)
 | 
			
		||||
			pubout=1;
 | 
			
		||||
		else if ((enc=EVP_get_cipherbyname(&(argv[0][1]))) == NULL)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err, "unknown option %s\n", *argv);
 | 
			
		||||
			badops=1;
 | 
			
		||||
			break;
 | 
			
		||||
			}
 | 
			
		||||
		argc--;
 | 
			
		||||
		argv++;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (badops)
 | 
			
		||||
		{
 | 
			
		||||
bad:
 | 
			
		||||
		BIO_printf(bio_err, "%s [options] <infile >outfile\n", prog);
 | 
			
		||||
		BIO_printf(bio_err, "where options are\n");
 | 
			
		||||
		BIO_printf(bio_err, " -inform arg     input format - "
 | 
			
		||||
				"DER or PEM\n");
 | 
			
		||||
		BIO_printf(bio_err, " -outform arg    output format - "
 | 
			
		||||
				"DER or PEM\n");
 | 
			
		||||
		BIO_printf(bio_err, " -in arg         input file\n");
 | 
			
		||||
		BIO_printf(bio_err, " -passin arg     input file pass "
 | 
			
		||||
				"phrase source\n");
 | 
			
		||||
		BIO_printf(bio_err, " -out arg        output file\n");
 | 
			
		||||
		BIO_printf(bio_err, " -passout arg    output file pass "
 | 
			
		||||
				"phrase source\n");
 | 
			
		||||
		BIO_printf(bio_err, " -engine e       use engine e, "
 | 
			
		||||
				"possibly a hardware device.\n");
 | 
			
		||||
		BIO_printf(bio_err, " -des            encrypt PEM output, "
 | 
			
		||||
				"instead of 'des' every other \n"
 | 
			
		||||
				"                 cipher "
 | 
			
		||||
				"supported by OpenSSL can be used\n");
 | 
			
		||||
		BIO_printf(bio_err, " -text           print the key\n");
 | 
			
		||||
		BIO_printf(bio_err, " -noout          don't print key out\n");
 | 
			
		||||
		BIO_printf(bio_err, " -param_out      print the elliptic "
 | 
			
		||||
				"curve parameters\n");
 | 
			
		||||
		BIO_printf(bio_err, " -conv_form arg  specifies the "
 | 
			
		||||
				"point conversion form \n");
 | 
			
		||||
		BIO_printf(bio_err, "                 possible values:"
 | 
			
		||||
				" compressed\n");
 | 
			
		||||
		BIO_printf(bio_err, "                                 "
 | 
			
		||||
				" uncompressed (default)\n");
 | 
			
		||||
		BIO_printf(bio_err, "                                  "
 | 
			
		||||
				" hybrid\n");
 | 
			
		||||
		BIO_printf(bio_err, " -param_enc arg  specifies the way"
 | 
			
		||||
				" the ec parameters are encoded\n");
 | 
			
		||||
		BIO_printf(bio_err, "                 in the asn1 der "
 | 
			
		||||
				"encoding\n");
 | 
			
		||||
		BIO_printf(bio_err, "                 possilbe values:"
 | 
			
		||||
				" named_curve (default)\n");
 | 
			
		||||
		BIO_printf(bio_err,"                                  "
 | 
			
		||||
				"explicit\n");
 | 
			
		||||
		goto end;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	ERR_load_crypto_strings();
 | 
			
		||||
 | 
			
		||||
        e = setup_engine(bio_err, engine, 0);
 | 
			
		||||
 | 
			
		||||
	if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) 
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err, "Error getting passwords\n");
 | 
			
		||||
		goto end;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	in = BIO_new(BIO_s_file());
 | 
			
		||||
	out = BIO_new(BIO_s_file());
 | 
			
		||||
	if ((in == NULL) || (out == NULL))
 | 
			
		||||
		{
 | 
			
		||||
		ERR_print_errors(bio_err);
 | 
			
		||||
		goto end;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (infile == NULL)
 | 
			
		||||
		BIO_set_fp(in, stdin, BIO_NOCLOSE);
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
		if (BIO_read_filename(in, infile) <= 0)
 | 
			
		||||
			{
 | 
			
		||||
			perror(infile);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	BIO_printf(bio_err, "read EC key\n");
 | 
			
		||||
	if (informat == FORMAT_ASN1) 
 | 
			
		||||
		{
 | 
			
		||||
		if (pubin) 
 | 
			
		||||
			eckey = d2i_EC_PUBKEY_bio(in, NULL);
 | 
			
		||||
		else 
 | 
			
		||||
			eckey = d2i_ECPrivateKey_bio(in, NULL);
 | 
			
		||||
		} 
 | 
			
		||||
	else if (informat == FORMAT_PEM) 
 | 
			
		||||
		{
 | 
			
		||||
		if (pubin) 
 | 
			
		||||
			eckey = PEM_read_bio_EC_PUBKEY(in, NULL, NULL, 
 | 
			
		||||
				NULL);
 | 
			
		||||
		else 
 | 
			
		||||
			eckey = PEM_read_bio_ECPrivateKey(in, NULL, NULL,
 | 
			
		||||
				passin);
 | 
			
		||||
		} 
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err, "bad input format specified for key\n");
 | 
			
		||||
		goto end;
 | 
			
		||||
		}
 | 
			
		||||
	if (eckey == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"unable to load Key\n");
 | 
			
		||||
		ERR_print_errors(bio_err);
 | 
			
		||||
		goto end;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (outfile == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_set_fp(out, stdout, BIO_NOCLOSE);
 | 
			
		||||
#ifdef OPENSSL_SYS_VMS
 | 
			
		||||
			{
 | 
			
		||||
			BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
			
		||||
			out = BIO_push(tmpbio, out);
 | 
			
		||||
			}
 | 
			
		||||
#endif
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
		if (BIO_write_filename(out, outfile) <= 0)
 | 
			
		||||
			{
 | 
			
		||||
			perror(outfile);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (new_form)
 | 
			
		||||
		{
 | 
			
		||||
		EC_GROUP_set_point_conversion_form(eckey->group, form);
 | 
			
		||||
		eckey->conv_form = form;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (new_asn1_flag)
 | 
			
		||||
		EC_GROUP_set_asn1_flag(eckey->group, asn1_flag);
 | 
			
		||||
 | 
			
		||||
	if (text) 
 | 
			
		||||
		if (!EC_KEY_print(out, eckey, 0))
 | 
			
		||||
			{
 | 
			
		||||
			perror(outfile);
 | 
			
		||||
			ERR_print_errors(bio_err);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
	if (noout) 
 | 
			
		||||
		goto end;
 | 
			
		||||
 | 
			
		||||
	BIO_printf(bio_err, "writing EC key\n");
 | 
			
		||||
	if (outformat == FORMAT_ASN1) 
 | 
			
		||||
		{
 | 
			
		||||
		if (param_out)
 | 
			
		||||
			i = i2d_ECPKParameters_bio(out, eckey->group);
 | 
			
		||||
		else if (pubin || pubout) 
 | 
			
		||||
			i = i2d_EC_PUBKEY_bio(out, eckey);
 | 
			
		||||
		else 
 | 
			
		||||
			i = i2d_ECPrivateKey_bio(out, eckey);
 | 
			
		||||
		} 
 | 
			
		||||
	else if (outformat == FORMAT_PEM) 
 | 
			
		||||
		{
 | 
			
		||||
		if (param_out)
 | 
			
		||||
			i = PEM_write_bio_ECPKParameters(out, eckey->group);
 | 
			
		||||
		else if (pubin || pubout)
 | 
			
		||||
			i = PEM_write_bio_EC_PUBKEY(out, eckey);
 | 
			
		||||
		else 
 | 
			
		||||
			i = PEM_write_bio_ECPrivateKey(out, eckey, enc,
 | 
			
		||||
						NULL, 0, NULL, passout);
 | 
			
		||||
		} 
 | 
			
		||||
	else 
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err, "bad output format specified for "
 | 
			
		||||
			"outfile\n");
 | 
			
		||||
		goto end;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (!i)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err, "unable to write private key\n");
 | 
			
		||||
		ERR_print_errors(bio_err);
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		ret=0;
 | 
			
		||||
end:
 | 
			
		||||
	if (in)
 | 
			
		||||
		BIO_free(in);
 | 
			
		||||
	if (out)
 | 
			
		||||
		BIO_free_all(out);
 | 
			
		||||
	if (eckey)
 | 
			
		||||
		EC_KEY_free(eckey);
 | 
			
		||||
	if (passin)
 | 
			
		||||
		OPENSSL_free(passin);
 | 
			
		||||
	if (passout)
 | 
			
		||||
		OPENSSL_free(passout);
 | 
			
		||||
	apps_shutdown();
 | 
			
		||||
	OPENSSL_EXIT(ret);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										728
									
								
								apps/ecparam.c
									
									
									
									
									
								
							
							
						
						
									
										728
									
								
								apps/ecparam.c
									
									
									
									
									
								
							@@ -1,728 +0,0 @@
 | 
			
		||||
/* apps/ecparam.c */
 | 
			
		||||
/*
 | 
			
		||||
 * Written by Nils Larsch for the OpenSSL project.
 | 
			
		||||
 */
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *
 | 
			
		||||
 * 1. Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer. 
 | 
			
		||||
 *
 | 
			
		||||
 * 2. Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * 3. All advertising materials mentioning features or use of this
 | 
			
		||||
 *    software must display the following acknowledgment:
 | 
			
		||||
 *    "This product includes software developed by the OpenSSL Project
 | 
			
		||||
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 | 
			
		||||
 *
 | 
			
		||||
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 | 
			
		||||
 *    endorse or promote products derived from this software without
 | 
			
		||||
 *    prior written permission. For written permission, please contact
 | 
			
		||||
 *    openssl-core@openssl.org.
 | 
			
		||||
 *
 | 
			
		||||
 * 5. Products derived from this software may not be called "OpenSSL"
 | 
			
		||||
 *    nor may "OpenSSL" appear in their names without prior written
 | 
			
		||||
 *    permission of the OpenSSL Project.
 | 
			
		||||
 *
 | 
			
		||||
 * 6. Redistributions of any form whatsoever must retain the following
 | 
			
		||||
 *    acknowledgment:
 | 
			
		||||
 *    "This product includes software developed by the OpenSSL Project
 | 
			
		||||
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 | 
			
		||||
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 | 
			
		||||
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
 | 
			
		||||
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 | 
			
		||||
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 | 
			
		||||
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 | 
			
		||||
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 | 
			
		||||
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 | 
			
		||||
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 | 
			
		||||
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 | 
			
		||||
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
 * ====================================================================
 | 
			
		||||
 *
 | 
			
		||||
 * This product includes cryptographic software written by Eric Young
 | 
			
		||||
 * (eay@cryptsoft.com).  This product includes software written by Tim
 | 
			
		||||
 * Hudson (tjh@cryptsoft.com).
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 | 
			
		||||
 *
 | 
			
		||||
 * Portions of the attached software ("Contribution") are developed by 
 | 
			
		||||
 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
 | 
			
		||||
 *
 | 
			
		||||
 * The Contribution is licensed pursuant to the OpenSSL open source
 | 
			
		||||
 * license provided above.
 | 
			
		||||
 *
 | 
			
		||||
 * The elliptic curve binary polynomial software is originally written by 
 | 
			
		||||
 * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include "apps.h"
 | 
			
		||||
#include <openssl/bio.h>
 | 
			
		||||
#include <openssl/err.h>
 | 
			
		||||
#include <openssl/bn.h>
 | 
			
		||||
#include <openssl/ec.h>
 | 
			
		||||
#include <openssl/x509.h>
 | 
			
		||||
#include <openssl/pem.h>
 | 
			
		||||
 | 
			
		||||
#undef PROG
 | 
			
		||||
#define PROG	ecparam_main
 | 
			
		||||
 | 
			
		||||
/* -inform arg      - input format - default PEM (DER or PEM)
 | 
			
		||||
 * -outform arg     - output format - default PEM
 | 
			
		||||
 * -in  arg         - input file  - default stdin
 | 
			
		||||
 * -out arg         - output file - default stdout
 | 
			
		||||
 * -noout           - do not print the ec parameter
 | 
			
		||||
 * -text            - print the ec parameters in text form
 | 
			
		||||
 * -check           - validate the ec parameters
 | 
			
		||||
 * -C               - print a 'C' function creating the parameters
 | 
			
		||||
 * -name arg        - use the ec parameters with 'short name' name
 | 
			
		||||
 * -list_curves     - prints a list of all currently available curve 'short names'
 | 
			
		||||
 * -conv_form arg   - specifies the point conversion form 
 | 
			
		||||
 *                  - possible values: compressed
 | 
			
		||||
 *                                     uncompressed (default)
 | 
			
		||||
 *                                     hybrid
 | 
			
		||||
 * -param_enc arg   - specifies the way the ec parameters are encoded
 | 
			
		||||
 *                    in the asn1 der encoding
 | 
			
		||||
 *                    possible values: named_curve (default)
 | 
			
		||||
 *                                     explicit
 | 
			
		||||
 * -no_seed         - if 'explicit' parameters are choosen do not use the seed
 | 
			
		||||
 * -genkey          - generate ec key
 | 
			
		||||
 * -rand file       - files to use for random number input
 | 
			
		||||
 * -engine e        - use engine e, possibly a hardware device
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int ecparam_print_var(BIO *,BIGNUM *,const char *,int,unsigned char *);
 | 
			
		||||
 | 
			
		||||
int MAIN(int, char **);
 | 
			
		||||
 | 
			
		||||
int MAIN(int argc, char **argv)
 | 
			
		||||
	{
 | 
			
		||||
	EC_GROUP *group = NULL;
 | 
			
		||||
	point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED; 
 | 
			
		||||
	int 	new_form = 0;
 | 
			
		||||
	int 	asn1_flag = OPENSSL_EC_NAMED_CURVE;
 | 
			
		||||
	int 	new_asn1_flag = 0;
 | 
			
		||||
	char 	*curve_name = NULL, *inrand = NULL;
 | 
			
		||||
	int	list_curves = 0, no_seed = 0, check = 0,
 | 
			
		||||
		badops = 0, text = 0, i, need_rand = 0, genkey = 0;
 | 
			
		||||
	char	*infile = NULL, *outfile = NULL, *prog;
 | 
			
		||||
	BIO 	*in = NULL, *out = NULL;
 | 
			
		||||
	int 	informat, outformat, noout = 0, C = 0, ret = 1;
 | 
			
		||||
	ENGINE	*e = NULL;
 | 
			
		||||
	char	*engine = NULL;
 | 
			
		||||
 | 
			
		||||
	BIGNUM	*ec_p = NULL, *ec_a = NULL, *ec_b = NULL,
 | 
			
		||||
		*ec_gen = NULL, *ec_order = NULL, *ec_cofactor = NULL;
 | 
			
		||||
	unsigned char *buffer = NULL;
 | 
			
		||||
 | 
			
		||||
	apps_startup();
 | 
			
		||||
 | 
			
		||||
	if (bio_err == NULL)
 | 
			
		||||
		if ((bio_err=BIO_new(BIO_s_file())) != NULL)
 | 
			
		||||
			BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
			
		||||
 | 
			
		||||
	if (!load_config(bio_err, NULL))
 | 
			
		||||
		goto end;
 | 
			
		||||
 | 
			
		||||
	informat=FORMAT_PEM;
 | 
			
		||||
	outformat=FORMAT_PEM;
 | 
			
		||||
 | 
			
		||||
	prog=argv[0];
 | 
			
		||||
	argc--;
 | 
			
		||||
	argv++;
 | 
			
		||||
	while (argc >= 1)
 | 
			
		||||
		{
 | 
			
		||||
		if 	(strcmp(*argv,"-inform") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			informat=str2fmt(*(++argv));
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv,"-outform") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			outformat=str2fmt(*(++argv));
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv,"-in") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			infile= *(++argv);
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv,"-out") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			outfile= *(++argv);
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv,"-text") == 0)
 | 
			
		||||
			text = 1;
 | 
			
		||||
		else if (strcmp(*argv,"-C") == 0)
 | 
			
		||||
			C = 1;
 | 
			
		||||
		else if (strcmp(*argv,"-check") == 0)
 | 
			
		||||
			check = 1;
 | 
			
		||||
		else if (strcmp (*argv, "-name") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1)
 | 
			
		||||
				goto bad;
 | 
			
		||||
			curve_name = *(++argv);
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv, "-list_curves") == 0)
 | 
			
		||||
			list_curves = 1;
 | 
			
		||||
		else if (strcmp(*argv, "-conv_form") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1)
 | 
			
		||||
				goto bad;
 | 
			
		||||
			++argv;
 | 
			
		||||
			new_form = 1;
 | 
			
		||||
			if (strcmp(*argv, "compressed") == 0)
 | 
			
		||||
				form = POINT_CONVERSION_COMPRESSED;
 | 
			
		||||
			else if (strcmp(*argv, "uncompressed") == 0)
 | 
			
		||||
				form = POINT_CONVERSION_UNCOMPRESSED;
 | 
			
		||||
			else if (strcmp(*argv, "hybrid") == 0)
 | 
			
		||||
				form = POINT_CONVERSION_HYBRID;
 | 
			
		||||
			else
 | 
			
		||||
				goto bad;
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv, "-param_enc") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1)
 | 
			
		||||
				goto bad;
 | 
			
		||||
			++argv;
 | 
			
		||||
			new_asn1_flag = 1;
 | 
			
		||||
			if (strcmp(*argv, "named_curve") == 0)
 | 
			
		||||
				asn1_flag = OPENSSL_EC_NAMED_CURVE;
 | 
			
		||||
			else if (strcmp(*argv, "explicit") == 0)
 | 
			
		||||
				asn1_flag = 0;
 | 
			
		||||
			else
 | 
			
		||||
				goto bad;
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv, "-no_seed") == 0)
 | 
			
		||||
			no_seed = 1;
 | 
			
		||||
		else if (strcmp(*argv, "-noout") == 0)
 | 
			
		||||
			noout=1;
 | 
			
		||||
		else if (strcmp(*argv,"-genkey") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			genkey=1;
 | 
			
		||||
			need_rand=1;
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv, "-rand") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			inrand= *(++argv);
 | 
			
		||||
			need_rand=1;
 | 
			
		||||
			}
 | 
			
		||||
		else if(strcmp(*argv, "-engine") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			engine = *(++argv);
 | 
			
		||||
			}	
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,"unknown option %s\n",*argv);
 | 
			
		||||
			badops=1;
 | 
			
		||||
			break;
 | 
			
		||||
			}
 | 
			
		||||
		argc--;
 | 
			
		||||
		argv++;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (badops)
 | 
			
		||||
		{
 | 
			
		||||
bad:
 | 
			
		||||
		BIO_printf(bio_err, "%s [options] <infile >outfile\n",prog);
 | 
			
		||||
		BIO_printf(bio_err, "where options are\n");
 | 
			
		||||
		BIO_printf(bio_err, " -inform arg       input format - "
 | 
			
		||||
				"default PEM (DER or PEM)\n");
 | 
			
		||||
		BIO_printf(bio_err, " -outform arg      output format - "
 | 
			
		||||
				"default PEM\n");
 | 
			
		||||
		BIO_printf(bio_err, " -in  arg          input file  - "
 | 
			
		||||
				"default stdin\n");
 | 
			
		||||
		BIO_printf(bio_err, " -out arg          output file - "
 | 
			
		||||
				"default stdout\n");
 | 
			
		||||
		BIO_printf(bio_err, " -noout            do not print the "
 | 
			
		||||
				"ec parameter\n");
 | 
			
		||||
		BIO_printf(bio_err, " -text             print the ec "
 | 
			
		||||
				"parameters in text form\n");
 | 
			
		||||
		BIO_printf(bio_err, " -check            validate the ec "
 | 
			
		||||
				"parameters\n");
 | 
			
		||||
		BIO_printf(bio_err, " -C                print a 'C' "
 | 
			
		||||
				"function creating the parameters\n");
 | 
			
		||||
		BIO_printf(bio_err, " -name arg         use the "
 | 
			
		||||
				"ec parameters with 'short name' name\n");
 | 
			
		||||
		BIO_printf(bio_err, " -list_curves      prints a list of "
 | 
			
		||||
				"all currently available curve 'short names'\n");
 | 
			
		||||
		BIO_printf(bio_err, " -conv_form arg    specifies the "
 | 
			
		||||
				"point conversion form \n");
 | 
			
		||||
		BIO_printf(bio_err, "                   possible values:"
 | 
			
		||||
				" compressed\n");
 | 
			
		||||
		BIO_printf(bio_err, "                                   "
 | 
			
		||||
				" uncompressed (default)\n");
 | 
			
		||||
		BIO_printf(bio_err, "                                   "
 | 
			
		||||
				" hybrid\n");
 | 
			
		||||
		BIO_printf(bio_err, " -param_enc arg    specifies the way"
 | 
			
		||||
				" the ec parameters are encoded\n");
 | 
			
		||||
		BIO_printf(bio_err, "                   in the asn1 der "
 | 
			
		||||
				"encoding\n");
 | 
			
		||||
		BIO_printf(bio_err, "                   possible values:"
 | 
			
		||||
				" named_curve (default)\n");
 | 
			
		||||
		BIO_printf(bio_err, "                                   "
 | 
			
		||||
				" explicit\n");
 | 
			
		||||
		BIO_printf(bio_err, " -no_seed          if 'explicit'"
 | 
			
		||||
				" parameters are choosen do not"
 | 
			
		||||
				" use the seed\n");
 | 
			
		||||
		BIO_printf(bio_err, " -genkey           generate ec"
 | 
			
		||||
				" key\n");
 | 
			
		||||
		BIO_printf(bio_err, " -rand file        files to use for"
 | 
			
		||||
				" random number input\n");
 | 
			
		||||
		BIO_printf(bio_err, " -engine e         use engine e, "
 | 
			
		||||
				"possibly a hardware device\n");
 | 
			
		||||
		goto end;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	ERR_load_crypto_strings();
 | 
			
		||||
 | 
			
		||||
	in=BIO_new(BIO_s_file());
 | 
			
		||||
	out=BIO_new(BIO_s_file());
 | 
			
		||||
	if ((in == NULL) || (out == NULL))
 | 
			
		||||
		{
 | 
			
		||||
		ERR_print_errors(bio_err);
 | 
			
		||||
		goto end;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (infile == NULL)
 | 
			
		||||
		BIO_set_fp(in,stdin,BIO_NOCLOSE);
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
		if (BIO_read_filename(in,infile) <= 0)
 | 
			
		||||
			{
 | 
			
		||||
			perror(infile);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	if (outfile == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
			
		||||
#ifdef OPENSSL_SYS_VMS
 | 
			
		||||
		{
 | 
			
		||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
			
		||||
		out = BIO_push(tmpbio, out);
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
		if (BIO_write_filename(out,outfile) <= 0)
 | 
			
		||||
			{
 | 
			
		||||
			perror(outfile);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	e = setup_engine(bio_err, engine, 0);
 | 
			
		||||
 | 
			
		||||
	if (list_curves)
 | 
			
		||||
		{
 | 
			
		||||
		EC_builtin_curve *curves = NULL;
 | 
			
		||||
		size_t crv_len = 0;
 | 
			
		||||
		size_t n = 0;
 | 
			
		||||
		size_t len;
 | 
			
		||||
 | 
			
		||||
		crv_len = EC_get_builtin_curves(NULL, 0);
 | 
			
		||||
 | 
			
		||||
		curves = OPENSSL_malloc(sizeof(EC_builtin_curve) * crv_len);
 | 
			
		||||
 | 
			
		||||
		if (curves == NULL)
 | 
			
		||||
			goto end;
 | 
			
		||||
 | 
			
		||||
		if (!EC_get_builtin_curves(curves, crv_len))
 | 
			
		||||
			{
 | 
			
		||||
			OPENSSL_free(curves);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		
 | 
			
		||||
		for (n = 0; n < crv_len; n++)
 | 
			
		||||
			{
 | 
			
		||||
			const char *comment;
 | 
			
		||||
			const char *sname;
 | 
			
		||||
			comment = curves[n].comment;
 | 
			
		||||
			sname   = OBJ_nid2sn(curves[n].nid);
 | 
			
		||||
			if (comment == NULL)
 | 
			
		||||
				comment = "CURVE DESCRIPTION NOT AVAILABLE";
 | 
			
		||||
			if (sname == NULL)
 | 
			
		||||
				sname = "";
 | 
			
		||||
 | 
			
		||||
			len = BIO_printf(out, "  %-10s: ", sname);
 | 
			
		||||
			if (len + strlen(comment) > 80)
 | 
			
		||||
				BIO_printf(out, "\n%80s\n", comment);
 | 
			
		||||
			else
 | 
			
		||||
				BIO_printf(out, "%s\n", comment);
 | 
			
		||||
			} 
 | 
			
		||||
 | 
			
		||||
		OPENSSL_free(curves);
 | 
			
		||||
		ret = 0;
 | 
			
		||||
		goto end;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (curve_name != NULL)
 | 
			
		||||
		{
 | 
			
		||||
		int nid;
 | 
			
		||||
 | 
			
		||||
		/* workaround for the SECG curve names secp192r1
 | 
			
		||||
		 * and secp256r1 (which are the same as the curves
 | 
			
		||||
		 * prime192v1 and prime256v1 defined in X9.62)
 | 
			
		||||
		 */
 | 
			
		||||
		if (!strcmp(curve_name, "secp192r1"))
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err, "using curve name prime192v1 "
 | 
			
		||||
				"instead of secp192r1\n");
 | 
			
		||||
			nid = NID_X9_62_prime192v1;
 | 
			
		||||
			}
 | 
			
		||||
		else if (!strcmp(curve_name, "secp256r1"))
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err, "using curve name prime256v1 "
 | 
			
		||||
				"instead of secp256r1\n");
 | 
			
		||||
			nid = NID_X9_62_prime256v1;
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
			nid = OBJ_sn2nid(curve_name);
 | 
			
		||||
	
 | 
			
		||||
		if (nid == 0)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err, "unknown curve name (%s)\n", 
 | 
			
		||||
				curve_name);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		group = EC_GROUP_new_by_nid(nid);
 | 
			
		||||
		if (group == NULL)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err, "unable to create curve (%s)\n", 
 | 
			
		||||
				curve_name);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		EC_GROUP_set_asn1_flag(group, asn1_flag);
 | 
			
		||||
		EC_GROUP_set_point_conversion_form(group, form);
 | 
			
		||||
		}
 | 
			
		||||
	else if (informat == FORMAT_ASN1)
 | 
			
		||||
		{
 | 
			
		||||
		group = d2i_ECPKParameters_bio(in, NULL);
 | 
			
		||||
		}
 | 
			
		||||
	else if (informat == FORMAT_PEM)
 | 
			
		||||
		{
 | 
			
		||||
		group = PEM_read_bio_ECPKParameters(in,NULL,NULL,NULL);
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err, "bad input format specified\n");
 | 
			
		||||
		goto end;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (group == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err, 
 | 
			
		||||
			"unable to load elliptic curve parameters\n");
 | 
			
		||||
		ERR_print_errors(bio_err);
 | 
			
		||||
		goto end;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (new_form)
 | 
			
		||||
		EC_GROUP_set_point_conversion_form(group, form);
 | 
			
		||||
 | 
			
		||||
	if (new_asn1_flag)
 | 
			
		||||
		EC_GROUP_set_asn1_flag(group, asn1_flag);
 | 
			
		||||
 | 
			
		||||
	if (no_seed)
 | 
			
		||||
		{
 | 
			
		||||
		EC_GROUP_set_seed(group, NULL, 0);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (text)
 | 
			
		||||
		{
 | 
			
		||||
		if (!ECPKParameters_print(out, group, 0))
 | 
			
		||||
			goto end;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (check)
 | 
			
		||||
		{
 | 
			
		||||
		if (group == NULL)
 | 
			
		||||
			BIO_printf(bio_err, "no elliptic curve parameters\n");
 | 
			
		||||
		BIO_printf(bio_err, "checking elliptic curve parameters: ");
 | 
			
		||||
		if (!EC_GROUP_check(group, NULL))
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err, "failed\n");
 | 
			
		||||
			ERR_print_errors(bio_err);
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
			BIO_printf(bio_err, "ok\n");
 | 
			
		||||
			
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (C)
 | 
			
		||||
		{
 | 
			
		||||
		size_t	buf_len = 0, tmp_len = 0;
 | 
			
		||||
		const EC_POINT *point;
 | 
			
		||||
		int	is_prime, len = 0;
 | 
			
		||||
		const EC_METHOD *meth = EC_GROUP_method_of(group);
 | 
			
		||||
 | 
			
		||||
		if ((ec_p = BN_new()) == NULL || (ec_a = BN_new()) == NULL ||
 | 
			
		||||
		    (ec_b = BN_new()) == NULL || (ec_gen = BN_new()) == NULL ||
 | 
			
		||||
		    (ec_order = BN_new()) == NULL || 
 | 
			
		||||
		    (ec_cofactor = BN_new()) == NULL )
 | 
			
		||||
			{
 | 
			
		||||
			perror("OPENSSL_malloc");
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		is_prime = (EC_METHOD_get_field_type(meth) == 
 | 
			
		||||
			NID_X9_62_prime_field);
 | 
			
		||||
 | 
			
		||||
		if (is_prime)
 | 
			
		||||
			{
 | 
			
		||||
			if (!EC_GROUP_get_curve_GFp(group, ec_p, ec_a,
 | 
			
		||||
				ec_b, NULL))
 | 
			
		||||
				goto end;
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			/* TODO */
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		if ((point = EC_GROUP_get0_generator(group)) == NULL)
 | 
			
		||||
			goto end;
 | 
			
		||||
		if (!EC_POINT_point2bn(group, point, 
 | 
			
		||||
			EC_GROUP_get_point_conversion_form(group), ec_gen, 
 | 
			
		||||
			NULL))
 | 
			
		||||
			goto end;
 | 
			
		||||
		if (!EC_GROUP_get_order(group, ec_order, NULL))
 | 
			
		||||
			goto end;
 | 
			
		||||
		if (!EC_GROUP_get_cofactor(group, ec_cofactor, NULL))
 | 
			
		||||
			goto end;
 | 
			
		||||
 | 
			
		||||
		if (!ec_p || !ec_a || !ec_b || !ec_gen || 
 | 
			
		||||
			!ec_order || !ec_cofactor)
 | 
			
		||||
			goto end;
 | 
			
		||||
 | 
			
		||||
		len = BN_num_bits(ec_order);
 | 
			
		||||
 | 
			
		||||
		if ((tmp_len = (size_t)BN_num_bytes(ec_p)) > buf_len)
 | 
			
		||||
			buf_len = tmp_len;
 | 
			
		||||
		if ((tmp_len = (size_t)BN_num_bytes(ec_a)) > buf_len)
 | 
			
		||||
			buf_len = tmp_len;
 | 
			
		||||
		if ((tmp_len = (size_t)BN_num_bytes(ec_b)) > buf_len)
 | 
			
		||||
			buf_len = tmp_len;
 | 
			
		||||
		if ((tmp_len = (size_t)BN_num_bytes(ec_gen)) > buf_len)
 | 
			
		||||
			buf_len = tmp_len;
 | 
			
		||||
		if ((tmp_len = (size_t)BN_num_bytes(ec_order)) > buf_len)
 | 
			
		||||
			buf_len = tmp_len;
 | 
			
		||||
		if ((tmp_len = (size_t)BN_num_bytes(ec_cofactor)) > buf_len)
 | 
			
		||||
			buf_len = tmp_len;
 | 
			
		||||
 | 
			
		||||
		buffer = (unsigned char *)OPENSSL_malloc(buf_len);
 | 
			
		||||
 | 
			
		||||
		if (buffer == NULL)
 | 
			
		||||
			{
 | 
			
		||||
			perror("OPENSSL_malloc");
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		ecparam_print_var(out, ec_p, "ec_p", len, buffer);
 | 
			
		||||
		ecparam_print_var(out, ec_a, "ec_a", len, buffer);
 | 
			
		||||
		ecparam_print_var(out, ec_b, "ec_b", len, buffer);
 | 
			
		||||
		ecparam_print_var(out, ec_gen, "ec_gen", len, buffer);
 | 
			
		||||
		ecparam_print_var(out, ec_order, "ec_order", len, buffer);
 | 
			
		||||
		ecparam_print_var(out, ec_cofactor, "ec_cofactor", len, 
 | 
			
		||||
			buffer);
 | 
			
		||||
 | 
			
		||||
		BIO_printf(out, "\n\n");
 | 
			
		||||
 | 
			
		||||
		BIO_printf(out, "EC_GROUP *get_ec_group_%d(void)\n\t{\n", len);
 | 
			
		||||
		BIO_printf(out, "\tint ok=0;\n");
 | 
			
		||||
		BIO_printf(out, "\tEC_GROUP *group = NULL;\n");
 | 
			
		||||
		BIO_printf(out, "\tEC_POINT *point = NULL;\n");
 | 
			
		||||
		BIO_printf(out, "\tBIGNUM   *tmp_1 = NULL, *tmp_2 = NULL, "
 | 
			
		||||
				"*tmp_3 = NULL;\n\n");
 | 
			
		||||
		BIO_printf(out, "\tif ((tmp_1 = BN_bin2bn(ec_p_%d, "
 | 
			
		||||
				"sizeof(ec_p_%d), NULL)) == NULL)\n\t\t"
 | 
			
		||||
				"goto err;\n", len, len);
 | 
			
		||||
		BIO_printf(out, "\tif ((tmp_2 = BN_bin2bn(ec_a_%d, "
 | 
			
		||||
				"sizeof(ec_a_%d), NULL)) == NULL)\n\t\t"
 | 
			
		||||
				"goto err;\n", len, len);
 | 
			
		||||
		BIO_printf(out, "\tif ((tmp_3 = BN_bin2bn(ec_b_%d, "
 | 
			
		||||
				"sizeof(ec_b_%d), NULL)) == NULL)\n\t\t"
 | 
			
		||||
				"goto err;\n", len, len);
 | 
			
		||||
		if (is_prime)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(out, "\tif ((group = EC_GROUP_new_curve_"
 | 
			
		||||
				"GFp(tmp_1, tmp_2, tmp_3, NULL)) == NULL)"
 | 
			
		||||
				"\n\t\tgoto err;\n\n");
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			/* TODO */
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		BIO_printf(out, "\t/* build generator */\n");
 | 
			
		||||
		BIO_printf(out, "\tif ((tmp_1 = BN_bin2bn(ec_gen_%d, "
 | 
			
		||||
				"sizeof(ec_gen_%d), tmp_1)) == NULL)"
 | 
			
		||||
				"\n\t\tgoto err;\n", len, len);
 | 
			
		||||
		BIO_printf(out, "\tpoint = EC_POINT_bn2point(group, tmp_1, "
 | 
			
		||||
				"NULL, NULL);\n");
 | 
			
		||||
		BIO_printf(out, "\tif (point == NULL)\n\t\tgoto err;\n");
 | 
			
		||||
		BIO_printf(out, "\tif ((tmp_2 = BN_bin2bn(ec_order_%d, "
 | 
			
		||||
				"sizeof(ec_order_%d), tmp_2)) == NULL)"
 | 
			
		||||
				"\n\t\tgoto err;\n", len, len);
 | 
			
		||||
		BIO_printf(out, "\tif ((tmp_3 = BN_bin2bn(ec_cofactor_%d, "
 | 
			
		||||
				"sizeof(ec_cofactor_%d), tmp_3)) == NULL)"
 | 
			
		||||
				"\n\t\tgoto err;\n", len, len);
 | 
			
		||||
		BIO_printf(out, "\tif (!EC_GROUP_set_generator(group, point,"
 | 
			
		||||
				" tmp_2, tmp_3))\n\t\tgoto err;\n");
 | 
			
		||||
		BIO_printf(out, "\n\tok=1;\n");
 | 
			
		||||
		BIO_printf(out, "err:\n");
 | 
			
		||||
		BIO_printf(out, "\tif (tmp_1)\n\t\tBN_free(tmp_1);\n");
 | 
			
		||||
		BIO_printf(out, "\tif (tmp_2)\n\t\tBN_free(tmp_2);\n");
 | 
			
		||||
		BIO_printf(out, "\tif (tmp_3)\n\t\tBN_free(tmp_3);\n");
 | 
			
		||||
		BIO_printf(out, "\tif (point)\n\t\tEC_POINT_free(point);\n");
 | 
			
		||||
		BIO_printf(out, "\tif (!ok)\n");
 | 
			
		||||
		BIO_printf(out, "\t\t{\n");
 | 
			
		||||
		BIO_printf(out, "\t\tEC_GROUP_free(group);\n");
 | 
			
		||||
		BIO_printf(out, "\t\tgroup = NULL;\n");
 | 
			
		||||
		BIO_printf(out, "\t\t}\n");
 | 
			
		||||
		BIO_printf(out, "\treturn(group);\n\t}\n");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (!noout)
 | 
			
		||||
		{
 | 
			
		||||
		if (outformat == FORMAT_ASN1)
 | 
			
		||||
			i = i2d_ECPKParameters_bio(out, group);
 | 
			
		||||
		else if (outformat == FORMAT_PEM)
 | 
			
		||||
			i = PEM_write_bio_ECPKParameters(out, group);
 | 
			
		||||
		else	
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,"bad output format specified for"
 | 
			
		||||
				" outfile\n");
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		if (!i)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err, "unable to write elliptic "
 | 
			
		||||
				"curve parameters\n");
 | 
			
		||||
			ERR_print_errors(bio_err);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	
 | 
			
		||||
	if (need_rand)
 | 
			
		||||
		{
 | 
			
		||||
		app_RAND_load_file(NULL, bio_err, (inrand != NULL));
 | 
			
		||||
		if (inrand != NULL)
 | 
			
		||||
			BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
 | 
			
		||||
				app_RAND_load_files(inrand));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (genkey)
 | 
			
		||||
		{
 | 
			
		||||
		EC_KEY *eckey = EC_KEY_new();
 | 
			
		||||
 | 
			
		||||
		if (eckey == NULL)
 | 
			
		||||
			goto end;
 | 
			
		||||
 | 
			
		||||
		assert(need_rand);
 | 
			
		||||
 | 
			
		||||
		eckey->group = group;
 | 
			
		||||
		
 | 
			
		||||
		if (!EC_KEY_generate_key(eckey))
 | 
			
		||||
			{
 | 
			
		||||
			eckey->group = NULL;
 | 
			
		||||
			EC_KEY_free(eckey);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		if (outformat == FORMAT_ASN1)
 | 
			
		||||
			i = i2d_ECPrivateKey_bio(out, eckey);
 | 
			
		||||
		else if (outformat == FORMAT_PEM)
 | 
			
		||||
			i = PEM_write_bio_ECPrivateKey(out, eckey, NULL,
 | 
			
		||||
				NULL, 0, NULL, NULL);
 | 
			
		||||
		else	
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err, "bad output format specified "
 | 
			
		||||
				"for outfile\n");
 | 
			
		||||
			eckey->group = NULL;
 | 
			
		||||
			EC_KEY_free(eckey);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		eckey->group = NULL;
 | 
			
		||||
		EC_KEY_free(eckey);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (need_rand)
 | 
			
		||||
		app_RAND_write_file(NULL, bio_err);
 | 
			
		||||
 | 
			
		||||
	ret=0;
 | 
			
		||||
end:
 | 
			
		||||
	if (ec_p)
 | 
			
		||||
		BN_free(ec_p);
 | 
			
		||||
	if (ec_a)
 | 
			
		||||
		BN_free(ec_a);
 | 
			
		||||
	if (ec_b)
 | 
			
		||||
		BN_free(ec_b);
 | 
			
		||||
	if (ec_gen)
 | 
			
		||||
		BN_free(ec_gen);
 | 
			
		||||
	if (ec_order)
 | 
			
		||||
		BN_free(ec_order);
 | 
			
		||||
	if (ec_cofactor)
 | 
			
		||||
		BN_free(ec_cofactor);
 | 
			
		||||
	if (buffer)
 | 
			
		||||
		OPENSSL_free(buffer);
 | 
			
		||||
	if (in != NULL)
 | 
			
		||||
		BIO_free(in);
 | 
			
		||||
	if (out != NULL)
 | 
			
		||||
		BIO_free_all(out);
 | 
			
		||||
	if (group != NULL)
 | 
			
		||||
		EC_GROUP_free(group);
 | 
			
		||||
	apps_shutdown();
 | 
			
		||||
	OPENSSL_EXIT(ret);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ecparam_print_var(BIO *out, BIGNUM *in, const char *var,
 | 
			
		||||
	int len, unsigned char *buffer)
 | 
			
		||||
	{
 | 
			
		||||
	BIO_printf(out, "static unsigned char %s_%d[] = {", var, len);
 | 
			
		||||
	if (BN_is_zero(in))
 | 
			
		||||
		BIO_printf(out, "\n\t0x00");
 | 
			
		||||
	else 
 | 
			
		||||
		{
 | 
			
		||||
		int i, l;
 | 
			
		||||
 | 
			
		||||
		l = BN_bn2bin(in, buffer);
 | 
			
		||||
		for (i=0; i<l-1; i++)
 | 
			
		||||
			{
 | 
			
		||||
			if ((i%12) == 0) 
 | 
			
		||||
				BIO_printf(out, "\n\t");
 | 
			
		||||
			BIO_printf(out, "0x%02X,", buffer[i]);
 | 
			
		||||
			}
 | 
			
		||||
		if ((i%12) == 0) 
 | 
			
		||||
			BIO_printf(out, "\n\t");
 | 
			
		||||
		BIO_printf(out, "0x%02X", buffer[i]);
 | 
			
		||||
		}
 | 
			
		||||
	BIO_printf(out, "\n\t};\n\n");
 | 
			
		||||
	return 1;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
@@ -79,8 +79,7 @@ static char *engine_usage[]={
 | 
			
		||||
"               -vvv will also add the input flags for each command\n",
 | 
			
		||||
"               -vvvv will also show internal input flags\n",
 | 
			
		||||
" -c          - for each engine, also list the capabilities\n",
 | 
			
		||||
" -t[t]       - for each engine, check that they are really available\n",
 | 
			
		||||
"               -tt will display error trace for unavailable engines\n",
 | 
			
		||||
" -t          - for each engine, check that they are really available\n",
 | 
			
		||||
" -pre <cmd>  - runs command 'cmd' against the ENGINE before any attempts\n",
 | 
			
		||||
"               to load it (if -t is used)\n",
 | 
			
		||||
" -post <cmd> - runs command 'cmd' against the ENGINE after loading it\n",
 | 
			
		||||
@@ -345,7 +344,7 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
	{
 | 
			
		||||
	int ret=1,i;
 | 
			
		||||
	char **pp;
 | 
			
		||||
	int verbose=0, list_cap=0, test_avail=0, test_avail_noise = 0;
 | 
			
		||||
	int verbose=0, list_cap=0, test_avail=0;
 | 
			
		||||
	ENGINE *e;
 | 
			
		||||
	STACK *engines = sk_new_null();
 | 
			
		||||
	STACK *pre_cmds = sk_new_null();
 | 
			
		||||
@@ -383,14 +382,8 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv,"-c") == 0)
 | 
			
		||||
			list_cap=1;
 | 
			
		||||
		else if (strncmp(*argv,"-t",2) == 0)
 | 
			
		||||
			{
 | 
			
		||||
		else if (strcmp(*argv,"-t") == 0)
 | 
			
		||||
			test_avail=1;
 | 
			
		||||
			if(strspn(*argv + 1, "t") < strlen(*argv + 1))
 | 
			
		||||
				goto skip_arg_loop;
 | 
			
		||||
			if((test_avail_noise = strlen(*argv + 1) - 1) > 1)
 | 
			
		||||
				goto skip_arg_loop;
 | 
			
		||||
			}
 | 
			
		||||
		else if (strcmp(*argv,"-pre") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			argc--; argv++;
 | 
			
		||||
@@ -505,7 +498,6 @@ skip_digests:
 | 
			
		||||
				else
 | 
			
		||||
					{
 | 
			
		||||
					BIO_printf(bio_out, "[ unavailable ]\n");
 | 
			
		||||
					if(test_avail_noise)
 | 
			
		||||
					ERR_print_errors_fp(stdout);
 | 
			
		||||
					ERR_clear_error();
 | 
			
		||||
					}
 | 
			
		||||
@@ -520,7 +512,6 @@ skip_digests:
 | 
			
		||||
 | 
			
		||||
	ret=0;
 | 
			
		||||
end:
 | 
			
		||||
 | 
			
		||||
	ERR_print_errors(bio_err);
 | 
			
		||||
	sk_pop_free(engines, identity);
 | 
			
		||||
	sk_pop_free(pre_cmds, identity);
 | 
			
		||||
 
 | 
			
		||||
@@ -57,12 +57,6 @@
 | 
			
		||||
 * [including the GNU Public Licence.]
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* Until the key-gen callbacks are modified to use newer prototypes, we allow
 | 
			
		||||
 * deprecated functions for openssl-internal code */
 | 
			
		||||
#ifdef OPENSSL_NO_DEPRECATED
 | 
			
		||||
#undef OPENSSL_NO_DEPRECATED
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_DH
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 
 | 
			
		||||
@@ -56,12 +56,6 @@
 | 
			
		||||
 * [including the GNU Public Licence.]
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* Until the key-gen callbacks are modified to use newer prototypes, we allow
 | 
			
		||||
 * deprecated functions for openssl-internal code */
 | 
			
		||||
#ifdef OPENSSL_NO_DEPRECATED
 | 
			
		||||
#undef OPENSSL_NO_DEPRECATED
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_RSA
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 
 | 
			
		||||
@@ -139,13 +139,13 @@ $! Define The Application Files.
 | 
			
		||||
$!
 | 
			
		||||
$ LIB_FILES = "VERIFY;ASN1PARS;REQ;DGST;DH;DHPARAM;ENC;PASSWD;GENDH;ERRSTR;"+-
 | 
			
		||||
	      "CA;PKCS7;CRL2P7;CRL;"+-
 | 
			
		||||
	      "RSA;RSAUTL;DSA;DSAPARAM;EC;ECPARAM;"+-
 | 
			
		||||
	      "RSA;RSAUTL;DSA;DSAPARAM;"+-
 | 
			
		||||
	      "X509;GENRSA;GENDSA;S_SERVER;S_CLIENT;SPEED;"+-
 | 
			
		||||
	      "S_TIME;APPS;S_CB;S_SOCKET;APP_RAND;VERSION;SESS_ID;"+-
 | 
			
		||||
	      "CIPHERS;NSEQ;PKCS12;PKCS8;SPKAC;SMIME;RAND;ENGINE;OCSP"
 | 
			
		||||
$ APP_FILES := OPENSSL,'OBJ_DIR'VERIFY.OBJ,ASN1PARS.OBJ,REQ.OBJ,DGST.OBJ,DH.OBJ,DHPARAM.OBJ,ENC.OBJ,PASSWD.OBJ,GENDH.OBJ,ERRSTR.OBJ,-
 | 
			
		||||
	       CA.OBJ,PKCS7.OBJ,CRL2P7.OBJ,CRL.OBJ,-
 | 
			
		||||
	       RSA.OBJ,RSAUTL.OBJ,DSA.OBJ,DSAPARAM.OBJ,EC.OBJ,ECPARAM.OBJ,-
 | 
			
		||||
	       RSA.OBJ,RSAUTL.OBJ,DSA.OBJ,DSAPARAM.OBJ,-
 | 
			
		||||
	       X509.OBJ,GENRSA.OBJ,GENDSA.OBJ,S_SERVER.OBJ,S_CLIENT.OBJ,SPEED.OBJ,-
 | 
			
		||||
	       S_TIME.OBJ,APPS.OBJ,S_CB.OBJ,S_SOCKET.OBJ,APP_RAND.OBJ,VERSION.OBJ,SESS_ID.OBJ,-
 | 
			
		||||
	       CIPHERS.OBJ,NSEQ.OBJ,PKCS12.OBJ,PKCS8.OBJ,SPKAC.OBJ,SMIME.OBJ,RAND.OBJ,ENGINE.OBJ,OCSP.OBJ
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										50
									
								
								apps/ocsp.c
									
									
									
									
									
								
							
							
						
						
									
										50
									
								
								apps/ocsp.c
									
									
									
									
									
								
							@@ -68,6 +68,19 @@
 | 
			
		||||
/* Maximum leeway in validity period: default 5 minutes */
 | 
			
		||||
#define MAX_VALIDITY_PERIOD	(5 * 60)
 | 
			
		||||
 | 
			
		||||
/* CA index.txt definitions */
 | 
			
		||||
#define DB_type         0
 | 
			
		||||
#define DB_exp_date     1
 | 
			
		||||
#define DB_rev_date     2
 | 
			
		||||
#define DB_serial       3       /* index - unique */
 | 
			
		||||
#define DB_file         4       
 | 
			
		||||
#define DB_name         5       /* index - unique for active */
 | 
			
		||||
#define DB_NUMBER       6
 | 
			
		||||
 | 
			
		||||
#define DB_TYPE_REV	'R'
 | 
			
		||||
#define DB_TYPE_EXP	'E'
 | 
			
		||||
#define DB_TYPE_VAL	'V'
 | 
			
		||||
 | 
			
		||||
static int add_ocsp_cert(OCSP_REQUEST **req, X509 *cert, X509 *issuer,
 | 
			
		||||
				STACK_OF(OCSP_CERTID) *ids);
 | 
			
		||||
static int add_ocsp_serial(OCSP_REQUEST **req, char *serial, X509 *issuer,
 | 
			
		||||
@@ -76,12 +89,12 @@ static int print_ocsp_summary(BIO *out, OCSP_BASICRESP *bs, OCSP_REQUEST *req,
 | 
			
		||||
				STACK *names, STACK_OF(OCSP_CERTID) *ids,
 | 
			
		||||
				long nsec, long maxage);
 | 
			
		||||
 | 
			
		||||
static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, CA_DB *db,
 | 
			
		||||
static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, TXT_DB *db,
 | 
			
		||||
			X509 *ca, X509 *rcert, EVP_PKEY *rkey,
 | 
			
		||||
			STACK_OF(X509) *rother, unsigned long flags,
 | 
			
		||||
			int nmin, int ndays);
 | 
			
		||||
 | 
			
		||||
static char **lookup_serial(CA_DB *db, ASN1_INTEGER *ser);
 | 
			
		||||
static char **lookup_serial(TXT_DB *db, ASN1_INTEGER *ser);
 | 
			
		||||
static BIO *init_responder(char *port);
 | 
			
		||||
static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, char *port);
 | 
			
		||||
static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp);
 | 
			
		||||
@@ -130,7 +143,7 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
	X509 *rca_cert = NULL;
 | 
			
		||||
	char *ridx_filename = NULL;
 | 
			
		||||
	char *rca_filename = NULL;
 | 
			
		||||
	CA_DB *rdb = NULL;
 | 
			
		||||
	TXT_DB *rdb = NULL;
 | 
			
		||||
	int nmin = 0, ndays = -1;
 | 
			
		||||
 | 
			
		||||
	if (bio_err == NULL) bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
 | 
			
		||||
@@ -687,9 +700,22 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
 | 
			
		||||
	if (ridx_filename && !rdb)
 | 
			
		||||
		{
 | 
			
		||||
		rdb = load_index(ridx_filename, NULL);
 | 
			
		||||
		if (!rdb) goto end;
 | 
			
		||||
		if (!index_index(rdb)) goto end;
 | 
			
		||||
		BIO *db_bio = NULL;
 | 
			
		||||
		db_bio = BIO_new_file(ridx_filename, "r");
 | 
			
		||||
		if (!db_bio)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err, "Error opening index file %s\n", ridx_filename);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		rdb = TXT_DB_read(db_bio, DB_NUMBER);
 | 
			
		||||
		BIO_free(db_bio);
 | 
			
		||||
		if (!rdb)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err, "Error reading index file %s\n", ridx_filename);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		if (!make_serial_index(rdb))
 | 
			
		||||
			goto end;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (rdb)
 | 
			
		||||
@@ -784,7 +810,7 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
 | 
			
		||||
	if (i != OCSP_RESPONSE_STATUS_SUCCESSFUL)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(out, "Responder Error: %s (%d)\n",
 | 
			
		||||
		BIO_printf(out, "Responder Error: %s (%ld)\n",
 | 
			
		||||
				OCSP_response_status_str(i), i);
 | 
			
		||||
		if (ignore_err)
 | 
			
		||||
			goto redo_accept;
 | 
			
		||||
@@ -850,7 +876,7 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
 | 
			
		||||
		if(i <= 0)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err, "Response Verify Failure\n");
 | 
			
		||||
			BIO_printf(bio_err, "Response Verify Failure\n", i);
 | 
			
		||||
			ERR_print_errors(bio_err);
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
@@ -873,7 +899,7 @@ end:
 | 
			
		||||
	X509_free(cert);
 | 
			
		||||
	X509_free(rsigner);
 | 
			
		||||
	X509_free(rca_cert);
 | 
			
		||||
	free_index(rdb);
 | 
			
		||||
	TXT_DB_free(rdb);
 | 
			
		||||
	BIO_free_all(cbio);
 | 
			
		||||
	BIO_free_all(acbio);
 | 
			
		||||
	BIO_free(out);
 | 
			
		||||
@@ -1015,7 +1041,7 @@ static int print_ocsp_summary(BIO *out, OCSP_BASICRESP *bs, OCSP_REQUEST *req,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, CA_DB *db,
 | 
			
		||||
static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, TXT_DB *db,
 | 
			
		||||
			X509 *ca, X509 *rcert, EVP_PKEY *rkey,
 | 
			
		||||
			STACK_OF(X509) *rother, unsigned long flags,
 | 
			
		||||
			int nmin, int ndays)
 | 
			
		||||
@@ -1107,7 +1133,7 @@ static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, CA_DB *db
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static char **lookup_serial(CA_DB *db, ASN1_INTEGER *ser)
 | 
			
		||||
static char **lookup_serial(TXT_DB *db, ASN1_INTEGER *ser)
 | 
			
		||||
	{
 | 
			
		||||
	int i;
 | 
			
		||||
	BIGNUM *bn = NULL;
 | 
			
		||||
@@ -1120,7 +1146,7 @@ static char **lookup_serial(CA_DB *db, ASN1_INTEGER *ser)
 | 
			
		||||
		itmp = BN_bn2hex(bn);
 | 
			
		||||
	row[DB_serial] = itmp;
 | 
			
		||||
	BN_free(bn);
 | 
			
		||||
	rrow=TXT_DB_get_by_index(db->db,DB_serial,row);
 | 
			
		||||
	rrow=TXT_DB_get_by_index(db,DB_serial,row);
 | 
			
		||||
	OPENSSL_free(itmp);
 | 
			
		||||
	return rrow;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -38,14 +38,10 @@ dir		= ./demoCA		# Where everything is kept
 | 
			
		||||
certs		= $dir/certs		# Where the issued certs are kept
 | 
			
		||||
crl_dir		= $dir/crl		# Where the issued crl are kept
 | 
			
		||||
database	= $dir/index.txt	# database index file.
 | 
			
		||||
#unique_subject	= no			# Set to 'no' to allow creation of
 | 
			
		||||
					# several ctificates with same subject.
 | 
			
		||||
new_certs_dir	= $dir/newcerts		# default place for new certs.
 | 
			
		||||
 | 
			
		||||
certificate	= $dir/cacert.pem 	# The CA certificate
 | 
			
		||||
serial		= $dir/serial 		# The current serial number
 | 
			
		||||
crlnumber	= $dir/crlnumber	# the current crl number
 | 
			
		||||
					# must be commented out to leave a V1 CRL
 | 
			
		||||
crl		= $dir/crl.pem 		# The current CRL
 | 
			
		||||
private_key	= $dir/private/cakey.pem# The private key
 | 
			
		||||
RANDFILE	= $dir/private/.rand	# private random number file
 | 
			
		||||
@@ -62,7 +58,6 @@ cert_opt 	= ca_default		# Certificate field options
 | 
			
		||||
 | 
			
		||||
# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
 | 
			
		||||
# so this is commented out by default to leave a V1 CRL.
 | 
			
		||||
# crlnumber must also be commented out to leave a V1 CRL.
 | 
			
		||||
# crl_extensions	= crl_ext
 | 
			
		||||
 | 
			
		||||
default_days	= 365			# how long to certify for
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										222
									
								
								apps/pkcs12.c
									
									
									
									
									
								
							
							
						
						
									
										222
									
								
								apps/pkcs12.c
									
									
									
									
									
								
							@@ -2,10 +2,10 @@
 | 
			
		||||
#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_SHA1)
 | 
			
		||||
 | 
			
		||||
/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
 | 
			
		||||
 * project.
 | 
			
		||||
 * project 1999.
 | 
			
		||||
 */
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright (c) 1999-2002 The OpenSSL Project.  All rights reserved.
 | 
			
		||||
 * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
@@ -166,14 +166,10 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
					 maciter = PKCS12_DEFAULT_ITER;
 | 
			
		||||
		else if (!strcmp (*args, "-nomaciter"))
 | 
			
		||||
					 maciter = 1;
 | 
			
		||||
		else if (!strcmp (*args, "-nomac"))
 | 
			
		||||
					 maciter = -1;
 | 
			
		||||
		else if (!strcmp (*args, "-nodes")) enc=NULL;
 | 
			
		||||
		else if (!strcmp (*args, "-certpbe")) {
 | 
			
		||||
			if (args[1]) {
 | 
			
		||||
				args++;
 | 
			
		||||
				if (!strcmp(*args, "NONE"))
 | 
			
		||||
					cert_pbe = -1;
 | 
			
		||||
				cert_pbe=OBJ_txt2nid(*args);
 | 
			
		||||
				if(cert_pbe == NID_undef) {
 | 
			
		||||
					BIO_printf(bio_err,
 | 
			
		||||
@@ -184,9 +180,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
		} else if (!strcmp (*args, "-keypbe")) {
 | 
			
		||||
			if (args[1]) {
 | 
			
		||||
				args++;
 | 
			
		||||
				if (!strcmp(*args, "NONE"))
 | 
			
		||||
					key_pbe = -1;
 | 
			
		||||
				else
 | 
			
		||||
				key_pbe=OBJ_txt2nid(*args);
 | 
			
		||||
				if(key_pbe == NID_undef) {
 | 
			
		||||
					BIO_printf(bio_err,
 | 
			
		||||
@@ -372,6 +365,24 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
	    goto end;
 | 
			
		||||
   }
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
   if (certfile) {
 | 
			
		||||
    	if(!(certsin = BIO_new_file(certfile, "r"))) {
 | 
			
		||||
	    BIO_printf(bio_err, "Can't open certificate file %s\n", certfile);
 | 
			
		||||
	    perror (certfile);
 | 
			
		||||
	    goto end;
 | 
			
		||||
	}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (keyname) {
 | 
			
		||||
    	if(!(inkey = BIO_new_file(keyname, "r"))) {
 | 
			
		||||
	    BIO_printf(bio_err, "Can't key certificate file %s\n", keyname);
 | 
			
		||||
	    perror (keyname);
 | 
			
		||||
	    goto end;
 | 
			
		||||
	}
 | 
			
		||||
     }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef CRYPTO_MDEBUG
 | 
			
		||||
    CRYPTO_pop_info();
 | 
			
		||||
    CRYPTO_push_info("write files");
 | 
			
		||||
@@ -408,29 +419,25 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
 | 
			
		||||
    if (export_cert) {
 | 
			
		||||
	EVP_PKEY *key = NULL;
 | 
			
		||||
	X509 *ucert = NULL, *x = NULL;
 | 
			
		||||
	STACK_OF(PKCS12_SAFEBAG) *bags = NULL;
 | 
			
		||||
	STACK_OF(PKCS7) *safes = NULL;
 | 
			
		||||
	PKCS12_SAFEBAG *bag = NULL;
 | 
			
		||||
	PKCS8_PRIV_KEY_INFO *p8 = NULL;
 | 
			
		||||
	PKCS7 *authsafe = NULL;
 | 
			
		||||
	X509 *ucert = NULL;
 | 
			
		||||
	STACK_OF(X509) *certs=NULL;
 | 
			
		||||
	unsigned char *catmp = NULL;
 | 
			
		||||
	char *catmp = NULL;
 | 
			
		||||
	int i;
 | 
			
		||||
 | 
			
		||||
	if ((options & (NOCERTS|NOKEYS)) == (NOCERTS|NOKEYS))
 | 
			
		||||
		{	
 | 
			
		||||
		BIO_printf(bio_err, "Nothing to do!\n");
 | 
			
		||||
		goto export_end;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (options & NOCERTS)
 | 
			
		||||
		chain = 0;
 | 
			
		||||
	unsigned char keyid[EVP_MAX_MD_SIZE];
 | 
			
		||||
	unsigned int keyidlen = 0;
 | 
			
		||||
 | 
			
		||||
#ifdef CRYPTO_MDEBUG
 | 
			
		||||
	CRYPTO_push_info("process -export_cert");
 | 
			
		||||
	CRYPTO_push_info("reading private key");
 | 
			
		||||
#endif
 | 
			
		||||
	if (!(options & NOKEYS))
 | 
			
		||||
		{
 | 
			
		||||
		key = load_key(bio_err, keyname ? keyname : infile,
 | 
			
		||||
				FORMAT_PEM, 1, passin, e, "private key");
 | 
			
		||||
		if (!key)
 | 
			
		||||
	key = load_key(bio_err, keyname ? keyname : infile, FORMAT_PEM, 1,
 | 
			
		||||
		passin, e, "private key");
 | 
			
		||||
	if (!key) {
 | 
			
		||||
		goto export_end;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -440,37 +447,9 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	/* Load in all certs in input file */
 | 
			
		||||
	if(!(options & NOCERTS))
 | 
			
		||||
		{
 | 
			
		||||
		certs = load_certs(bio_err, infile, FORMAT_PEM, NULL, e,
 | 
			
		||||
							"certificates");
 | 
			
		||||
		if (!certs)
 | 
			
		||||
	if(!(certs = load_certs(bio_err, infile, FORMAT_PEM, NULL, e,
 | 
			
		||||
		"certificates"))) {
 | 
			
		||||
		goto export_end;
 | 
			
		||||
 | 
			
		||||
		if (key)
 | 
			
		||||
			{
 | 
			
		||||
			/* Look for matching private key */
 | 
			
		||||
			for(i = 0; i < sk_X509_num(certs); i++)
 | 
			
		||||
				{
 | 
			
		||||
				x = sk_X509_value(certs, i);
 | 
			
		||||
				if(X509_check_private_key(x, key))
 | 
			
		||||
					{
 | 
			
		||||
					ucert = x;
 | 
			
		||||
					/* Zero keyid and alias */
 | 
			
		||||
					X509_keyid_set1(ucert, NULL, 0);
 | 
			
		||||
					X509_alias_set1(ucert, NULL, 0);
 | 
			
		||||
					/* Remove from list */
 | 
			
		||||
					sk_X509_delete(certs, i);
 | 
			
		||||
					break;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			if (!ucert)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err, "No certificate matches private key\n");
 | 
			
		||||
				goto export_end;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
#ifdef CRYPTO_MDEBUG
 | 
			
		||||
@@ -478,17 +457,17 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
	CRYPTO_push_info("reading certs from input 2");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	/* Add any more certificates asked for */
 | 
			
		||||
	if(certfile)
 | 
			
		||||
		{
 | 
			
		||||
		STACK_OF(X509) *morecerts=NULL;
 | 
			
		||||
		if(!(morecerts = load_certs(bio_err, certfile, FORMAT_PEM,
 | 
			
		||||
					    NULL, e,
 | 
			
		||||
					    "certificates from certfile")))
 | 
			
		||||
	for(i = 0; i < sk_X509_num(certs); i++) {
 | 
			
		||||
		ucert = sk_X509_value(certs, i);
 | 
			
		||||
		if(X509_check_private_key(ucert, key)) {
 | 
			
		||||
			X509_digest(ucert, EVP_sha1(), keyid, &keyidlen);
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if(!keyidlen) {
 | 
			
		||||
		ucert = NULL;
 | 
			
		||||
		BIO_printf(bio_err, "No certificate matches private key\n");
 | 
			
		||||
		goto export_end;
 | 
			
		||||
		while(sk_X509_num(morecerts) > 0)
 | 
			
		||||
			sk_X509_push(certs, sk_X509_shift(morecerts));
 | 
			
		||||
		sk_X509_free(morecerts);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
#ifdef CRYPTO_MDEBUG
 | 
			
		||||
@@ -496,6 +475,22 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
	CRYPTO_push_info("reading certs from certfile");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	bags = sk_PKCS12_SAFEBAG_new_null ();
 | 
			
		||||
 | 
			
		||||
	/* Add any more certificates asked for */
 | 
			
		||||
	if (certfile) {
 | 
			
		||||
		STACK_OF(X509) *morecerts=NULL;
 | 
			
		||||
		if(!(morecerts = load_certs(bio_err, certfile, FORMAT_PEM,
 | 
			
		||||
					    NULL, e,
 | 
			
		||||
					    "certificates from certfile"))) {
 | 
			
		||||
			goto export_end;
 | 
			
		||||
		}
 | 
			
		||||
		while(sk_X509_num(morecerts) > 0) {
 | 
			
		||||
			sk_X509_push(certs, sk_X509_shift(morecerts));
 | 
			
		||||
		}
 | 
			
		||||
		sk_X509_free(morecerts);
 | 
			
		||||
 	}
 | 
			
		||||
 | 
			
		||||
#ifdef CRYPTO_MDEBUG
 | 
			
		||||
	CRYPTO_pop_info();
 | 
			
		||||
	CRYPTO_push_info("building chain");
 | 
			
		||||
@@ -531,43 +526,92 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
		}			
 | 
			
		||||
    	}
 | 
			
		||||
 | 
			
		||||
	/* Add any CA names */
 | 
			
		||||
#ifdef CRYPTO_MDEBUG
 | 
			
		||||
	CRYPTO_pop_info();
 | 
			
		||||
	CRYPTO_push_info("building bags");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < sk_num(canames); i++)
 | 
			
		||||
		{
 | 
			
		||||
		catmp = (unsigned char *)sk_value(canames, i);
 | 
			
		||||
		X509_alias_set1(sk_X509_value(certs, i), catmp, -1);
 | 
			
		||||
	/* We now have loads of certificates: include them all */
 | 
			
		||||
	for(i = 0; i < sk_X509_num(certs); i++) {
 | 
			
		||||
		X509 *cert = NULL;
 | 
			
		||||
		cert = sk_X509_value(certs, i);
 | 
			
		||||
		bag = PKCS12_x5092certbag(cert);
 | 
			
		||||
		/* If it matches private key set id */
 | 
			
		||||
		if(cert == ucert) {
 | 
			
		||||
			if(name) PKCS12_add_friendlyname(bag, name, -1);
 | 
			
		||||
			PKCS12_add_localkeyid(bag, keyid, keyidlen);
 | 
			
		||||
		} else if((catmp = sk_shift(canames))) 
 | 
			
		||||
				PKCS12_add_friendlyname(bag, catmp, -1);
 | 
			
		||||
		sk_PKCS12_SAFEBAG_push(bags, bag);
 | 
			
		||||
	}
 | 
			
		||||
		
 | 
			
		||||
	sk_X509_pop_free(certs, X509_free);
 | 
			
		||||
	certs = NULL;
 | 
			
		||||
 | 
			
		||||
#ifdef CRYPTO_MDEBUG
 | 
			
		||||
	CRYPTO_pop_info();
 | 
			
		||||
	CRYPTO_push_info("reading password");
 | 
			
		||||
	CRYPTO_push_info("encrypting bags");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	if(!noprompt &&
 | 
			
		||||
		EVP_read_pw_string(pass, sizeof pass, "Enter Export Password:", 1))
 | 
			
		||||
		{
 | 
			
		||||
		EVP_read_pw_string(pass, sizeof pass, "Enter Export Password:", 1)) {
 | 
			
		||||
	    BIO_printf (bio_err, "Can't read Password\n");
 | 
			
		||||
	    goto export_end;
 | 
			
		||||
        }
 | 
			
		||||
	if (!twopass) strcpy(macpass, pass);
 | 
			
		||||
	/* Turn certbags into encrypted authsafe */
 | 
			
		||||
	authsafe = PKCS12_pack_p7encdata(cert_pbe, cpass, -1, NULL, 0,
 | 
			
		||||
								 iter, bags);
 | 
			
		||||
	sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free);
 | 
			
		||||
	bags = NULL;
 | 
			
		||||
 | 
			
		||||
#ifdef CRYPTO_MDEBUG
 | 
			
		||||
	CRYPTO_pop_info();
 | 
			
		||||
	CRYPTO_push_info("creating PKCS#12 structure");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	p12 = PKCS12_create(cpass, name, key, ucert, certs,
 | 
			
		||||
				key_pbe, cert_pbe, iter, -1, keytype);
 | 
			
		||||
 | 
			
		||||
	if (!p12)
 | 
			
		||||
		{
 | 
			
		||||
	if (!authsafe) {
 | 
			
		||||
		ERR_print_errors (bio_err);
 | 
			
		||||
		goto export_end;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (maciter != -1)
 | 
			
		||||
	safes = sk_PKCS7_new_null ();
 | 
			
		||||
	sk_PKCS7_push (safes, authsafe);
 | 
			
		||||
 | 
			
		||||
#ifdef CRYPTO_MDEBUG
 | 
			
		||||
	CRYPTO_pop_info();
 | 
			
		||||
	CRYPTO_push_info("building shrouded key bag");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	/* Make a shrouded key bag */
 | 
			
		||||
	p8 = EVP_PKEY2PKCS8 (key);
 | 
			
		||||
	if(keytype) PKCS8_add_keyusage(p8, keytype);
 | 
			
		||||
	bag = PKCS12_MAKE_SHKEYBAG(key_pbe, cpass, -1, NULL, 0, iter, p8);
 | 
			
		||||
	PKCS8_PRIV_KEY_INFO_free(p8);
 | 
			
		||||
	p8 = NULL;
 | 
			
		||||
        if (name) PKCS12_add_friendlyname (bag, name, -1);
 | 
			
		||||
	if(csp_name) PKCS12_add_CSPName_asc(bag, csp_name, -1);
 | 
			
		||||
	PKCS12_add_localkeyid (bag, keyid, keyidlen);
 | 
			
		||||
	bags = sk_PKCS12_SAFEBAG_new_null();
 | 
			
		||||
	sk_PKCS12_SAFEBAG_push (bags, bag);
 | 
			
		||||
 | 
			
		||||
#ifdef CRYPTO_MDEBUG
 | 
			
		||||
	CRYPTO_pop_info();
 | 
			
		||||
	CRYPTO_push_info("encrypting shrouded key bag");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	/* Turn it into unencrypted safe bag */
 | 
			
		||||
	authsafe = PKCS12_pack_p7data (bags);
 | 
			
		||||
	sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free);
 | 
			
		||||
	bags = NULL;
 | 
			
		||||
	sk_PKCS7_push (safes, authsafe);
 | 
			
		||||
 | 
			
		||||
#ifdef CRYPTO_MDEBUG
 | 
			
		||||
	CRYPTO_pop_info();
 | 
			
		||||
	CRYPTO_push_info("building pkcs12");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	p12 = PKCS12_init(NID_pkcs7_data);
 | 
			
		||||
 | 
			
		||||
	PKCS12_pack_authsafes(p12, safes);
 | 
			
		||||
 | 
			
		||||
	sk_PKCS7_pop_free(safes, PKCS7_free);
 | 
			
		||||
	safes = NULL;
 | 
			
		||||
 | 
			
		||||
	PKCS12_set_mac (p12, mpass, -1, NULL, 0, maciter, NULL);
 | 
			
		||||
 | 
			
		||||
#ifdef CRYPTO_MDEBUG
 | 
			
		||||
@@ -588,7 +632,8 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
 | 
			
		||||
	if (key) EVP_PKEY_free(key);
 | 
			
		||||
	if (certs) sk_X509_pop_free(certs, X509_free);
 | 
			
		||||
	if (ucert) X509_free(ucert);
 | 
			
		||||
	if (safes) sk_PKCS7_pop_free(safes, PKCS7_free);
 | 
			
		||||
	if (bags) sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free);
 | 
			
		||||
 | 
			
		||||
#ifdef CRYPTO_MDEBUG
 | 
			
		||||
	CRYPTO_pop_info();
 | 
			
		||||
@@ -814,9 +859,8 @@ int alg_print (BIO *x, X509_ALGOR *alg)
 | 
			
		||||
	unsigned char *p;
 | 
			
		||||
	p = alg->parameter->value.sequence->data;
 | 
			
		||||
	pbe = d2i_PBEPARAM (NULL, &p, alg->parameter->value.sequence->length);
 | 
			
		||||
	BIO_printf (bio_err, "%s, Iteration %ld\n", 
 | 
			
		||||
		OBJ_nid2ln(OBJ_obj2nid(alg->algorithm)),
 | 
			
		||||
		ASN1_INTEGER_get(pbe->iter));
 | 
			
		||||
	BIO_printf (bio_err, "%s, Iteration %d\n", 
 | 
			
		||||
	OBJ_nid2ln(OBJ_obj2nid(alg->algorithm)), ASN1_INTEGER_get(pbe->iter));
 | 
			
		||||
	PBEPARAM_free (pbe);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										17
									
								
								apps/pkcs8.c
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								apps/pkcs8.c
									
									
									
									
									
								
							@@ -232,14 +232,11 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
		pkey = load_key(bio_err, infile, informat, 1,
 | 
			
		||||
			passin, e, "key");
 | 
			
		||||
		if (!pkey) {
 | 
			
		||||
			BIO_free_all(out);
 | 
			
		||||
			return (1);
 | 
			
		||||
		}
 | 
			
		||||
		if (!(p8inf = EVP_PKEY2PKCS8_broken(pkey, p8_broken))) {
 | 
			
		||||
			BIO_printf(bio_err, "Error converting key\n");
 | 
			
		||||
			ERR_print_errors(bio_err);
 | 
			
		||||
			EVP_PKEY_free(pkey);
 | 
			
		||||
			BIO_free_all(out);
 | 
			
		||||
			return (1);
 | 
			
		||||
		}
 | 
			
		||||
		if(nocrypt) {
 | 
			
		||||
@@ -249,9 +246,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
				i2d_PKCS8_PRIV_KEY_INFO_bio(out, p8inf);
 | 
			
		||||
			else {
 | 
			
		||||
				BIO_printf(bio_err, "Bad format specified for key\n");
 | 
			
		||||
				PKCS8_PRIV_KEY_INFO_free(p8inf);
 | 
			
		||||
				EVP_PKEY_free(pkey);
 | 
			
		||||
				BIO_free_all(out);
 | 
			
		||||
				return (1);
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
@@ -259,22 +253,14 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
			else {
 | 
			
		||||
				p8pass = pass;
 | 
			
		||||
				if (EVP_read_pw_string(pass, sizeof pass, "Enter Encryption Password:", 1))
 | 
			
		||||
				{
 | 
			
		||||
					PKCS8_PRIV_KEY_INFO_free(p8inf);
 | 
			
		||||
					EVP_PKEY_free(pkey);
 | 
			
		||||
					BIO_free_all(out);
 | 
			
		||||
					return (1);
 | 
			
		||||
			}
 | 
			
		||||
			}
 | 
			
		||||
			app_RAND_load_file(NULL, bio_err, 0);
 | 
			
		||||
			if (!(p8 = PKCS8_encrypt(pbe_nid, cipher,
 | 
			
		||||
					p8pass, strlen(p8pass),
 | 
			
		||||
					NULL, 0, iter, p8inf))) {
 | 
			
		||||
				BIO_printf(bio_err, "Error encrypting key\n");
 | 
			
		||||
				ERR_print_errors(bio_err);
 | 
			
		||||
				PKCS8_PRIV_KEY_INFO_free(p8inf);
 | 
			
		||||
				EVP_PKEY_free(pkey);
 | 
			
		||||
				BIO_free_all(out);
 | 
			
		||||
				return (1);
 | 
			
		||||
			}
 | 
			
		||||
			app_RAND_write_file(NULL, bio_err);
 | 
			
		||||
@@ -284,9 +270,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
				i2d_PKCS8_bio(out, p8);
 | 
			
		||||
			else {
 | 
			
		||||
				BIO_printf(bio_err, "Bad format specified for key\n");
 | 
			
		||||
				PKCS8_PRIV_KEY_INFO_free(p8inf);
 | 
			
		||||
				EVP_PKEY_free(pkey);
 | 
			
		||||
				BIO_free_all(out);
 | 
			
		||||
				return (1);
 | 
			
		||||
			}
 | 
			
		||||
			X509_SIG_free(p8);
 | 
			
		||||
 
 | 
			
		||||
@@ -17,8 +17,6 @@ extern int rsa_main(int argc,char *argv[]);
 | 
			
		||||
extern int rsautl_main(int argc,char *argv[]);
 | 
			
		||||
extern int dsa_main(int argc,char *argv[]);
 | 
			
		||||
extern int dsaparam_main(int argc,char *argv[]);
 | 
			
		||||
extern int ec_main(int argc,char *argv[]);
 | 
			
		||||
extern int ecparam_main(int argc,char *argv[]);
 | 
			
		||||
extern int x509_main(int argc,char *argv[]);
 | 
			
		||||
extern int genrsa_main(int argc,char *argv[]);
 | 
			
		||||
extern int gendsa_main(int argc,char *argv[]);
 | 
			
		||||
@@ -82,12 +80,6 @@ FUNCTION functions[] = {
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
	{FUNC_TYPE_GENERAL,"dsaparam",dsaparam_main},
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
	{FUNC_TYPE_GENERAL,"ec",ec_main},
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
	{FUNC_TYPE_GENERAL,"ecparam",ecparam_main},
 | 
			
		||||
#endif
 | 
			
		||||
	{FUNC_TYPE_GENERAL,"x509",x509_main},
 | 
			
		||||
#ifndef OPENSSL_NO_RSA
 | 
			
		||||
 
 | 
			
		||||
@@ -33,8 +33,6 @@ foreach (@ARGV)
 | 
			
		||||
		{ print "#ifndef OPENSSL_NO_RSA\n${str}#endif\n";  }
 | 
			
		||||
	elsif ( ($_ =~ /^dsa$/) || ($_ =~ /^gendsa$/) || ($_ =~ /^dsaparam$/))
 | 
			
		||||
		{ print "#ifndef OPENSSL_NO_DSA\n${str}#endif\n"; }
 | 
			
		||||
	elsif ( ($_ =~ /^ec$/) || ($_ =~ /^ecparam$/))
 | 
			
		||||
		{ print "#ifndef OPENSSL_NO_EC\n${str}#endif\n";}
 | 
			
		||||
	elsif ( ($_ =~ /^dh$/) || ($_ =~ /^gendh$/) || ($_ =~ /^dhparam$/))
 | 
			
		||||
		{ print "#ifndef OPENSSL_NO_DH\n${str}#endif\n"; }
 | 
			
		||||
	elsif ( ($_ =~ /^pkcs12$/))
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										124
									
								
								apps/req.c
									
									
									
									
									
								
							
							
						
						
									
										124
									
								
								apps/req.c
									
									
									
									
									
								
							@@ -56,12 +56,6 @@
 | 
			
		||||
 * [including the GNU Public Licence.]
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* Until the key-gen callbacks are modified to use newer prototypes, we allow
 | 
			
		||||
 * deprecated functions for openssl-internal code */
 | 
			
		||||
#ifdef OPENSSL_NO_DEPRECATED
 | 
			
		||||
#undef OPENSSL_NO_DEPRECATED
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
@@ -133,7 +127,7 @@ static int add_attribute_object(X509_REQ *req, char *text,
 | 
			
		||||
				char *def, char *value, int nid, int n_min,
 | 
			
		||||
				int n_max, unsigned long chtype);
 | 
			
		||||
static int add_DN_object(X509_NAME *n, char *text, char *def, char *value,
 | 
			
		||||
	int nid,int n_min,int n_max, unsigned long chtype, int mval);
 | 
			
		||||
	int nid,int n_min,int n_max, unsigned long chtype);
 | 
			
		||||
#ifndef OPENSSL_NO_RSA
 | 
			
		||||
static void MS_CALLBACK req_cb(int p,int n,void *arg);
 | 
			
		||||
#endif
 | 
			
		||||
@@ -148,7 +142,6 @@ static int batch=0;
 | 
			
		||||
#define TYPE_RSA	1
 | 
			
		||||
#define TYPE_DSA	2
 | 
			
		||||
#define TYPE_DH		3
 | 
			
		||||
#define TYPE_EC		4
 | 
			
		||||
 | 
			
		||||
int MAIN(int, char **);
 | 
			
		||||
 | 
			
		||||
@@ -157,9 +150,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
	ENGINE *e = NULL;
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
	DSA *dsa_params=NULL;
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
	EC_KEY *ec_params = NULL;
 | 
			
		||||
#endif
 | 
			
		||||
	unsigned long nmflag = 0, reqflag = 0;
 | 
			
		||||
	int ex=1,x509=0,days=30;
 | 
			
		||||
@@ -332,56 +322,8 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				BIO_free(in);
 | 
			
		||||
				in=NULL;
 | 
			
		||||
				newkey=BN_num_bits(dsa_params->p);
 | 
			
		||||
				}
 | 
			
		||||
			else 
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
				if (strncmp("ec:",p,3) == 0)
 | 
			
		||||
				{
 | 
			
		||||
				X509 *xtmp=NULL;
 | 
			
		||||
				EVP_PKEY *dtmp;
 | 
			
		||||
 | 
			
		||||
				pkey_type=TYPE_EC;
 | 
			
		||||
				p+=3;
 | 
			
		||||
				if ((in=BIO_new_file(p,"r")) == NULL)
 | 
			
		||||
					{
 | 
			
		||||
					perror(p);
 | 
			
		||||
					goto end;
 | 
			
		||||
					}
 | 
			
		||||
				if ((ec_params = EC_KEY_new()) == NULL)
 | 
			
		||||
					goto end;
 | 
			
		||||
				if ((ec_params->group = PEM_read_bio_ECPKParameters(in, NULL, NULL, NULL)) == NULL)
 | 
			
		||||
					{
 | 
			
		||||
					if (ec_params)
 | 
			
		||||
						EC_KEY_free(ec_params);
 | 
			
		||||
					ERR_clear_error();
 | 
			
		||||
					(void)BIO_reset(in);
 | 
			
		||||
					if ((xtmp=PEM_read_bio_X509(in,NULL,NULL,NULL)) == NULL)
 | 
			
		||||
						{	
 | 
			
		||||
						BIO_printf(bio_err,"unable to load EC parameters from file\n");
 | 
			
		||||
						goto end;
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
					if ((dtmp=X509_get_pubkey(xtmp))==NULL)
 | 
			
		||||
						goto end;
 | 
			
		||||
					if (dtmp->type == EVP_PKEY_EC)
 | 
			
		||||
						ec_params = ECParameters_dup(dtmp->pkey.eckey);
 | 
			
		||||
					EVP_PKEY_free(dtmp);
 | 
			
		||||
					X509_free(xtmp);
 | 
			
		||||
					if (ec_params == NULL)
 | 
			
		||||
						{
 | 
			
		||||
						BIO_printf(bio_err,"Certificate does not contain EC parameters\n");
 | 
			
		||||
						goto end;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
				BIO_free(in);
 | 
			
		||||
				in=NULL;
 | 
			
		||||
				
 | 
			
		||||
				newkey = EC_GROUP_get_degree(ec_params->group);
 | 
			
		||||
 | 
			
		||||
				}
 | 
			
		||||
			else 
 | 
			
		||||
#endif
 | 
			
		||||
@@ -393,9 +335,7 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
				}
 | 
			
		||||
			else
 | 
			
		||||
#endif
 | 
			
		||||
				{
 | 
			
		||||
				goto bad;
 | 
			
		||||
				}
 | 
			
		||||
				pkey_type=TYPE_RSA;
 | 
			
		||||
 | 
			
		||||
			newreq=1;
 | 
			
		||||
			}
 | 
			
		||||
@@ -505,9 +445,6 @@ bad:
 | 
			
		||||
		BIO_printf(bio_err,"                the random number generator\n");
 | 
			
		||||
		BIO_printf(bio_err," -newkey rsa:bits generate a new RSA key of 'bits' in size\n");
 | 
			
		||||
		BIO_printf(bio_err," -newkey dsa:file generate a new DSA key, parameters taken from CA in 'file'\n");
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
		BIO_printf(bio_err," -newkey ec:file generate a new EC key, parameters taken from CA in 'file'\n");
 | 
			
		||||
#endif
 | 
			
		||||
		BIO_printf(bio_err," -[digest]      Digest to sign with (md5, sha1, md2, mdc2, md4)\n");
 | 
			
		||||
		BIO_printf(bio_err," -config file   request template file.\n");
 | 
			
		||||
		BIO_printf(bio_err," -subj arg      set or modify request subject\n");
 | 
			
		||||
@@ -700,8 +637,7 @@ bad:
 | 
			
		||||
			   message */
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		if (EVP_PKEY_type(pkey->type) == EVP_PKEY_DSA || 
 | 
			
		||||
			EVP_PKEY_type(pkey->type) == EVP_PKEY_EC)
 | 
			
		||||
		if (EVP_PKEY_type(pkey->type) == EVP_PKEY_DSA)
 | 
			
		||||
			{
 | 
			
		||||
			char *randfile = NCONF_get_string(req_conf,SECTION,"RANDFILE");
 | 
			
		||||
			if (randfile == NULL)
 | 
			
		||||
@@ -725,15 +661,14 @@ bad:
 | 
			
		||||
				newkey=DEFAULT_KEY_LENGTH;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		if (newkey < MIN_KEY_LENGTH && (pkey_type == TYPE_RSA || pkey_type == TYPE_DSA))
 | 
			
		||||
		if (newkey < MIN_KEY_LENGTH)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,"private key length is too short,\n");
 | 
			
		||||
			BIO_printf(bio_err,"it needs to be at least %d bits, not %ld\n",MIN_KEY_LENGTH,newkey);
 | 
			
		||||
			BIO_printf(bio_err,"it needs to be at least %d bits, not %d\n",MIN_KEY_LENGTH,newkey);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		BIO_printf(bio_err,"Generating a %ld bit %s private key\n",
 | 
			
		||||
			newkey,(pkey_type == TYPE_RSA)?"RSA":
 | 
			
		||||
			(pkey_type == TYPE_DSA)?"DSA":"EC");
 | 
			
		||||
		BIO_printf(bio_err,"Generating a %d bit %s private key\n",
 | 
			
		||||
			newkey,(pkey_type == TYPE_RSA)?"RSA":"DSA");
 | 
			
		||||
 | 
			
		||||
		if ((pkey=EVP_PKEY_new()) == NULL) goto end;
 | 
			
		||||
 | 
			
		||||
@@ -755,15 +690,6 @@ bad:
 | 
			
		||||
			dsa_params=NULL;
 | 
			
		||||
			}
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
			if (pkey_type == TYPE_EC)
 | 
			
		||||
			{
 | 
			
		||||
			if (!EC_KEY_generate_key(ec_params)) goto end;
 | 
			
		||||
			if (!EVP_PKEY_assign_EC_KEY(pkey, ec_params)) 
 | 
			
		||||
				goto end;
 | 
			
		||||
			ec_params = NULL;
 | 
			
		||||
			}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
		app_RAND_write_file(randfile, bio_err);
 | 
			
		||||
 | 
			
		||||
@@ -869,10 +795,6 @@ loop:
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
		if (pkey->type == EVP_PKEY_DSA)
 | 
			
		||||
			digest=EVP_dss1();
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
		if (pkey->type == EVP_PKEY_EC)
 | 
			
		||||
			digest=EVP_ecdsa();
 | 
			
		||||
#endif
 | 
			
		||||
		if (req == NULL)
 | 
			
		||||
			{
 | 
			
		||||
@@ -1158,9 +1080,6 @@ end:
 | 
			
		||||
	OBJ_cleanup();
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
	if (dsa_params != NULL) DSA_free(dsa_params);
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
	if (ec_params != NULL) EC_KEY_free(ec_params);
 | 
			
		||||
#endif
 | 
			
		||||
	apps_shutdown();
 | 
			
		||||
	OPENSSL_EXIT(ex);
 | 
			
		||||
@@ -1259,7 +1178,7 @@ static int prompt_info(X509_REQ *req,
 | 
			
		||||
	int i;
 | 
			
		||||
	char *p,*q;
 | 
			
		||||
	char buf[100];
 | 
			
		||||
	int nid, mval;
 | 
			
		||||
	int nid;
 | 
			
		||||
	long n_min,n_max;
 | 
			
		||||
	char *type,*def,*value;
 | 
			
		||||
	CONF_VALUE *v;
 | 
			
		||||
@@ -1302,13 +1221,6 @@ start:		for (;;)
 | 
			
		||||
					if(*p) type = p;
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			if (*type == '+')
 | 
			
		||||
				{
 | 
			
		||||
				mval = -1;
 | 
			
		||||
				type++;
 | 
			
		||||
				}
 | 
			
		||||
			else
 | 
			
		||||
				mval = 0;
 | 
			
		||||
			/* If OBJ not recognised ignore it */
 | 
			
		||||
			if ((nid=OBJ_txt2nid(type)) == NID_undef) goto start;
 | 
			
		||||
 | 
			
		||||
@@ -1346,7 +1258,7 @@ start:		for (;;)
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
			if (!add_DN_object(subj,v->value,def,value,nid,
 | 
			
		||||
				n_min,n_max, chtype, mval))
 | 
			
		||||
				n_min,n_max, chtype))
 | 
			
		||||
				return 0;
 | 
			
		||||
			}
 | 
			
		||||
		if (X509_NAME_entry_count(subj) == 0)
 | 
			
		||||
@@ -1436,7 +1348,6 @@ static int auto_info(X509_REQ *req, STACK_OF(CONF_VALUE) *dn_sk,
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < sk_CONF_VALUE_num(dn_sk); i++)
 | 
			
		||||
		{
 | 
			
		||||
		int mval;
 | 
			
		||||
		v=sk_CONF_VALUE_value(dn_sk,i);
 | 
			
		||||
		p=q=NULL;
 | 
			
		||||
		type=v->name;
 | 
			
		||||
@@ -1453,19 +1364,8 @@ static int auto_info(X509_REQ *req, STACK_OF(CONF_VALUE) *dn_sk,
 | 
			
		||||
				if(*p) type = p;
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
#ifndef CHARSET_EBCDIC
 | 
			
		||||
		if (*p == '+')
 | 
			
		||||
#else
 | 
			
		||||
		if (*p == os_toascii['+'])
 | 
			
		||||
#endif
 | 
			
		||||
			{
 | 
			
		||||
			p++;
 | 
			
		||||
			mval = -1;
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
			mval = 0;
 | 
			
		||||
		if (!X509_NAME_add_entry_by_txt(subj,type, chtype,
 | 
			
		||||
				(unsigned char *) v->value,-1,-1,mval)) return 0;
 | 
			
		||||
				(unsigned char *) v->value,-1,-1,0)) return 0;
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@@ -1488,7 +1388,7 @@ static int auto_info(X509_REQ *req, STACK_OF(CONF_VALUE) *dn_sk,
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int add_DN_object(X509_NAME *n, char *text, char *def, char *value,
 | 
			
		||||
	     int nid, int n_min, int n_max, unsigned long chtype, int mval)
 | 
			
		||||
	     int nid, int n_min, int n_max, unsigned long chtype)
 | 
			
		||||
	{
 | 
			
		||||
	int i,ret=0;
 | 
			
		||||
	MS_STATIC char buf[1024];
 | 
			
		||||
@@ -1538,7 +1438,7 @@ start:
 | 
			
		||||
#endif
 | 
			
		||||
	if(!req_check_len(i, n_min, n_max)) goto start;
 | 
			
		||||
	if (!X509_NAME_add_entry_by_NID(n,nid, chtype,
 | 
			
		||||
				(unsigned char *) buf, -1,-1,mval)) goto err;
 | 
			
		||||
				(unsigned char *) buf, -1,-1,0)) goto err;
 | 
			
		||||
	ret=1;
 | 
			
		||||
err:
 | 
			
		||||
	return(ret);
 | 
			
		||||
 
 | 
			
		||||
@@ -112,6 +112,14 @@
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <openssl/opensslconf.h>
 | 
			
		||||
 | 
			
		||||
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
 | 
			
		||||
#include <conio.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef OPENSSL_SYS_MSDOS
 | 
			
		||||
#define _kbhit kbhit
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(OPENSSL_SYS_VMS) && !defined(FD_SET)
 | 
			
		||||
/* VAX C does not defined fd_set and friends, but it's actually quite simple */
 | 
			
		||||
/* These definitions are borrowed from SOCKETSHR.	/Richard Levitte */
 | 
			
		||||
 
 | 
			
		||||
@@ -239,15 +239,15 @@ long MS_CALLBACK bio_dump_cb(BIO *bio, int cmd, const char *argp, int argi,
 | 
			
		||||
 | 
			
		||||
	if (cmd == (BIO_CB_READ|BIO_CB_RETURN))
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(out,"read from %p [%p] (%d bytes => %ld (0x%lX))\n",
 | 
			
		||||
 			(void *)bio,argp,argi,ret,ret);
 | 
			
		||||
		BIO_printf(out,"read from %08X [%08lX] (%d bytes => %ld (0x%X))\n",
 | 
			
		||||
			bio,argp,argi,ret,ret);
 | 
			
		||||
		BIO_dump(out,argp,(int)ret);
 | 
			
		||||
		return(ret);
 | 
			
		||||
		}
 | 
			
		||||
	else if (cmd == (BIO_CB_WRITE|BIO_CB_RETURN))
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(out,"write to %p [%p] (%d bytes => %ld (0x%lX))\n",
 | 
			
		||||
			(void *)bio,argp,argi,ret,ret);
 | 
			
		||||
		BIO_printf(out,"write to %08X [%08lX] (%d bytes => %ld (0x%X))\n",
 | 
			
		||||
			bio,argp,argi,ret,ret);
 | 
			
		||||
		BIO_dump(out,argp,(int)ret);
 | 
			
		||||
		}
 | 
			
		||||
	return(ret);
 | 
			
		||||
 
 | 
			
		||||
@@ -136,10 +136,6 @@ typedef unsigned int u_int;
 | 
			
		||||
#include <openssl/rand.h>
 | 
			
		||||
#include "s_apps.h"
 | 
			
		||||
 | 
			
		||||
#ifdef OPENSSL_SYS_WINDOWS
 | 
			
		||||
#include <conio.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef OPENSSL_SYS_WINCE
 | 
			
		||||
/* Windows CE incorrectly defines fileno as returning void*, so to avoid problems below... */
 | 
			
		||||
#ifdef fileno
 | 
			
		||||
@@ -260,7 +256,7 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
	char *engine_id=NULL;
 | 
			
		||||
	ENGINE *e=NULL;
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef OPENSSL_SYS_WINDOWS
 | 
			
		||||
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
 | 
			
		||||
	struct timeval tv;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@@ -644,7 +640,7 @@ re_start:
 | 
			
		||||
 | 
			
		||||
		if (!ssl_pending)
 | 
			
		||||
			{
 | 
			
		||||
#ifndef OPENSSL_SYS_WINDOWS
 | 
			
		||||
#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS)
 | 
			
		||||
			if (tty_on)
 | 
			
		||||
				{
 | 
			
		||||
				if (read_tty)  FD_SET(fileno(stdin),&readfds);
 | 
			
		||||
@@ -671,8 +667,8 @@ re_start:
 | 
			
		||||
			 * will choke the compiler: if you do have a cast then
 | 
			
		||||
			 * you can either go for (int *) or (void *).
 | 
			
		||||
			 */
 | 
			
		||||
#ifdef OPENSSL_SYS_WINDOWS
 | 
			
		||||
			/* Under Windows we make the assumption that we can
 | 
			
		||||
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
 | 
			
		||||
                        /* Under Windows/DOS we make the assumption that we can
 | 
			
		||||
			 * always write to the tty: therefore if we need to
 | 
			
		||||
			 * write to the tty we just fall through. Otherwise
 | 
			
		||||
			 * we timeout the select every second and see if there
 | 
			
		||||
@@ -686,7 +682,7 @@ re_start:
 | 
			
		||||
					tv.tv_usec = 0;
 | 
			
		||||
					i=select(width,(void *)&readfds,(void *)&writefds,
 | 
			
		||||
						 NULL,&tv);
 | 
			
		||||
#ifdef OPENSSL_SYS_WINCE
 | 
			
		||||
#if defined(OPENSSL_SYS_WINCE) || defined(OPENSSL_SYS_MSDOS)
 | 
			
		||||
					if(!i && (!_kbhit() || !read_tty) ) continue;
 | 
			
		||||
#else
 | 
			
		||||
					if(!i && (!((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0))) || !read_tty) ) continue;
 | 
			
		||||
@@ -855,8 +851,8 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
#ifdef OPENSSL_SYS_WINDOWS
 | 
			
		||||
#ifdef OPENSSL_SYS_WINCE
 | 
			
		||||
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
 | 
			
		||||
#if defined(OPENSSL_SYS_WINCE) || defined(OPENSSL_SYS_MSDOS)
 | 
			
		||||
		else if (_kbhit())
 | 
			
		||||
#else
 | 
			
		||||
		else if ((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0)))
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										130
									
								
								apps/s_server.c
									
									
									
									
									
								
							
							
						
						
									
										130
									
								
								apps/s_server.c
									
									
									
									
									
								
							@@ -108,17 +108,6 @@
 | 
			
		||||
 * Hudson (tjh@cryptsoft.com).
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 | 
			
		||||
 * ECC cipher suite support in OpenSSL originally developed by 
 | 
			
		||||
 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* Until the key-gen callbacks are modified to use newer prototypes, we allow
 | 
			
		||||
 * deprecated functions for openssl-internal code */
 | 
			
		||||
#ifdef OPENSSL_NO_DEPRECATED
 | 
			
		||||
#undef OPENSSL_NO_DEPRECATED
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
@@ -151,10 +140,6 @@ typedef unsigned int u_int;
 | 
			
		||||
#include <openssl/rand.h>
 | 
			
		||||
#include "s_apps.h"
 | 
			
		||||
 | 
			
		||||
#ifdef OPENSSL_SYS_WINDOWS
 | 
			
		||||
#include <conio.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef OPENSSL_SYS_WINCE
 | 
			
		||||
/* Windows CE incorrectly defines fileno as returning void*, so to avoid problems below... */
 | 
			
		||||
#ifdef fileno
 | 
			
		||||
@@ -183,7 +168,6 @@ static int generate_session_id(const SSL *ssl, unsigned char *id,
 | 
			
		||||
static DH *load_dh_param(char *dhfile);
 | 
			
		||||
static DH *get_dh512(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef MONOLITH
 | 
			
		||||
static void s_server_init(void);
 | 
			
		||||
#endif
 | 
			
		||||
@@ -222,7 +206,6 @@ static DH *get_dh512(void)
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* static int load_CA(SSL_CTX *ctx, char *file);*/
 | 
			
		||||
 | 
			
		||||
#undef BUFSIZZ
 | 
			
		||||
@@ -304,11 +287,6 @@ static void sv_usage(void)
 | 
			
		||||
	BIO_printf(bio_err," -dkey arg     - second private key file to use (usually for DSA)\n");
 | 
			
		||||
	BIO_printf(bio_err," -dhparam arg  - DH parameter file to use, in cert file if not specified\n");
 | 
			
		||||
	BIO_printf(bio_err,"                 or a default set of parameters is used\n");
 | 
			
		||||
#ifndef OPENSSL_NO_ECDH
 | 
			
		||||
	BIO_printf(bio_err," -named_curve arg  - Elliptic curve name to use for ephemeral ECDH keys.\n" \
 | 
			
		||||
	                   "                 Use \"openssl ecparam -list_curves\" for all names\n" \
 | 
			
		||||
	                   "                 (default is sect163r2).\n");
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef FIONBIO
 | 
			
		||||
	BIO_printf(bio_err," -nbio         - Run with non-blocking IO\n");
 | 
			
		||||
#endif
 | 
			
		||||
@@ -332,9 +310,6 @@ static void sv_usage(void)
 | 
			
		||||
	BIO_printf(bio_err," -no_tls1      - Just disable TLSv1\n");
 | 
			
		||||
#ifndef OPENSSL_NO_DH
 | 
			
		||||
	BIO_printf(bio_err," -no_dhe       - Disable ephemeral DH\n");
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDH
 | 
			
		||||
	BIO_printf(bio_err," -no_ecdhe     - Disable ephemeral ECDH\n");
 | 
			
		||||
#endif
 | 
			
		||||
	BIO_printf(bio_err," -bugs         - Turn on SSL bug compatibility\n");
 | 
			
		||||
	BIO_printf(bio_err," -www          - Respond to a 'GET /' with a status page\n");
 | 
			
		||||
@@ -511,11 +486,10 @@ int MAIN(int argc, char *argv[])
 | 
			
		||||
	char *CApath=NULL,*CAfile=NULL;
 | 
			
		||||
	char *context = NULL;
 | 
			
		||||
	char *dhfile = NULL;
 | 
			
		||||
	char *named_curve = NULL;
 | 
			
		||||
	int badop=0,bugs=0;
 | 
			
		||||
	int ret=1;
 | 
			
		||||
	int off=0;
 | 
			
		||||
	int no_tmp_rsa=0,no_dhe=0,no_ecdhe=0,nocert=0;
 | 
			
		||||
	int no_tmp_rsa=0,no_dhe=0,nocert=0;
 | 
			
		||||
	int state=0;
 | 
			
		||||
	SSL_METHOD *meth=NULL;
 | 
			
		||||
#ifndef OPENSSL_NO_ENGINE
 | 
			
		||||
@@ -598,13 +572,6 @@ int MAIN(int argc, char *argv[])
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			dhfile = *(++argv);
 | 
			
		||||
			}
 | 
			
		||||
#ifndef OPENSSL_NO_ECDH		
 | 
			
		||||
		else if	(strcmp(*argv,"-named_curve") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
			named_curve = *(++argv);
 | 
			
		||||
			}
 | 
			
		||||
#endif
 | 
			
		||||
		else if	(strcmp(*argv,"-dcert") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (--argc < 1) goto bad;
 | 
			
		||||
@@ -673,8 +640,6 @@ int MAIN(int argc, char *argv[])
 | 
			
		||||
			{ no_tmp_rsa=1; }
 | 
			
		||||
		else if	(strcmp(*argv,"-no_dhe") == 0)
 | 
			
		||||
			{ no_dhe=1; }
 | 
			
		||||
		else if	(strcmp(*argv,"-no_ecdhe") == 0)
 | 
			
		||||
			{ no_ecdhe=1; }
 | 
			
		||||
		else if	(strcmp(*argv,"-www") == 0)
 | 
			
		||||
			{ www=1; }
 | 
			
		||||
		else if	(strcmp(*argv,"-WWW") == 0)
 | 
			
		||||
@@ -761,7 +726,7 @@ bad:
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
#if !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_ECDSA)
 | 
			
		||||
#if !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_DSA)
 | 
			
		||||
	if (nocert)
 | 
			
		||||
#endif
 | 
			
		||||
		{
 | 
			
		||||
@@ -850,59 +815,6 @@ bad:
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
	
 | 
			
		||||
#ifndef OPENSSL_NO_ECDH
 | 
			
		||||
	if (!no_ecdhe)
 | 
			
		||||
		{
 | 
			
		||||
		EC_KEY *ecdh=NULL;
 | 
			
		||||
 | 
			
		||||
		ecdh = EC_KEY_new();
 | 
			
		||||
		if (ecdh == NULL)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,"Could not create ECDH struct.\n");
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		if (named_curve)
 | 
			
		||||
			{
 | 
			
		||||
			int nid = OBJ_sn2nid(named_curve);
 | 
			
		||||
 | 
			
		||||
			if (nid == 0)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err, "unknown curve name (%s)\n", 
 | 
			
		||||
					named_curve);
 | 
			
		||||
				goto end;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
			ecdh->group = EC_GROUP_new_by_nid(nid);
 | 
			
		||||
			if (ecdh->group == NULL)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err, "unable to create curve (%s)\n", 
 | 
			
		||||
					named_curve);
 | 
			
		||||
				goto end;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		if (ecdh->group != NULL)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_s_out,"Setting temp ECDH parameters\n");
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_s_out,"Using default temp ECDH parameters\n");
 | 
			
		||||
			ecdh->group=EC_GROUP_new_by_nid(NID_sect163r2);
 | 
			
		||||
			if (ecdh->group == NULL) 
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err, "unable to create curve (sect163r2)\n");
 | 
			
		||||
				goto end;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		(void)BIO_flush(bio_s_out);
 | 
			
		||||
 | 
			
		||||
		SSL_CTX_set_tmp_ecdh(ctx,ecdh);
 | 
			
		||||
		EC_KEY_free(ecdh);
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
	
 | 
			
		||||
	if (!set_cert_stuff(ctx,s_cert_file,s_key_file))
 | 
			
		||||
		goto end;
 | 
			
		||||
	if (s_dcert_file != NULL)
 | 
			
		||||
@@ -971,23 +883,23 @@ static void print_stats(BIO *bio, SSL_CTX *ssl_ctx)
 | 
			
		||||
	{
 | 
			
		||||
	BIO_printf(bio,"%4ld items in the session cache\n",
 | 
			
		||||
		SSL_CTX_sess_number(ssl_ctx));
 | 
			
		||||
	BIO_printf(bio,"%4ld client connects (SSL_connect())\n",
 | 
			
		||||
	BIO_printf(bio,"%4d client connects (SSL_connect())\n",
 | 
			
		||||
		SSL_CTX_sess_connect(ssl_ctx));
 | 
			
		||||
	BIO_printf(bio,"%4ld client renegotiates (SSL_connect())\n",
 | 
			
		||||
	BIO_printf(bio,"%4d client renegotiates (SSL_connect())\n",
 | 
			
		||||
		SSL_CTX_sess_connect_renegotiate(ssl_ctx));
 | 
			
		||||
	BIO_printf(bio,"%4ld client connects that finished\n",
 | 
			
		||||
	BIO_printf(bio,"%4d client connects that finished\n",
 | 
			
		||||
		SSL_CTX_sess_connect_good(ssl_ctx));
 | 
			
		||||
	BIO_printf(bio,"%4ld server accepts (SSL_accept())\n",
 | 
			
		||||
	BIO_printf(bio,"%4d server accepts (SSL_accept())\n",
 | 
			
		||||
		SSL_CTX_sess_accept(ssl_ctx));
 | 
			
		||||
	BIO_printf(bio,"%4ld server renegotiates (SSL_accept())\n",
 | 
			
		||||
	BIO_printf(bio,"%4d server renegotiates (SSL_accept())\n",
 | 
			
		||||
		SSL_CTX_sess_accept_renegotiate(ssl_ctx));
 | 
			
		||||
	BIO_printf(bio,"%4ld server accepts that finished\n",
 | 
			
		||||
	BIO_printf(bio,"%4d server accepts that finished\n",
 | 
			
		||||
		SSL_CTX_sess_accept_good(ssl_ctx));
 | 
			
		||||
	BIO_printf(bio,"%4ld session cache hits\n",SSL_CTX_sess_hits(ssl_ctx));
 | 
			
		||||
	BIO_printf(bio,"%4ld session cache misses\n",SSL_CTX_sess_misses(ssl_ctx));
 | 
			
		||||
	BIO_printf(bio,"%4ld session cache timeouts\n",SSL_CTX_sess_timeouts(ssl_ctx));
 | 
			
		||||
	BIO_printf(bio,"%4ld callback cache hits\n",SSL_CTX_sess_cb_hits(ssl_ctx));
 | 
			
		||||
	BIO_printf(bio,"%4ld cache full overflows (%ld allowed)\n",
 | 
			
		||||
	BIO_printf(bio,"%4d session cache hits\n",SSL_CTX_sess_hits(ssl_ctx));
 | 
			
		||||
	BIO_printf(bio,"%4d session cache misses\n",SSL_CTX_sess_misses(ssl_ctx));
 | 
			
		||||
	BIO_printf(bio,"%4d session cache timeouts\n",SSL_CTX_sess_timeouts(ssl_ctx));
 | 
			
		||||
	BIO_printf(bio,"%4d callback cache hits\n",SSL_CTX_sess_cb_hits(ssl_ctx));
 | 
			
		||||
	BIO_printf(bio,"%4d cache full overflows (%d allowed)\n",
 | 
			
		||||
		SSL_CTX_sess_cache_full(ssl_ctx),
 | 
			
		||||
		SSL_CTX_sess_get_cache_size(ssl_ctx));
 | 
			
		||||
	}
 | 
			
		||||
@@ -1001,7 +913,7 @@ static int sv_body(char *hostname, int s, unsigned char *context)
 | 
			
		||||
	unsigned long l;
 | 
			
		||||
	SSL *con=NULL;
 | 
			
		||||
	BIO *sbio;
 | 
			
		||||
#ifdef OPENSSL_SYS_WINDOWS
 | 
			
		||||
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
 | 
			
		||||
	struct timeval tv;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@@ -1075,7 +987,7 @@ static int sv_body(char *hostname, int s, unsigned char *context)
 | 
			
		||||
		if (!read_from_sslcon)
 | 
			
		||||
			{
 | 
			
		||||
			FD_ZERO(&readfds);
 | 
			
		||||
#ifndef OPENSSL_SYS_WINDOWS
 | 
			
		||||
#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS)
 | 
			
		||||
			FD_SET(fileno(stdin),&readfds);
 | 
			
		||||
#endif
 | 
			
		||||
			FD_SET(s,&readfds);
 | 
			
		||||
@@ -1085,8 +997,8 @@ static int sv_body(char *hostname, int s, unsigned char *context)
 | 
			
		||||
			 * the compiler: if you do have a cast then you can either
 | 
			
		||||
			 * go for (int *) or (void *).
 | 
			
		||||
			 */
 | 
			
		||||
#ifdef OPENSSL_SYS_WINDOWS
 | 
			
		||||
			/* Under Windows we can't select on stdin: only
 | 
			
		||||
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
 | 
			
		||||
                        /* Under DOS (non-djgpp) and Windows we can't select on stdin: only
 | 
			
		||||
			 * on sockets. As a workaround we timeout the select every
 | 
			
		||||
			 * second and check for any keypress. In a proper Windows
 | 
			
		||||
			 * application we wouldn't do this because it is inefficient.
 | 
			
		||||
@@ -1347,7 +1259,13 @@ static int init_ssl_connection(SSL *con)
 | 
			
		||||
	if (SSL_ctrl(con,SSL_CTRL_GET_FLAGS,0,NULL) &
 | 
			
		||||
		TLS1_FLAGS_TLS_PADDING_BUG)
 | 
			
		||||
		BIO_printf(bio_s_out,"Peer has incorrect TLSv1 block padding\n");
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_KRB5
 | 
			
		||||
	if (con->kssl_ctx->client_princ != NULL)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_s_out,"Kerberos peer principal is %s\n",
 | 
			
		||||
			con->kssl_ctx->client_princ);
 | 
			
		||||
		}
 | 
			
		||||
#endif /* OPENSSL_NO_KRB5 */
 | 
			
		||||
	return(1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -62,6 +62,8 @@
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
 | 
			
		||||
#include <openssl/e_os2.h>
 | 
			
		||||
 | 
			
		||||
/* With IPv6, it looks like Digital has mixed up the proper order of
 | 
			
		||||
   recursive header file inclusion, resulting in the compiler complaining
 | 
			
		||||
   that u_int isn't defined, but only if _POSIX_C_SOURCE is defined, which
 | 
			
		||||
@@ -79,14 +81,6 @@ typedef unsigned int u_int;
 | 
			
		||||
#include "s_apps.h"
 | 
			
		||||
#include <openssl/ssl.h>
 | 
			
		||||
 | 
			
		||||
#ifdef FLAT_INC
 | 
			
		||||
#include "e_os.h"
 | 
			
		||||
#else
 | 
			
		||||
#include "../e_os.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_SOCK
 | 
			
		||||
 | 
			
		||||
static struct hostent *GetHostByName(char *name);
 | 
			
		||||
#ifdef OPENSSL_SYS_WINDOWS
 | 
			
		||||
static void ssl_sock_cleanup(void);
 | 
			
		||||
@@ -559,5 +553,3 @@ static struct hostent *GetHostByName(char *name)
 | 
			
		||||
		return(ret);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								apps/smime.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								apps/smime.c
									
									
									
									
									
								
							@@ -1,9 +1,9 @@
 | 
			
		||||
/* smime.c */
 | 
			
		||||
/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
 | 
			
		||||
 * project.
 | 
			
		||||
 * project 1999.
 | 
			
		||||
 */
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright (c) 1999-2003 The OpenSSL Project.  All rights reserved.
 | 
			
		||||
 * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
@@ -482,14 +482,8 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
	if(operation == SMIME_ENCRYPT) {
 | 
			
		||||
		p7 = PKCS7_encrypt(encerts, in, cipher, flags);
 | 
			
		||||
	} else if(operation == SMIME_SIGN) {
 | 
			
		||||
		/* If detached data and SMIME output enable partial
 | 
			
		||||
		 * signing.
 | 
			
		||||
		 */
 | 
			
		||||
		if ((flags & PKCS7_DETACHED) && (outformat == FORMAT_SMIME))
 | 
			
		||||
			flags |= PKCS7_STREAM;
 | 
			
		||||
		p7 = PKCS7_sign(signer, key, other, in, flags);
 | 
			
		||||
		/* Don't need to rewind for partial signing */
 | 
			
		||||
		if (!(flags & PKCS7_STREAM) && (BIO_reset(in) != 0)) {
 | 
			
		||||
		if (BIO_reset(in) != 0 && (flags & PKCS7_DETACHED)) {
 | 
			
		||||
		  BIO_printf(bio_err, "Can't rewind input file\n");
 | 
			
		||||
		  goto end;
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										667
									
								
								apps/speed.c
									
									
									
									
									
								
							
							
						
						
									
										667
									
								
								apps/speed.c
									
									
									
									
									
								
							@@ -55,19 +55,6 @@
 | 
			
		||||
 * copied and put under another distribution licence
 | 
			
		||||
 * [including the GNU Public Licence.]
 | 
			
		||||
 */
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 | 
			
		||||
 *
 | 
			
		||||
 * Portions of the attached software ("Contribution") are developed by 
 | 
			
		||||
 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
 | 
			
		||||
 *
 | 
			
		||||
 * The Contribution is licensed pursuant to the OpenSSL open source
 | 
			
		||||
 * license provided above.
 | 
			
		||||
 *
 | 
			
		||||
 * The ECDH and ECDSA speed test software is originally written by 
 | 
			
		||||
 * Sumit Gupta of Sun Microsystems Laboratories.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* most of this code has been pilfered from my libdes speed.c program */
 | 
			
		||||
 | 
			
		||||
@@ -77,8 +64,6 @@
 | 
			
		||||
#define SECONDS		3	
 | 
			
		||||
#define RSA_SECONDS	10
 | 
			
		||||
#define DSA_SECONDS	10
 | 
			
		||||
#define ECDSA_SECONDS   10
 | 
			
		||||
#define ECDH_SECONDS    10
 | 
			
		||||
 | 
			
		||||
/* 11-Sep-92 Andrew Daviel   Support for Silicon Graphics IRIX added */
 | 
			
		||||
/* 06-Apr-92 Luke Brennan    Support for VMS and add extra signal calls */
 | 
			
		||||
@@ -201,12 +186,6 @@
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
#include "./testdsa.h"
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
#include <openssl/ecdsa.h>
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDH
 | 
			
		||||
#include <openssl/ecdh.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* The following if from times(3) man page.  It may need to be changed */
 | 
			
		||||
#ifndef HZ
 | 
			
		||||
@@ -250,10 +229,6 @@ static int do_multi(int multi);
 | 
			
		||||
#define SIZE_NUM	5
 | 
			
		||||
#define RSA_NUM		4
 | 
			
		||||
#define DSA_NUM		3
 | 
			
		||||
 | 
			
		||||
#define EC_NUM       16
 | 
			
		||||
#define MAX_ECDH_SIZE 256
 | 
			
		||||
 | 
			
		||||
static const char *names[ALGOR_NUM]={
 | 
			
		||||
  "md2","mdc2","md4","md5","hmac(md5)","sha1","rmd160","rc4",
 | 
			
		||||
  "des cbc","des ede3","idea cbc",
 | 
			
		||||
@@ -263,9 +238,6 @@ static double results[ALGOR_NUM][SIZE_NUM];
 | 
			
		||||
static int lengths[SIZE_NUM]={16,64,256,1024,8*1024};
 | 
			
		||||
static double rsa_results[RSA_NUM][2];
 | 
			
		||||
static double dsa_results[DSA_NUM][2];
 | 
			
		||||
static double ecdsa_results[EC_NUM][2];
 | 
			
		||||
static double ecdh_results[EC_NUM][1];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef SIGALRM
 | 
			
		||||
#if defined(__STDC__) || defined(sgi) || defined(_AIX)
 | 
			
		||||
@@ -396,20 +368,6 @@ static double Time_F(int s)
 | 
			
		||||
#endif
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static const int KDF1_SHA1_len = 20;
 | 
			
		||||
static void *KDF1_SHA1(void *in, size_t inlen, void *out, size_t outlen)
 | 
			
		||||
	{
 | 
			
		||||
#ifndef OPENSSL_NO_SHA
 | 
			
		||||
	if (outlen != SHA_DIGEST_LENGTH)
 | 
			
		||||
		return NULL;
 | 
			
		||||
	return SHA1(in, inlen, out);
 | 
			
		||||
#else
 | 
			
		||||
	return NULL;
 | 
			
		||||
#endif
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int MAIN(int, char **);
 | 
			
		||||
 | 
			
		||||
int MAIN(int argc, char **argv)
 | 
			
		||||
@@ -524,24 +482,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
#define	R_RSA_1024	1
 | 
			
		||||
#define	R_RSA_2048	2
 | 
			
		||||
#define	R_RSA_4096	3
 | 
			
		||||
 | 
			
		||||
#define R_EC_P160    0
 | 
			
		||||
#define R_EC_P192    1	
 | 
			
		||||
#define R_EC_P224    2
 | 
			
		||||
#define R_EC_P256    3
 | 
			
		||||
#define R_EC_P384    4
 | 
			
		||||
#define R_EC_P521    5
 | 
			
		||||
#define R_EC_K163    6
 | 
			
		||||
#define R_EC_K233    7
 | 
			
		||||
#define R_EC_K283    8
 | 
			
		||||
#define R_EC_K409    9
 | 
			
		||||
#define R_EC_K571    10
 | 
			
		||||
#define R_EC_B163    11
 | 
			
		||||
#define R_EC_B233    12
 | 
			
		||||
#define R_EC_B283    13
 | 
			
		||||
#define R_EC_B409    14
 | 
			
		||||
#define R_EC_B571    15
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_RSA
 | 
			
		||||
	RSA *rsa_key[RSA_NUM];
 | 
			
		||||
	long rsa_c[RSA_NUM][2];
 | 
			
		||||
@@ -557,83 +497,8 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
	long dsa_c[DSA_NUM][2];
 | 
			
		||||
	static unsigned int dsa_bits[DSA_NUM]={512,1024,2048};
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
	/* We only test over the following curves as they are representative, 
 | 
			
		||||
	 * To add tests over more curves, simply add the curve NID
 | 
			
		||||
	 * and curve name to the following arrays and increase the 
 | 
			
		||||
	 * EC_NUM value accordingly. 
 | 
			
		||||
	 */
 | 
			
		||||
	static unsigned int test_curves[EC_NUM] = 
 | 
			
		||||
	{	
 | 
			
		||||
	/* Prime Curves */
 | 
			
		||||
	NID_secp160r1,
 | 
			
		||||
	NID_X9_62_prime192v1,
 | 
			
		||||
	NID_secp224r1,
 | 
			
		||||
	NID_X9_62_prime256v1,
 | 
			
		||||
	NID_secp384r1,
 | 
			
		||||
	NID_secp521r1,
 | 
			
		||||
	/* Binary Curves */
 | 
			
		||||
	NID_sect163k1,
 | 
			
		||||
	NID_sect233k1,
 | 
			
		||||
	NID_sect283k1,
 | 
			
		||||
	NID_sect409k1,
 | 
			
		||||
	NID_sect571k1,
 | 
			
		||||
	NID_sect163r2,
 | 
			
		||||
	NID_sect233r1,
 | 
			
		||||
	NID_sect283r1,
 | 
			
		||||
	NID_sect409r1,
 | 
			
		||||
	NID_sect571r1
 | 
			
		||||
	}; 
 | 
			
		||||
	static char * test_curves_names[EC_NUM] = 
 | 
			
		||||
	{
 | 
			
		||||
	/* Prime Curves */
 | 
			
		||||
	"secp160r1",
 | 
			
		||||
	"nistp192",
 | 
			
		||||
	"nistp224",
 | 
			
		||||
	"nistp256",
 | 
			
		||||
	"nistp384",
 | 
			
		||||
	"nistp521",
 | 
			
		||||
	/* Binary Curves */
 | 
			
		||||
	"nistk163",
 | 
			
		||||
	"nistk233",
 | 
			
		||||
	"nistk283",
 | 
			
		||||
	"nistk409",
 | 
			
		||||
	"nistk571",
 | 
			
		||||
	"nistb163",
 | 
			
		||||
	"nistb233",
 | 
			
		||||
	"nistb283",
 | 
			
		||||
	"nistb409",
 | 
			
		||||
	"nistb571"
 | 
			
		||||
	};
 | 
			
		||||
	static int test_curves_bits[EC_NUM] =
 | 
			
		||||
        {
 | 
			
		||||
        160, 192, 224, 256, 384, 521,
 | 
			
		||||
        163, 233, 283, 409, 571,
 | 
			
		||||
        163, 233, 283, 409, 571
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
        unsigned char ecdsasig[256];
 | 
			
		||||
        unsigned int ecdsasiglen;
 | 
			
		||||
        EC_KEY *ecdsa[EC_NUM];
 | 
			
		||||
        long ecdsa_c[EC_NUM][2];
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_ECDH
 | 
			
		||||
        EC_KEY *ecdh_a[EC_NUM], *ecdh_b[EC_NUM];
 | 
			
		||||
        unsigned char secret_a[MAX_ECDH_SIZE], secret_b[MAX_ECDH_SIZE];
 | 
			
		||||
        int secret_size_a, secret_size_b;
 | 
			
		||||
        int ecdh_checks = 0;
 | 
			
		||||
        int secret_idx = 0;
 | 
			
		||||
        long ecdh_c[EC_NUM][2];
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	int rsa_doit[RSA_NUM];
 | 
			
		||||
	int dsa_doit[DSA_NUM];
 | 
			
		||||
	int ecdsa_doit[EC_NUM];
 | 
			
		||||
        int ecdh_doit[EC_NUM];
 | 
			
		||||
	int doit[ALGOR_NUM];
 | 
			
		||||
	int pr_header=0;
 | 
			
		||||
	const EVP_CIPHER *evp_cipher=NULL;
 | 
			
		||||
@@ -652,17 +517,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
	memset(dsa_key,0,sizeof(dsa_key));
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
	for (i=0; i<EC_NUM; i++) ecdsa[i] = NULL;
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDH
 | 
			
		||||
	for (i=0; i<EC_NUM; i++)
 | 
			
		||||
		{
 | 
			
		||||
		ecdh_a[i] = NULL;
 | 
			
		||||
		ecdh_b[i] = NULL;
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	if (bio_err == NULL)
 | 
			
		||||
		if ((bio_err=BIO_new(BIO_s_file())) != NULL)
 | 
			
		||||
@@ -701,15 +555,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
		rsa_doit[i]=0;
 | 
			
		||||
	for (i=0; i<DSA_NUM; i++)
 | 
			
		||||
		dsa_doit[i]=0;
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
	for (i=0; i<EC_NUM; i++)
 | 
			
		||||
		ecdsa_doit[i]=0;
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDH
 | 
			
		||||
	for (i=0; i<EC_NUM; i++)
 | 
			
		||||
		ecdh_doit[i]=0;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	j=0;
 | 
			
		||||
	argc--;
 | 
			
		||||
@@ -930,52 +775,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
			dsa_doit[R_DSA_1024]=1;
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
		     if (strcmp(*argv,"ecdsap160") == 0) ecdsa_doit[R_EC_P160]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdsap224") == 0) ecdsa_doit[R_EC_P224]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdsap256") == 0) ecdsa_doit[R_EC_P256]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdsap384") == 0) ecdsa_doit[R_EC_P384]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdsap521") == 0) ecdsa_doit[R_EC_P521]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdsak163") == 0) ecdsa_doit[R_EC_K163]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdsak233") == 0) ecdsa_doit[R_EC_K233]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdsak283") == 0) ecdsa_doit[R_EC_K283]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdsak409") == 0) ecdsa_doit[R_EC_K409]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdsak571") == 0) ecdsa_doit[R_EC_K571]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdsab163") == 0) ecdsa_doit[R_EC_B163]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdsab233") == 0) ecdsa_doit[R_EC_B233]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdsab283") == 0) ecdsa_doit[R_EC_B283]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdsab409") == 0) ecdsa_doit[R_EC_B409]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdsab571") == 0) ecdsa_doit[R_EC_B571]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdsa") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			for (i=0; i < EC_NUM; i++)
 | 
			
		||||
				ecdsa_doit[i]=1;
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDH
 | 
			
		||||
		     if (strcmp(*argv,"ecdhp160") == 0) ecdh_doit[R_EC_P160]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdhp224") == 0) ecdh_doit[R_EC_P224]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdhp256") == 0) ecdh_doit[R_EC_P256]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdhp384") == 0) ecdh_doit[R_EC_P384]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdhp521") == 0) ecdh_doit[R_EC_P521]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdhk163") == 0) ecdh_doit[R_EC_K163]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdhk233") == 0) ecdh_doit[R_EC_K233]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdhk283") == 0) ecdh_doit[R_EC_K283]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdhk409") == 0) ecdh_doit[R_EC_K409]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdhk571") == 0) ecdh_doit[R_EC_K571]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdhb163") == 0) ecdh_doit[R_EC_B163]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdhb233") == 0) ecdh_doit[R_EC_B233]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdhb283") == 0) ecdh_doit[R_EC_B283]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdhb409") == 0) ecdh_doit[R_EC_B409]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdhb571") == 0) ecdh_doit[R_EC_B571]=2;
 | 
			
		||||
		else if (strcmp(*argv,"ecdh") == 0)
 | 
			
		||||
			{
 | 
			
		||||
			for (i=0; i < EC_NUM; i++)
 | 
			
		||||
				ecdh_doit[i]=1;
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
#endif
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,"Error: bad option or value\n");
 | 
			
		||||
@@ -1042,18 +841,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
			BIO_printf(bio_err,"dsa512   dsa1024  dsa2048\n");
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
			BIO_printf(bio_err,"ecdsap160 ecdsap224 ecdsap256 ecdsap384 ecdsap521\n");
 | 
			
		||||
			BIO_printf(bio_err,"ecdsak163 ecdsak233 ecdsak283 ecdsak409 ecdsak571\n");
 | 
			
		||||
			BIO_printf(bio_err,"ecdsab163 ecdsab233 ecdsab283 ecdsab409 ecdsab571\n");
 | 
			
		||||
			BIO_printf(bio_err,"ecdsa\n");
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDH
 | 
			
		||||
			BIO_printf(bio_err,"ecdhp160  ecdhp224  ecdhp256  ecdhp384  ecdhp521\n");
 | 
			
		||||
			BIO_printf(bio_err,"ecdhk163  ecdhk233  ecdhk283  ecdhk409  ecdhk571\n");
 | 
			
		||||
			BIO_printf(bio_err,"ecdhb163  ecdhb233  ecdhb283  ecdhb409  ecdhb571\n");
 | 
			
		||||
			BIO_printf(bio_err,"ecdh\n");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_IDEA
 | 
			
		||||
			BIO_printf(bio_err,"idea     ");
 | 
			
		||||
@@ -1285,114 +1072,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
	ecdsa_c[R_EC_P160][0]=count/1000;
 | 
			
		||||
	ecdsa_c[R_EC_P160][1]=count/1000/2;
 | 
			
		||||
	for (i=R_EC_P224; i<=R_EC_P521; i++)
 | 
			
		||||
		{
 | 
			
		||||
		ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
 | 
			
		||||
		ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
 | 
			
		||||
		if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
 | 
			
		||||
			ecdsa_doit[i]=0;
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			if (ecdsa_c[i] == 0)
 | 
			
		||||
				{
 | 
			
		||||
				ecdsa_c[i][0]=1;
 | 
			
		||||
				ecdsa_c[i][1]=1;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	ecdsa_c[R_EC_K163][0]=count/1000;
 | 
			
		||||
	ecdsa_c[R_EC_K163][1]=count/1000/2;
 | 
			
		||||
	for (i=R_EC_K233; i<=R_EC_K571; i++)
 | 
			
		||||
		{
 | 
			
		||||
		ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
 | 
			
		||||
		ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
 | 
			
		||||
		if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
 | 
			
		||||
			ecdsa_doit[i]=0;
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			if (ecdsa_c[i] == 0)
 | 
			
		||||
				{
 | 
			
		||||
				ecdsa_c[i][0]=1;
 | 
			
		||||
				ecdsa_c[i][1]=1;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	ecdsa_c[R_EC_B163][0]=count/1000;
 | 
			
		||||
	ecdsa_c[R_EC_B163][1]=count/1000/2;
 | 
			
		||||
	for (i=R_EC_B233; i<=R_EC_B571; i++)
 | 
			
		||||
		{
 | 
			
		||||
		ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
 | 
			
		||||
		ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
 | 
			
		||||
		if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
 | 
			
		||||
			ecdsa_doit[i]=0;
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			if (ecdsa_c[i] == 0)
 | 
			
		||||
				{
 | 
			
		||||
				ecdsa_c[i][0]=1;
 | 
			
		||||
				ecdsa_c[i][1]=1;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_ECDH
 | 
			
		||||
	ecdh_c[R_EC_P160][0]=count/1000;
 | 
			
		||||
	ecdh_c[R_EC_P160][1]=count/1000;
 | 
			
		||||
	for (i=R_EC_P224; i<=R_EC_P521; i++)
 | 
			
		||||
		{
 | 
			
		||||
		ecdh_c[i][0]=ecdh_c[i-1][0]/2;
 | 
			
		||||
		ecdh_c[i][1]=ecdh_c[i-1][1]/2;
 | 
			
		||||
		if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
 | 
			
		||||
			ecdh_doit[i]=0;
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			if (ecdh_c[i] == 0)
 | 
			
		||||
				{
 | 
			
		||||
				ecdh_c[i][0]=1;
 | 
			
		||||
				ecdh_c[i][1]=1;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	ecdh_c[R_EC_K163][0]=count/1000;
 | 
			
		||||
	ecdh_c[R_EC_K163][1]=count/1000;
 | 
			
		||||
	for (i=R_EC_K233; i<=R_EC_K571; i++)
 | 
			
		||||
		{
 | 
			
		||||
		ecdh_c[i][0]=ecdh_c[i-1][0]/2;
 | 
			
		||||
		ecdh_c[i][1]=ecdh_c[i-1][1]/2;
 | 
			
		||||
		if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
 | 
			
		||||
			ecdh_doit[i]=0;
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			if (ecdh_c[i] == 0)
 | 
			
		||||
				{
 | 
			
		||||
				ecdh_c[i][0]=1;
 | 
			
		||||
				ecdh_c[i][1]=1;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	ecdh_c[R_EC_B163][0]=count/1000;
 | 
			
		||||
	ecdh_c[R_EC_B163][1]=count/1000;
 | 
			
		||||
	for (i=R_EC_B233; i<=R_EC_B571; i++)
 | 
			
		||||
		{
 | 
			
		||||
		ecdh_c[i][0]=ecdh_c[i-1][0]/2;
 | 
			
		||||
		ecdh_c[i][1]=ecdh_c[i-1][1]/2;
 | 
			
		||||
		if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
 | 
			
		||||
			ecdh_doit[i]=0;
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			if (ecdh_c[i] == 0)
 | 
			
		||||
				{
 | 
			
		||||
				ecdh_c[i][0]=1;
 | 
			
		||||
				ecdh_c[i][1]=1;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define COND(d)	(count < (d))
 | 
			
		||||
#define COUNT(d) (d)
 | 
			
		||||
#else
 | 
			
		||||
@@ -1918,239 +1597,6 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
		}
 | 
			
		||||
	if (rnd_fake) RAND_cleanup();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
	if (RAND_status() != 1) 
 | 
			
		||||
		{
 | 
			
		||||
		RAND_seed(rnd_seed, sizeof rnd_seed);
 | 
			
		||||
		rnd_fake = 1;
 | 
			
		||||
		}
 | 
			
		||||
	for (j=0; j<EC_NUM; j++) 
 | 
			
		||||
		{
 | 
			
		||||
		int ret;
 | 
			
		||||
 | 
			
		||||
		if (!ecdsa_doit[j]) continue; /* Ignore Curve */ 
 | 
			
		||||
		ecdsa[j] = EC_KEY_new();
 | 
			
		||||
		if (ecdsa[j] == NULL) 
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,"ECDSA failure.\n");
 | 
			
		||||
			ERR_print_errors(bio_err);
 | 
			
		||||
			rsa_count=1;
 | 
			
		||||
			} 
 | 
			
		||||
		else 
 | 
			
		||||
			{
 | 
			
		||||
			ecdsa[j]->group = EC_GROUP_new_by_nid(test_curves[j]);
 | 
			
		||||
			/* Could not obtain group information */
 | 
			
		||||
			if (ecdsa[j]->group == NULL) 
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err,"ECDSA failure.Could not obtain group information\n");
 | 
			
		||||
				ERR_print_errors(bio_err);
 | 
			
		||||
				rsa_count=1;
 | 
			
		||||
				} 
 | 
			
		||||
			else 
 | 
			
		||||
				{
 | 
			
		||||
#if 1
 | 
			
		||||
				EC_GROUP_precompute_mult(ecdsa[j]->group, NULL);
 | 
			
		||||
#endif
 | 
			
		||||
				/* Perform ECDSA signature test */
 | 
			
		||||
				EC_KEY_generate_key(ecdsa[j]);
 | 
			
		||||
				ret = ECDSA_sign(0, buf, 20, ecdsasig, 
 | 
			
		||||
					&ecdsasiglen, ecdsa[j]);
 | 
			
		||||
				if (ret == 0) 
 | 
			
		||||
					{
 | 
			
		||||
					BIO_printf(bio_err,"ECDSA sign failure.  No ECDSA sign will be done.\n");
 | 
			
		||||
					ERR_print_errors(bio_err);
 | 
			
		||||
					rsa_count=1;
 | 
			
		||||
					} 
 | 
			
		||||
				else 
 | 
			
		||||
					{
 | 
			
		||||
					pkey_print_message("sign","ecdsa",
 | 
			
		||||
						ecdsa_c[j][0], 
 | 
			
		||||
						test_curves_bits[j],
 | 
			
		||||
						ECDSA_SECONDS);
 | 
			
		||||
 | 
			
		||||
					Time_F(START);
 | 
			
		||||
					for (count=0,run=1; COND(ecdsa_c[j][0]);
 | 
			
		||||
						count++) 
 | 
			
		||||
						{
 | 
			
		||||
						ret=ECDSA_sign(0, buf, 20, 
 | 
			
		||||
							ecdsasig, &ecdsasiglen,
 | 
			
		||||
							ecdsa[j]);
 | 
			
		||||
						if (ret == 0) 
 | 
			
		||||
							{
 | 
			
		||||
							BIO_printf(bio_err, "ECDSA sign failure\n");
 | 
			
		||||
							ERR_print_errors(bio_err);
 | 
			
		||||
							count=1;
 | 
			
		||||
							break;
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
						d=Time_F(STOP);
 | 
			
		||||
 | 
			
		||||
						BIO_printf(bio_err, mr ? "+R5:%ld:%d:%.2f\n" :
 | 
			
		||||
						"%ld %d bit ECDSA signs in %.2fs \n", 
 | 
			
		||||
						count, test_curves_bits[j], d);
 | 
			
		||||
						ecdsa_results[j][0]=d/(double)count;
 | 
			
		||||
						rsa_count=count;
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
				/* Perform ECDSA verification test */
 | 
			
		||||
				ret=ECDSA_verify(0, buf, 20, ecdsasig, 
 | 
			
		||||
					ecdsasiglen, ecdsa[j]);
 | 
			
		||||
				if (ret != 1) 
 | 
			
		||||
					{
 | 
			
		||||
					BIO_printf(bio_err,"ECDSA verify failure.  No ECDSA verify will be done.\n");
 | 
			
		||||
					ERR_print_errors(bio_err);
 | 
			
		||||
					ecdsa_doit[j] = 0;
 | 
			
		||||
					} 
 | 
			
		||||
				else 
 | 
			
		||||
					{
 | 
			
		||||
					pkey_print_message("verify","ecdsa",
 | 
			
		||||
					ecdsa_c[j][1],
 | 
			
		||||
					test_curves_bits[j],
 | 
			
		||||
					ECDSA_SECONDS);
 | 
			
		||||
					Time_F(START);
 | 
			
		||||
					for (count=0,run=1; COND(ecdsa_c[j][1]); count++) 
 | 
			
		||||
						{
 | 
			
		||||
						ret=ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]);
 | 
			
		||||
						if (ret != 1) 
 | 
			
		||||
							{
 | 
			
		||||
							BIO_printf(bio_err, "ECDSA verify failure\n");
 | 
			
		||||
							ERR_print_errors(bio_err);
 | 
			
		||||
							count=1;
 | 
			
		||||
							break;
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
						d=Time_F(STOP);
 | 
			
		||||
						BIO_printf(bio_err, mr? "+R6:%ld:%d:%.2f\n"
 | 
			
		||||
							: "%ld %d bit ECDSA verify in %.2fs\n",
 | 
			
		||||
						count, test_curves_bits[j], d);
 | 
			
		||||
						ecdsa_results[j][1]=d/(double)count;
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
				if (rsa_count <= 1) 
 | 
			
		||||
					{
 | 
			
		||||
					/* if longer than 10s, don't do any more */
 | 
			
		||||
					for (j++; j<EC_NUM; j++)
 | 
			
		||||
					ecdsa_doit[j]=0;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	if (rnd_fake) RAND_cleanup();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_ECDH
 | 
			
		||||
	if (RAND_status() != 1)
 | 
			
		||||
		{
 | 
			
		||||
		RAND_seed(rnd_seed, sizeof rnd_seed);
 | 
			
		||||
		rnd_fake = 1;
 | 
			
		||||
		}
 | 
			
		||||
	for (j=0; j<EC_NUM; j++)
 | 
			
		||||
		{
 | 
			
		||||
		if (!ecdh_doit[j]) continue;
 | 
			
		||||
		ecdh_a[j] = EC_KEY_new();
 | 
			
		||||
		ecdh_b[j] = EC_KEY_new();
 | 
			
		||||
		if ((ecdh_a[j] == NULL) || (ecdh_b[j] == NULL))
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,"ECDH failure.\n");
 | 
			
		||||
			ERR_print_errors(bio_err);
 | 
			
		||||
			rsa_count=1;
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			ecdh_a[j]->group = EC_GROUP_new_by_nid(test_curves[j]);
 | 
			
		||||
			if (ecdh_a[j]->group == NULL)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err,"ECDH failure.\n");
 | 
			
		||||
				ERR_print_errors(bio_err);
 | 
			
		||||
				rsa_count=1;
 | 
			
		||||
				}
 | 
			
		||||
			else
 | 
			
		||||
				{
 | 
			
		||||
				ecdh_b[j]->group = EC_GROUP_dup(ecdh_a[j]->group);
 | 
			
		||||
 | 
			
		||||
				/* generate two ECDH key pairs */
 | 
			
		||||
				if (!EC_KEY_generate_key(ecdh_a[j]) ||
 | 
			
		||||
					!EC_KEY_generate_key(ecdh_b[j]))
 | 
			
		||||
					{
 | 
			
		||||
					BIO_printf(bio_err,"ECDH key generation failure.\n");
 | 
			
		||||
					ERR_print_errors(bio_err);
 | 
			
		||||
					rsa_count=1;		
 | 
			
		||||
					}
 | 
			
		||||
				else
 | 
			
		||||
					{
 | 
			
		||||
					/* If field size is not more than 24 octets, then use SHA-1 hash of result;
 | 
			
		||||
					 * otherwise, use result (see section 4.8 of draft-ietf-tls-ecc-03.txt).
 | 
			
		||||
					 */
 | 
			
		||||
					int field_size, outlen;
 | 
			
		||||
					void *(*kdf)(void *in, size_t inlen, void *out, size_t outlen);
 | 
			
		||||
					field_size = EC_GROUP_get_degree(ecdh_a[j]->group);
 | 
			
		||||
					if (field_size <= 24 * 8)
 | 
			
		||||
						{
 | 
			
		||||
						outlen = KDF1_SHA1_len;
 | 
			
		||||
						kdf = KDF1_SHA1;
 | 
			
		||||
						}
 | 
			
		||||
					else
 | 
			
		||||
						{
 | 
			
		||||
						outlen = (field_size+7)/8;
 | 
			
		||||
						kdf = NULL;
 | 
			
		||||
						}
 | 
			
		||||
					secret_size_a = ECDH_compute_key(secret_a, outlen,
 | 
			
		||||
						ecdh_b[j]->pub_key,
 | 
			
		||||
						ecdh_a[j], kdf);
 | 
			
		||||
					secret_size_b = ECDH_compute_key(secret_b, outlen,
 | 
			
		||||
						ecdh_a[j]->pub_key,
 | 
			
		||||
						ecdh_b[j], kdf);
 | 
			
		||||
					if (secret_size_a != secret_size_b) 
 | 
			
		||||
						ecdh_checks = 0;
 | 
			
		||||
					else
 | 
			
		||||
						ecdh_checks = 1;
 | 
			
		||||
 | 
			
		||||
					for (secret_idx = 0; 
 | 
			
		||||
					    (secret_idx < secret_size_a)
 | 
			
		||||
						&& (ecdh_checks == 1);
 | 
			
		||||
					    secret_idx++)
 | 
			
		||||
						{
 | 
			
		||||
						if (secret_a[secret_idx] != secret_b[secret_idx])
 | 
			
		||||
						ecdh_checks = 0;
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
					if (ecdh_checks == 0)
 | 
			
		||||
						{
 | 
			
		||||
						BIO_printf(bio_err,"ECDH computations don't match.\n");
 | 
			
		||||
						ERR_print_errors(bio_err);
 | 
			
		||||
						rsa_count=1;		
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
					pkey_print_message("","ecdh",
 | 
			
		||||
					ecdh_c[j][0], 
 | 
			
		||||
					test_curves_bits[j],
 | 
			
		||||
					ECDH_SECONDS);
 | 
			
		||||
					Time_F(START);
 | 
			
		||||
					for (count=0,run=1; COND(ecdh_c[j][0]); count++)
 | 
			
		||||
						{
 | 
			
		||||
						ECDH_compute_key(secret_a, outlen,
 | 
			
		||||
						ecdh_b[j]->pub_key,
 | 
			
		||||
						ecdh_a[j], kdf);
 | 
			
		||||
						}
 | 
			
		||||
					d=Time_F(STOP);
 | 
			
		||||
					BIO_printf(bio_err, mr ? "+R7:%ld:%d:%.2f\n" :"%ld %d-bit ECDH ops in %.2fs\n",
 | 
			
		||||
					count, test_curves_bits[j], d);
 | 
			
		||||
					ecdh_results[j][0]=d/(double)count;
 | 
			
		||||
					rsa_count=count;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		if (rsa_count <= 1)
 | 
			
		||||
			{
 | 
			
		||||
			/* if longer than 10s, don't do any more */
 | 
			
		||||
			for (j++; j<EC_NUM; j++)
 | 
			
		||||
			ecdh_doit[j]=0;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	if (rnd_fake) RAND_cleanup();
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef HAVE_FORK
 | 
			
		||||
show_res:
 | 
			
		||||
#endif
 | 
			
		||||
@@ -2276,57 +1722,7 @@ show_res:
 | 
			
		||||
				1.0/dsa_results[k][0],1.0/dsa_results[k][1]);
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
	j=1;
 | 
			
		||||
	for (k=0; k<EC_NUM; k++)
 | 
			
		||||
		{
 | 
			
		||||
		if (!ecdsa_doit[k]) continue;
 | 
			
		||||
		if (j && !mr)
 | 
			
		||||
			{
 | 
			
		||||
			printf("%30ssign    verify    sign/s verify/s\n"," ");
 | 
			
		||||
			j=0;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		if (mr)
 | 
			
		||||
			fprintf(stdout,"+F4:%u:%u:%f:%f\n", 
 | 
			
		||||
				k, test_curves_bits[k],
 | 
			
		||||
				ecdsa_results[k][0],ecdsa_results[k][1]);
 | 
			
		||||
		else
 | 
			
		||||
			fprintf(stdout,
 | 
			
		||||
				"%4u bit ecdsa (%s) %8.4fs %8.4fs %8.1f %8.1f\n", 
 | 
			
		||||
				test_curves_bits[k],
 | 
			
		||||
				test_curves_names[k],
 | 
			
		||||
				ecdsa_results[k][0],ecdsa_results[k][1], 
 | 
			
		||||
				1.0/ecdsa_results[k][0],1.0/ecdsa_results[k][1]);
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_ECDH
 | 
			
		||||
	j=1;
 | 
			
		||||
	for (k=0; k<EC_NUM; k++)
 | 
			
		||||
		{
 | 
			
		||||
		if (!ecdh_doit[k]) continue;
 | 
			
		||||
		if (j && !mr)
 | 
			
		||||
			{
 | 
			
		||||
			printf("%30sop      op/s\n"," ");
 | 
			
		||||
			j=0;
 | 
			
		||||
			}
 | 
			
		||||
		if (mr)
 | 
			
		||||
			fprintf(stdout,"+F5:%u:%u:%f:%f\n",
 | 
			
		||||
				k, test_curves_bits[k],
 | 
			
		||||
				ecdh_results[k][0], 1.0/ecdh_results[k][0]);
 | 
			
		||||
 | 
			
		||||
		else
 | 
			
		||||
			fprintf(stdout,"%4u bit ecdh (%s) %8.4fs %8.1f\n",
 | 
			
		||||
				test_curves_bits[k],
 | 
			
		||||
				test_curves_names[k],
 | 
			
		||||
				ecdh_results[k][0], 1.0/ecdh_results[k][0]);
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	mret=0;
 | 
			
		||||
 | 
			
		||||
end:
 | 
			
		||||
	ERR_print_errors(bio_err);
 | 
			
		||||
	if (buf != NULL) OPENSSL_free(buf);
 | 
			
		||||
@@ -2341,22 +1737,6 @@ end:
 | 
			
		||||
		if (dsa_key[i] != NULL)
 | 
			
		||||
			DSA_free(dsa_key[i]);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
	for (i=0; i<EC_NUM; i++)
 | 
			
		||||
		if (ecdsa[i] != NULL)
 | 
			
		||||
			EC_KEY_free(ecdsa[i]);
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDH
 | 
			
		||||
	for (i=0; i<EC_NUM; i++)
 | 
			
		||||
	{
 | 
			
		||||
		if (ecdh_a[i] != NULL)
 | 
			
		||||
			EC_KEY_free(ecdh_a[i]);
 | 
			
		||||
		if (ecdh_b[i] != NULL)
 | 
			
		||||
			EC_KEY_free(ecdh_b[i]);
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	apps_shutdown();
 | 
			
		||||
	OPENSSL_EXIT(mret);
 | 
			
		||||
	}
 | 
			
		||||
@@ -2398,8 +1778,8 @@ static void pkey_print_message(char *str, char *str2, long num, int bits,
 | 
			
		||||
 | 
			
		||||
static void print_result(int alg,int run_no,int count,double time_used)
 | 
			
		||||
	{
 | 
			
		||||
	BIO_printf(bio_err,mr ? "+R:%d:%s:%f\n"
 | 
			
		||||
		   : "%d %s's in %.2fs\n",count,names[alg],time_used);
 | 
			
		||||
	BIO_printf(bio_err,mr ? "+R:%ld:%s:%f\n"
 | 
			
		||||
		   : "%ld %s's in %.2fs\n",count,names[alg],time_used);
 | 
			
		||||
	results[alg][run_no]=((double)count)/time_used*lengths[run_no];
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -2558,49 +1938,6 @@ static int do_multi(int multi)
 | 
			
		||||
				else
 | 
			
		||||
					dsa_results[k][1]=d;
 | 
			
		||||
				}
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
			else if(!strncmp(buf,"+F4:",4))
 | 
			
		||||
				{
 | 
			
		||||
				int k;
 | 
			
		||||
				double d;
 | 
			
		||||
				
 | 
			
		||||
				p=buf+4;
 | 
			
		||||
				k=atoi(sstrsep(&p,sep));
 | 
			
		||||
				sstrsep(&p,sep);
 | 
			
		||||
 | 
			
		||||
				d=atof(sstrsep(&p,sep));
 | 
			
		||||
				if(n)
 | 
			
		||||
					ecdsa_results[k][0]=1/(1/ecdsa_results[k][0]+1/d);
 | 
			
		||||
				else
 | 
			
		||||
					ecdsa_results[k][0]=d;
 | 
			
		||||
 | 
			
		||||
				d=atof(sstrsep(&p,sep));
 | 
			
		||||
				if(n)
 | 
			
		||||
					ecdsa_results[k][1]=1/(1/ecdsa_results[k][1]+1/d);
 | 
			
		||||
				else
 | 
			
		||||
					ecdsa_results[k][1]=d;
 | 
			
		||||
				}
 | 
			
		||||
#endif 
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_ECDH
 | 
			
		||||
			else if(!strncmp(buf,"+F5:",4))
 | 
			
		||||
				{
 | 
			
		||||
				int k;
 | 
			
		||||
				double d;
 | 
			
		||||
				
 | 
			
		||||
				p=buf+4;
 | 
			
		||||
				k=atoi(sstrsep(&p,sep));
 | 
			
		||||
				sstrsep(&p,sep);
 | 
			
		||||
 | 
			
		||||
				d=atof(sstrsep(&p,sep));
 | 
			
		||||
				if(n)
 | 
			
		||||
					ecdh_results[k][0]=1/(1/ecdh_results[k][0]+1/d);
 | 
			
		||||
				else
 | 
			
		||||
					ecdh_results[k][0]=d;
 | 
			
		||||
 | 
			
		||||
				}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
			else if(!strncmp(buf,"+H:",3))
 | 
			
		||||
				{
 | 
			
		||||
				}
 | 
			
		||||
 
 | 
			
		||||
@@ -172,19 +172,7 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (version)
 | 
			
		||||
		{
 | 
			
		||||
		if (SSLeay() == SSLEAY_VERSION_NUMBER)
 | 
			
		||||
			{
 | 
			
		||||
			printf("%s\n",SSLeay_version(SSLEAY_VERSION));
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			printf("%s (Library: %s)\n",
 | 
			
		||||
				OPENSSL_VERSION_TEXT,
 | 
			
		||||
				SSLeay_version(SSLEAY_VERSION));
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	if (version) printf("%s\n",SSLeay_version(SSLEAY_VERSION));
 | 
			
		||||
	if (date)    printf("%s\n",SSLeay_version(SSLEAY_BUILT_ON));
 | 
			
		||||
	if (platform) printf("%s\n",SSLeay_version(SSLEAY_PLATFORM));
 | 
			
		||||
	if (options) 
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										112
									
								
								apps/x509.c
									
									
									
									
									
								
							
							
						
						
									
										112
									
								
								apps/x509.c
									
									
									
									
									
								
							@@ -92,9 +92,7 @@ static char *x509_usage[]={
 | 
			
		||||
" -out arg        - output file - default stdout\n",
 | 
			
		||||
" -passin arg     - private key password source\n",
 | 
			
		||||
" -serial         - print serial number value\n",
 | 
			
		||||
" -subject_hash   - print subject hash value\n",
 | 
			
		||||
" -issuer_hash    - print issuer hash value\n",
 | 
			
		||||
" -hash           - synonym for -subject_hash\n",
 | 
			
		||||
" -hash           - print hash value\n",
 | 
			
		||||
" -subject        - print subject DN\n",
 | 
			
		||||
" -issuer         - print issuer DN\n",
 | 
			
		||||
" -email          - print email address(es)\n",
 | 
			
		||||
@@ -169,8 +167,8 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
	char *infile=NULL,*outfile=NULL,*keyfile=NULL,*CAfile=NULL;
 | 
			
		||||
	char *CAkeyfile=NULL,*CAserial=NULL;
 | 
			
		||||
	char *alias=NULL;
 | 
			
		||||
	int text=0,serial=0,subject=0,issuer=0,startdate=0,enddate=0;
 | 
			
		||||
	int subject_hash=0,issuer_hash=0,ocspid=0;
 | 
			
		||||
	int text=0,serial=0,hash=0,subject=0,issuer=0,startdate=0,enddate=0;
 | 
			
		||||
	int ocspid=0;
 | 
			
		||||
	int noout=0,sign_flag=0,CA_flag=0,CA_createserial=0,email=0;
 | 
			
		||||
	int trustout=0,clrtrust=0,clrreject=0,aliasout=0,clrext=0;
 | 
			
		||||
	int C=0;
 | 
			
		||||
@@ -381,11 +379,8 @@ int MAIN(int argc, char **argv)
 | 
			
		||||
			x509req= ++num;
 | 
			
		||||
		else if (strcmp(*argv,"-text") == 0)
 | 
			
		||||
			text= ++num;
 | 
			
		||||
		else if (strcmp(*argv,"-hash") == 0
 | 
			
		||||
			|| strcmp(*argv,"-subject_hash") == 0)
 | 
			
		||||
			subject_hash= ++num;
 | 
			
		||||
		else if (strcmp(*argv,"-issuer_hash") == 0)
 | 
			
		||||
			issuer_hash= ++num;
 | 
			
		||||
		else if (strcmp(*argv,"-hash") == 0)
 | 
			
		||||
			hash= ++num;
 | 
			
		||||
		else if (strcmp(*argv,"-subject") == 0)
 | 
			
		||||
			subject= ++num;
 | 
			
		||||
		else if (strcmp(*argv,"-issuer") == 0)
 | 
			
		||||
@@ -712,14 +707,10 @@ bad:
 | 
			
		||||
				if (alstr) BIO_printf(STDout,"%s\n", alstr);
 | 
			
		||||
				else BIO_puts(STDout,"<No Alias>\n");
 | 
			
		||||
				}
 | 
			
		||||
			else if (subject_hash == i)
 | 
			
		||||
			else if (hash == i)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(STDout,"%08lx\n",X509_subject_name_hash(x));
 | 
			
		||||
				}
 | 
			
		||||
			else if (issuer_hash == i)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(STDout,"%08lx\n",X509_issuer_name_hash(x));
 | 
			
		||||
				}
 | 
			
		||||
			else if (pprint == i)
 | 
			
		||||
				{
 | 
			
		||||
				X509_PURPOSE *ptmp;
 | 
			
		||||
@@ -881,10 +872,6 @@ bad:
 | 
			
		||||
		                if (Upkey->type == EVP_PKEY_DSA)
 | 
			
		||||
		                        digest=EVP_dss1();
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
				if (Upkey->type == EVP_PKEY_EC)
 | 
			
		||||
					digest=EVP_ecdsa();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
				assert(need_rand);
 | 
			
		||||
				if (!sign(x,Upkey,days,clrext,digest,
 | 
			
		||||
@@ -905,10 +892,6 @@ bad:
 | 
			
		||||
		                if (CApkey->type == EVP_PKEY_DSA)
 | 
			
		||||
		                        digest=EVP_dss1();
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
				if (CApkey->type == EVP_PKEY_EC)
 | 
			
		||||
					digest = EVP_ecdsa();
 | 
			
		||||
#endif
 | 
			
		||||
				
 | 
			
		||||
				assert(need_rand);
 | 
			
		||||
				if (!x509_certify(ctx,CAfile,digest,x,xca,
 | 
			
		||||
@@ -940,10 +923,6 @@ bad:
 | 
			
		||||
		                if (pk->type == EVP_PKEY_DSA)
 | 
			
		||||
		                        digest=EVP_dss1();
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_ECDSA
 | 
			
		||||
				if (pk->type == EVP_PKEY_EC)
 | 
			
		||||
					digest=EVP_ecdsa();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
				rq=X509_to_X509_REQ(x,pk,digest);
 | 
			
		||||
				EVP_PKEY_free(pk);
 | 
			
		||||
@@ -1043,10 +1022,12 @@ end:
 | 
			
		||||
	OPENSSL_EXIT(ret);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static ASN1_INTEGER *x509_load_serial(char *CAfile, char *serialfile, int create)
 | 
			
		||||
static ASN1_INTEGER *load_serial(char *CAfile, char *serialfile, int create)
 | 
			
		||||
	{
 | 
			
		||||
	char *buf = NULL, *p;
 | 
			
		||||
	ASN1_INTEGER *bs = NULL;
 | 
			
		||||
	MS_STATIC char buf2[1024];
 | 
			
		||||
	ASN1_INTEGER *bs = NULL, *bs2 = NULL;
 | 
			
		||||
	BIO *io = NULL;
 | 
			
		||||
	BIGNUM *serial = NULL;
 | 
			
		||||
 | 
			
		||||
	buf=OPENSSL_malloc( ((serialfile == NULL)
 | 
			
		||||
@@ -1066,19 +1047,80 @@ static ASN1_INTEGER *x509_load_serial(char *CAfile, char *serialfile, int create
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		strcpy(buf,serialfile);
 | 
			
		||||
	serial=BN_new();
 | 
			
		||||
	bs=ASN1_INTEGER_new();
 | 
			
		||||
	if ((serial == NULL) || (bs == NULL))
 | 
			
		||||
		{
 | 
			
		||||
		ERR_print_errors(bio_err);
 | 
			
		||||
		goto end;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	serial = load_serial(buf, create, NULL);
 | 
			
		||||
	if (serial == NULL) goto end;
 | 
			
		||||
	io=BIO_new(BIO_s_file());
 | 
			
		||||
	if (io == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		ERR_print_errors(bio_err);
 | 
			
		||||
		goto end;
 | 
			
		||||
		}
 | 
			
		||||
	
 | 
			
		||||
	if (BIO_read_filename(io,buf) <= 0)
 | 
			
		||||
		{
 | 
			
		||||
		if (!create)
 | 
			
		||||
			{
 | 
			
		||||
			perror(buf);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			ASN1_INTEGER_set(bs,1);
 | 
			
		||||
			BN_one(serial);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	else 
 | 
			
		||||
		{
 | 
			
		||||
		if (!a2i_ASN1_INTEGER(io,bs,buf2,sizeof buf2))
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bio_err,"unable to load serial number from %s\n",buf);
 | 
			
		||||
			ERR_print_errors(bio_err);
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			serial=BN_bin2bn(bs->data,bs->length,serial);
 | 
			
		||||
			if (serial == NULL)
 | 
			
		||||
				{
 | 
			
		||||
				BIO_printf(bio_err,"error converting bin 2 bn");
 | 
			
		||||
				goto end;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (!BN_add_word(serial,1))
 | 
			
		||||
		{ BIO_printf(bio_err,"add_word failure\n"); goto end; }
 | 
			
		||||
	if (!(bs2 = BN_to_ASN1_INTEGER(serial, NULL)))
 | 
			
		||||
		{ BIO_printf(bio_err,"error converting bn 2 asn1_integer\n"); goto end; }
 | 
			
		||||
	if (BIO_write_filename(io,buf) <= 0)
 | 
			
		||||
		{
 | 
			
		||||
		BIO_printf(bio_err,"error attempting to write serial number file\n");
 | 
			
		||||
		perror(buf);
 | 
			
		||||
		goto end;
 | 
			
		||||
		}
 | 
			
		||||
	i2a_ASN1_INTEGER(io,bs2);
 | 
			
		||||
	BIO_puts(io,"\n");
 | 
			
		||||
 | 
			
		||||
	if (!save_serial(buf, NULL, serial, &bs)) goto end;
 | 
			
		||||
	BIO_free(io);
 | 
			
		||||
	if (buf) OPENSSL_free(buf);
 | 
			
		||||
	ASN1_INTEGER_free(bs2);
 | 
			
		||||
	BN_free(serial);
 | 
			
		||||
	io=NULL;
 | 
			
		||||
	return bs;
 | 
			
		||||
 | 
			
		||||
	end:
 | 
			
		||||
	if (buf) OPENSSL_free(buf);
 | 
			
		||||
	BIO_free(io);
 | 
			
		||||
	ASN1_INTEGER_free(bs);
 | 
			
		||||
	BN_free(serial);
 | 
			
		||||
	return bs;
 | 
			
		||||
	return NULL;
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
 | 
			
		||||
@@ -1100,10 +1142,10 @@ static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
 | 
			
		||||
		goto end;
 | 
			
		||||
		}
 | 
			
		||||
	if (sno) bs = sno;
 | 
			
		||||
	else if (!(bs = x509_load_serial(CAfile, serialfile, create)))
 | 
			
		||||
	else if (!(bs = load_serial(CAfile, serialfile, create)))
 | 
			
		||||
		goto end;
 | 
			
		||||
 | 
			
		||||
	if (!X509_STORE_add_cert(ctx,x)) goto end;
 | 
			
		||||
/*	if (!X509_STORE_add_cert(ctx,x)) goto end;*/
 | 
			
		||||
 | 
			
		||||
	/* NOTE: this certificate can/should be self signed, unless it was
 | 
			
		||||
	 * a certificate request in which case it is not. */
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								config
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								config
									
									
									
									
									
								
							@@ -81,7 +81,7 @@ if [ "x$XREL" != "x" ]; then
 | 
			
		||||
		esac
 | 
			
		||||
		;;
 | 
			
		||||
	    4.2)
 | 
			
		||||
		echo "whatever-whatever-unixware1"; exit 0
 | 
			
		||||
		echo "i386-whatever-unixware1"; exit 0
 | 
			
		||||
		;;
 | 
			
		||||
	    5)
 | 
			
		||||
		case "x${VERSION}" in
 | 
			
		||||
@@ -700,7 +700,7 @@ EOF
 | 
			
		||||
	if   [ $CPU_VERSION -ge 768 ]; then	# IA-64 CPU
 | 
			
		||||
	     echo "WARNING! 64-bit ABI is the default configured ABI on HP-UXi."
 | 
			
		||||
	     echo "         If you wish to build 32-bit library, the you have to"
 | 
			
		||||
	     echo "         invoke './Configure hpux-ia64-cc' *manually*."
 | 
			
		||||
	     echo "         invoke './Configure hpux-ia32-cc' *manually*."
 | 
			
		||||
	     if [ "$TEST" = "false" ]; then
 | 
			
		||||
		echo "         You have about 5 seconds to press Ctrl-C to abort."
 | 
			
		||||
		(stty -icanon min 0 time 50; read waste) < /dev/tty
 | 
			
		||||
 
 | 
			
		||||
@@ -28,17 +28,16 @@ LIBS=
 | 
			
		||||
 | 
			
		||||
SDIRS=	md2 md5 sha mdc2 hmac ripemd \
 | 
			
		||||
	des rc2 rc4 rc5 idea bf cast \
 | 
			
		||||
	bn ec rsa dsa ecdsa ecdh dh dso engine aes \
 | 
			
		||||
	bn ec rsa dsa dh dso engine aes \
 | 
			
		||||
	buffer bio stack lhash rand err objects \
 | 
			
		||||
	evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 \
 | 
			
		||||
	store
 | 
			
		||||
	evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5
 | 
			
		||||
 | 
			
		||||
GENERAL=Makefile README crypto-lib.com install.com
 | 
			
		||||
 | 
			
		||||
LIB= $(TOP)/libcrypto.a
 | 
			
		||||
SHARED_LIB= libcrypto$(SHLIB_EXT)
 | 
			
		||||
LIBSRC=	cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c tmdiff.c cpt_err.c ebcdic.c uid.c o_time.c o_str.c
 | 
			
		||||
LIBOBJ= cryptlib.o mem.o mem_clr.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o uid.o o_time.o o_str.c
 | 
			
		||||
LIBOBJ= cryptlib.o mem.o mem_clr.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o uid.o o_time.o o_str.o
 | 
			
		||||
 | 
			
		||||
SRC= $(LIBSRC)
 | 
			
		||||
 | 
			
		||||
@@ -204,6 +203,8 @@ mem_dbg.o: ../include/openssl/err.h ../include/openssl/lhash.h
 | 
			
		||||
mem_dbg.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
 | 
			
		||||
mem_dbg.o: ../include/openssl/safestack.h ../include/openssl/stack.h
 | 
			
		||||
mem_dbg.o: ../include/openssl/symhacks.h cryptlib.h mem_dbg.c
 | 
			
		||||
o_str.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h o_str.c
 | 
			
		||||
o_str.o: o_str.h
 | 
			
		||||
o_time.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h o_time.c
 | 
			
		||||
o_time.o: o_time.h
 | 
			
		||||
tmdiff.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
 | 
			
		||||
 
 | 
			
		||||
@@ -91,7 +91,8 @@ aes_cbc.o: ../../include/openssl/opensslconf.h aes_cbc.c aes_locl.h
 | 
			
		||||
aes_cfb.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h
 | 
			
		||||
aes_cfb.o: ../../include/openssl/opensslconf.h aes_cfb.c aes_locl.h
 | 
			
		||||
aes_core.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h
 | 
			
		||||
aes_core.o: ../../include/openssl/opensslconf.h aes_core.c aes_locl.h
 | 
			
		||||
aes_core.o: ../../include/openssl/fips.h ../../include/openssl/opensslconf.h
 | 
			
		||||
aes_core.o: aes_core.c aes_locl.h
 | 
			
		||||
aes_ctr.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h
 | 
			
		||||
aes_ctr.o: ../../include/openssl/opensslconf.h aes_ctr.c aes_locl.h
 | 
			
		||||
aes_ecb.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h
 | 
			
		||||
 
 | 
			
		||||
@@ -52,8 +52,6 @@
 | 
			
		||||
#ifndef HEADER_AES_H
 | 
			
		||||
#define HEADER_AES_H
 | 
			
		||||
 | 
			
		||||
#include <openssl/opensslconf.h>
 | 
			
		||||
 | 
			
		||||
#ifdef OPENSSL_NO_AES
 | 
			
		||||
#error AES is disabled.
 | 
			
		||||
#endif
 | 
			
		||||
@@ -97,6 +95,15 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
 | 
			
		||||
void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
 | 
			
		||||
	const unsigned long length, const AES_KEY *key,
 | 
			
		||||
	unsigned char *ivec, int *num, const int enc);
 | 
			
		||||
void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
 | 
			
		||||
	const unsigned long length, const AES_KEY *key,
 | 
			
		||||
	unsigned char *ivec, int *num, const int enc);
 | 
			
		||||
void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
 | 
			
		||||
	const unsigned long length, const AES_KEY *key,
 | 
			
		||||
	unsigned char *ivec, int *num, const int enc);
 | 
			
		||||
void AES_cfbr_encrypt_block(const unsigned char *in,unsigned char *out,
 | 
			
		||||
			    const int nbits,const AES_KEY *key,
 | 
			
		||||
			    unsigned char *ivec,const int enc);
 | 
			
		||||
void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
 | 
			
		||||
	const unsigned long length, const AES_KEY *key,
 | 
			
		||||
	unsigned char *ivec, int *num);
 | 
			
		||||
 
 | 
			
		||||
@@ -155,3 +155,96 @@ void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
 | 
			
		||||
	*num=n;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* This expects a single block of size nbits for both in and out. Note that
 | 
			
		||||
   it corrupts any extra bits in the last byte of out */
 | 
			
		||||
/* Untested, once it is working, it will be optimised */
 | 
			
		||||
void AES_cfbr_encrypt_block(const unsigned char *in,unsigned char *out,
 | 
			
		||||
			    const int nbits,const AES_KEY *key,
 | 
			
		||||
			    unsigned char *ivec,const int enc)
 | 
			
		||||
    {
 | 
			
		||||
    int n;
 | 
			
		||||
    unsigned char ovec[AES_BLOCK_SIZE*2];
 | 
			
		||||
 | 
			
		||||
    assert(in && out && key && ivec);
 | 
			
		||||
    if(enc)
 | 
			
		||||
	{
 | 
			
		||||
	/* construct the new IV */
 | 
			
		||||
	AES_encrypt(ivec,ovec,key);
 | 
			
		||||
	/* encrypt the input */
 | 
			
		||||
	for(n=0 ; n < (nbits+7)/8 ; ++n)
 | 
			
		||||
	    out[n]=in[n]^ovec[n];
 | 
			
		||||
	/* fill in the first half of the new IV with the current IV */
 | 
			
		||||
	memcpy(ovec,ivec,AES_BLOCK_SIZE);
 | 
			
		||||
	/* and put the ciphertext in the second half */
 | 
			
		||||
	memcpy(ovec+AES_BLOCK_SIZE,out,(nbits+7)/8);
 | 
			
		||||
	/* shift ovec left most of the bits... */
 | 
			
		||||
	memmove(ovec,ovec+nbits/8,AES_BLOCK_SIZE+(nbits%8 ? 1 : 0));
 | 
			
		||||
	/* now the remaining bits */
 | 
			
		||||
	if(nbits%8 != 0)
 | 
			
		||||
	    for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
 | 
			
		||||
		{
 | 
			
		||||
		ovec[n]<<=nbits%8;
 | 
			
		||||
		ovec[n]|=ovec[n+1]>>(8-nbits%8);
 | 
			
		||||
		}
 | 
			
		||||
	/* finally, move it back into place */
 | 
			
		||||
	memcpy(ivec,ovec,AES_BLOCK_SIZE);
 | 
			
		||||
	}
 | 
			
		||||
    else
 | 
			
		||||
	{
 | 
			
		||||
	/* construct the new IV in the first half of ovec */
 | 
			
		||||
	AES_encrypt(ivec,ovec,key);
 | 
			
		||||
	/* decrypt the input */
 | 
			
		||||
	for(n=0 ; n < (nbits+7)/8 ; ++n)
 | 
			
		||||
	    out[n]=in[n]^ovec[n];
 | 
			
		||||
	/* fill in the first half of the new IV with the current IV */
 | 
			
		||||
	memcpy(ovec,ivec,AES_BLOCK_SIZE);
 | 
			
		||||
	/* append the ciphertext */
 | 
			
		||||
	memcpy(ovec+AES_BLOCK_SIZE,in,(nbits+7)/8);
 | 
			
		||||
	/* shift ovec left most of the bits... */
 | 
			
		||||
	memmove(ovec,ovec+nbits/8,AES_BLOCK_SIZE+(nbits%8 ? 1 : 0));
 | 
			
		||||
	/* now the remaining bits */
 | 
			
		||||
	if(nbits%8 != 0)
 | 
			
		||||
	    for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
 | 
			
		||||
		{
 | 
			
		||||
		ovec[n]<<=nbits%8;
 | 
			
		||||
		ovec[n]|=ovec[n+1]>>(8-nbits%8);
 | 
			
		||||
		}
 | 
			
		||||
	/* finally, move it back into place */
 | 
			
		||||
	memcpy(ivec,ovec,AES_BLOCK_SIZE);
 | 
			
		||||
	}
 | 
			
		||||
    /* it is not necessary to cleanse ovec, since the IV is not secret */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
/* N.B. This expects the input to be packed, MS bit first */
 | 
			
		||||
void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
 | 
			
		||||
		      const unsigned long length, const AES_KEY *key,
 | 
			
		||||
		      unsigned char *ivec, int *num, const int enc)
 | 
			
		||||
    {
 | 
			
		||||
    unsigned int n;
 | 
			
		||||
    unsigned char c[1],d[1];
 | 
			
		||||
 | 
			
		||||
    assert(in && out && key && ivec && num);
 | 
			
		||||
    assert(*num == 0);
 | 
			
		||||
 | 
			
		||||
    memset(out,0,(length+7)/8);
 | 
			
		||||
    for(n=0 ; n < length ; ++n)
 | 
			
		||||
	{
 | 
			
		||||
	c[0]=(in[n/8]&(1 << (7-n%8))) ? 0x80 : 0;
 | 
			
		||||
	AES_cfbr_encrypt_block(c,d,1,key,ivec,enc);
 | 
			
		||||
	out[n/8]=(out[n/8]&~(1 << (7-n%8)))|((d[0]&0x80) >> (n%8));
 | 
			
		||||
	}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
 | 
			
		||||
		      const unsigned long length, const AES_KEY *key,
 | 
			
		||||
		      unsigned char *ivec, int *num, const int enc)
 | 
			
		||||
    {
 | 
			
		||||
    unsigned int n;
 | 
			
		||||
 | 
			
		||||
    assert(in && out && key && ivec && num);
 | 
			
		||||
    assert(*num == 0);
 | 
			
		||||
 | 
			
		||||
    for(n=0 ; n < length ; ++n)
 | 
			
		||||
	AES_cfbr_encrypt_block(&in[n],&out[n],8,key,ivec,enc);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -37,8 +37,11 @@
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <openssl/aes.h>
 | 
			
		||||
#include <openssl/fips.h>
 | 
			
		||||
#include "aes_locl.h"
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_FIPS
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
Te0[x] = S [x].[02, 01, 01, 03];
 | 
			
		||||
Te1[x] = S [x].[03, 02, 01, 01];
 | 
			
		||||
@@ -1255,3 +1258,4 @@ void AES_decrypt(const unsigned char *in, unsigned char *out,
 | 
			
		||||
	PUTU32(out + 12, s3);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /* ndef OPENSSL_FIPS */
 | 
			
		||||
 
 | 
			
		||||
@@ -59,7 +59,7 @@
 | 
			
		||||
#include <openssl/aes.h>
 | 
			
		||||
#include "aes_locl.h"
 | 
			
		||||
 | 
			
		||||
/* NOTE: the IV/counter CTR mode is big-endian.  The rest of the AES code
 | 
			
		||||
/* NOTE: CTR mode is big-endian.  The rest of the AES code
 | 
			
		||||
 * is endian-neutral. */
 | 
			
		||||
 | 
			
		||||
/* increment counter (128-bit int) by 1 */
 | 
			
		||||
@@ -67,36 +67,61 @@ static void AES_ctr128_inc(unsigned char *counter) {
 | 
			
		||||
	unsigned long c;
 | 
			
		||||
 | 
			
		||||
	/* Grab bottom dword of counter and increment */
 | 
			
		||||
#ifdef L_ENDIAN
 | 
			
		||||
	c = GETU32(counter +  0);
 | 
			
		||||
	c++;
 | 
			
		||||
	PUTU32(counter +  0, c);
 | 
			
		||||
#else
 | 
			
		||||
	c = GETU32(counter + 12);
 | 
			
		||||
	c++;
 | 
			
		||||
	PUTU32(counter + 12, c);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	/* if no overflow, we're done */
 | 
			
		||||
	if (c)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	/* Grab 1st dword of counter and increment */
 | 
			
		||||
#ifdef L_ENDIAN
 | 
			
		||||
	c = GETU32(counter +  4);
 | 
			
		||||
	c++;
 | 
			
		||||
	PUTU32(counter +  4, c);
 | 
			
		||||
#else
 | 
			
		||||
	c = GETU32(counter +  8);
 | 
			
		||||
	c++;
 | 
			
		||||
	PUTU32(counter +  8, c);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	/* if no overflow, we're done */
 | 
			
		||||
	if (c)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	/* Grab 2nd dword of counter and increment */
 | 
			
		||||
#ifdef L_ENDIAN
 | 
			
		||||
	c = GETU32(counter +  8);
 | 
			
		||||
	c++;
 | 
			
		||||
	PUTU32(counter +  8, c);
 | 
			
		||||
#else
 | 
			
		||||
	c = GETU32(counter +  4);
 | 
			
		||||
	c++;
 | 
			
		||||
	PUTU32(counter +  4, c);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	/* if no overflow, we're done */
 | 
			
		||||
	if (c)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	/* Grab top dword of counter and increment */
 | 
			
		||||
#ifdef L_ENDIAN
 | 
			
		||||
	c = GETU32(counter + 12);
 | 
			
		||||
	c++;
 | 
			
		||||
	PUTU32(counter + 12, c);
 | 
			
		||||
#else
 | 
			
		||||
	c = GETU32(counter +  0);
 | 
			
		||||
	c++;
 | 
			
		||||
	PUTU32(counter +  0, c);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* The input encrypted as though 128bit counter mode is being
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -147,7 +147,7 @@ ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
 | 
			
		||||
		ASN1err(ASN1_F_BN_TO_ASN1_ENUMERATED,ERR_R_NESTED_ASN1_ERROR);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	if(BN_get_sign(bn)) ret->type = V_ASN1_NEG_ENUMERATED;
 | 
			
		||||
	if(bn->neg) ret->type = V_ASN1_NEG_ENUMERATED;
 | 
			
		||||
	else ret->type=V_ASN1_ENUMERATED;
 | 
			
		||||
	j=BN_num_bits(bn);
 | 
			
		||||
	len=((j == 0)?0:((j/8)+1));
 | 
			
		||||
@@ -175,6 +175,6 @@ BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn)
 | 
			
		||||
 | 
			
		||||
	if ((ret=BN_bin2bn(ai->data,ai->length,bn)) == NULL)
 | 
			
		||||
		ASN1err(ASN1_F_ASN1_ENUMERATED_TO_BN,ASN1_R_BN_LIB);
 | 
			
		||||
	else if(ai->type == V_ASN1_NEG_ENUMERATED) BN_set_sign(ret,1);
 | 
			
		||||
	else if(ai->type == V_ASN1_NEG_ENUMERATED) ret->neg = 1;
 | 
			
		||||
	return(ret);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -115,7 +115,7 @@ err:
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
 | 
			
		||||
int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *d)
 | 
			
		||||
	{
 | 
			
		||||
	static int min[9]={ 0, 0, 1, 1, 0, 0, 0, 0, 0};
 | 
			
		||||
	static int max[9]={99, 99,12,31,23,59,59,12,59};
 | 
			
		||||
 
 | 
			
		||||
@@ -393,8 +393,7 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai)
 | 
			
		||||
		ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_NESTED_ASN1_ERROR);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	if (BN_get_sign(bn))
 | 
			
		||||
		ret->type = V_ASN1_NEG_INTEGER;
 | 
			
		||||
	if(bn->neg) ret->type = V_ASN1_NEG_INTEGER;
 | 
			
		||||
	else ret->type=V_ASN1_INTEGER;
 | 
			
		||||
	j=BN_num_bits(bn);
 | 
			
		||||
	len=((j == 0)?0:((j/8)+1));
 | 
			
		||||
@@ -427,8 +426,7 @@ BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai, BIGNUM *bn)
 | 
			
		||||
 | 
			
		||||
	if ((ret=BN_bin2bn(ai->data,ai->length,bn)) == NULL)
 | 
			
		||||
		ASN1err(ASN1_F_ASN1_INTEGER_TO_BN,ASN1_R_BN_LIB);
 | 
			
		||||
	else if(ai->type == V_ASN1_NEG_INTEGER)
 | 
			
		||||
		BN_set_sign(ret, 1);
 | 
			
		||||
	else if(ai->type == V_ASN1_NEG_INTEGER) ret->neg = 1;
 | 
			
		||||
	return(ret);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -56,7 +56,7 @@
 | 
			
		||||
 * [including the GNU Public Licence.]
 | 
			
		||||
 */
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright (c) 1998-2003 The OpenSSL Project.  All rights reserved.
 | 
			
		||||
 * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
@@ -229,11 +229,10 @@ int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
 | 
			
		||||
		else
 | 
			
		||||
			a=algor2;
 | 
			
		||||
		if (a == NULL) continue;
 | 
			
		||||
                if (type->pkey_type == NID_dsaWithSHA1 ||
 | 
			
		||||
			type->pkey_type == NID_ecdsa_with_SHA1)
 | 
			
		||||
                if (type->pkey_type == NID_dsaWithSHA1)
 | 
			
		||||
			{
 | 
			
		||||
			/* special case: RFC 3279 tells us to omit 'parameters'
 | 
			
		||||
			 * with id-dsa-with-sha1 and ecdsa-with-SHA1 */
 | 
			
		||||
			/* special case: RFC 2459 tells us to omit 'parameters'
 | 
			
		||||
			 * with id-dsa-with-sha1 */
 | 
			
		||||
			ASN1_TYPE_free(a->parameter);
 | 
			
		||||
			a->parameter = NULL;
 | 
			
		||||
			}
 | 
			
		||||
 
 | 
			
		||||
@@ -114,7 +114,7 @@ ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t)
 | 
			
		||||
	return ASN1_GENERALIZEDTIME_set(s,t);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int ASN1_TIME_check(ASN1_TIME *t)
 | 
			
		||||
int ASN1_TIME_check(const ASN1_TIME *t)
 | 
			
		||||
	{
 | 
			
		||||
	if (t->type == V_ASN1_GENERALIZEDTIME)
 | 
			
		||||
		return ASN1_GENERALIZEDTIME_check(t);
 | 
			
		||||
@@ -124,7 +124,8 @@ int ASN1_TIME_check(ASN1_TIME *t)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/* Convert an ASN1_TIME structure to GeneralizedTime */
 | 
			
		||||
ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out)
 | 
			
		||||
ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t,
 | 
			
		||||
						   ASN1_GENERALIZEDTIME **out)
 | 
			
		||||
	{
 | 
			
		||||
	ASN1_GENERALIZEDTIME *ret;
 | 
			
		||||
	char *str;
 | 
			
		||||
 
 | 
			
		||||
@@ -112,7 +112,7 @@ err:
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int ASN1_UTCTIME_check(ASN1_UTCTIME *d)
 | 
			
		||||
int ASN1_UTCTIME_check(const ASN1_UTCTIME *d)
 | 
			
		||||
	{
 | 
			
		||||
	static int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0};
 | 
			
		||||
	static int max[8]={99,12,31,23,59,59,12,59};
 | 
			
		||||
 
 | 
			
		||||
@@ -60,10 +60,10 @@
 | 
			
		||||
#define HEADER_ASN1_H
 | 
			
		||||
 | 
			
		||||
#include <time.h>
 | 
			
		||||
#include <openssl/e_os2.h>
 | 
			
		||||
#ifndef OPENSSL_NO_BIO
 | 
			
		||||
#include <openssl/bio.h>
 | 
			
		||||
#endif
 | 
			
		||||
#include <openssl/e_os2.h>
 | 
			
		||||
#include <openssl/bn.h>
 | 
			
		||||
#include <openssl/stack.h>
 | 
			
		||||
#include <openssl/safestack.h>
 | 
			
		||||
@@ -191,11 +191,6 @@ typedef struct asn1_object_st
 | 
			
		||||
	} ASN1_OBJECT;
 | 
			
		||||
 | 
			
		||||
#define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */
 | 
			
		||||
/* This indicates that the ASN1_STRING is not a real value but just a place
 | 
			
		||||
 * holder for the location where indefinite length constructed data should
 | 
			
		||||
 * be inserted in the memory buffer 
 | 
			
		||||
 */
 | 
			
		||||
#define ASN1_STRING_FLAG_NDEF 0x010 
 | 
			
		||||
/* This is the base type that holds just about everything :-) */
 | 
			
		||||
typedef struct asn1_string_st
 | 
			
		||||
	{
 | 
			
		||||
@@ -264,15 +259,14 @@ typedef struct ASN1_VALUE_st ASN1_VALUE;
 | 
			
		||||
 | 
			
		||||
#define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)
 | 
			
		||||
 | 
			
		||||
#define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \
 | 
			
		||||
	DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type)
 | 
			
		||||
 | 
			
		||||
#define DECLARE_ASN1_FUNCTIONS_name(type, name) \
 | 
			
		||||
	DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
 | 
			
		||||
	type *name##_new(void); \
 | 
			
		||||
	void name##_free(type *a); \
 | 
			
		||||
	DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name)
 | 
			
		||||
 | 
			
		||||
#define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \
 | 
			
		||||
	DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
 | 
			
		||||
	type *name##_new(void); \
 | 
			
		||||
	void name##_free(type *a); \
 | 
			
		||||
	DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)
 | 
			
		||||
 | 
			
		||||
#define	DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \
 | 
			
		||||
@@ -285,16 +279,10 @@ typedef struct ASN1_VALUE_st ASN1_VALUE;
 | 
			
		||||
	int i2d_##name(const type *a, unsigned char **out); \
 | 
			
		||||
	DECLARE_ASN1_ITEM(name)
 | 
			
		||||
 | 
			
		||||
#define	DECLARE_ASN1_NDEF_FUNCTION(name) \
 | 
			
		||||
	int i2d_##name##_NDEF(name *a, unsigned char **out);
 | 
			
		||||
 | 
			
		||||
#define DECLARE_ASN1_FUNCTIONS_const(name) \
 | 
			
		||||
	name *name##_new(void); \
 | 
			
		||||
	void name##_free(name *a);
 | 
			
		||||
 | 
			
		||||
#define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
 | 
			
		||||
	type *name##_new(void); \
 | 
			
		||||
	void name##_free(type *a);
 | 
			
		||||
 | 
			
		||||
/* The following macros and typedefs allow an ASN1_ITEM
 | 
			
		||||
 * to be embedded in a structure and referenced. Since
 | 
			
		||||
@@ -766,7 +754,7 @@ int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y);
 | 
			
		||||
 | 
			
		||||
DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)
 | 
			
		||||
 | 
			
		||||
int ASN1_UTCTIME_check(ASN1_UTCTIME *a);
 | 
			
		||||
int ASN1_UTCTIME_check(const ASN1_UTCTIME *a);
 | 
			
		||||
ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t);
 | 
			
		||||
int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, char *str); 
 | 
			
		||||
int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
 | 
			
		||||
@@ -774,7 +762,7 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
 | 
			
		||||
time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
 | 
			
		||||
int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a);
 | 
			
		||||
ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
 | 
			
		||||
int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, char *str); 
 | 
			
		||||
 | 
			
		||||
@@ -804,11 +792,9 @@ DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)
 | 
			
		||||
DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)
 | 
			
		||||
DECLARE_ASN1_FUNCTIONS(ASN1_TIME)
 | 
			
		||||
 | 
			
		||||
DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)
 | 
			
		||||
 | 
			
		||||
ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
 | 
			
		||||
int ASN1_TIME_check(ASN1_TIME *t);
 | 
			
		||||
ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out);
 | 
			
		||||
int ASN1_TIME_check(const ASN1_TIME *t);
 | 
			
		||||
ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t, ASN1_GENERALIZEDTIME **out);
 | 
			
		||||
 | 
			
		||||
int		i2d_ASN1_SET(STACK *a, unsigned char **pp,
 | 
			
		||||
			int (*func)(), int ex_tag, int ex_class, int is_set);
 | 
			
		||||
@@ -862,7 +848,6 @@ int ASN1_get_object(unsigned char **pp, long *plength, int *ptag,
 | 
			
		||||
int ASN1_check_infinite_end(unsigned char **p,long len);
 | 
			
		||||
void ASN1_put_object(unsigned char **pp, int constructed, int length,
 | 
			
		||||
	int tag, int xclass);
 | 
			
		||||
int ASN1_put_eoc(unsigned char **pp);
 | 
			
		||||
int ASN1_object_size(int constructed, int length, int tag);
 | 
			
		||||
 | 
			
		||||
/* Used to implement other functions */
 | 
			
		||||
@@ -949,13 +934,9 @@ ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);
 | 
			
		||||
void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);
 | 
			
		||||
ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, unsigned char **in, long len, const ASN1_ITEM *it);
 | 
			
		||||
int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
 | 
			
		||||
int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
 | 
			
		||||
 | 
			
		||||
void ASN1_add_oid_module(void);
 | 
			
		||||
 | 
			
		||||
ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf);
 | 
			
		||||
ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf);
 | 
			
		||||
	
 | 
			
		||||
/* BEGIN ERROR CODES */
 | 
			
		||||
/* The following lines are auto generated by the script mkerr.pl. Any changes
 | 
			
		||||
 * made after this point may be overwritten when the script is next run.
 | 
			
		||||
@@ -969,8 +950,6 @@ void ERR_load_ASN1_strings(void);
 | 
			
		||||
#define ASN1_F_A2I_ASN1_ENUMERATED			 101
 | 
			
		||||
#define ASN1_F_A2I_ASN1_INTEGER				 102
 | 
			
		||||
#define ASN1_F_A2I_ASN1_STRING				 103
 | 
			
		||||
#define ASN1_F_APPEND_TAG				 176
 | 
			
		||||
#define ASN1_F_ASN1_CB					 177
 | 
			
		||||
#define ASN1_F_ASN1_CHECK_TLEN				 104
 | 
			
		||||
#define ASN1_F_ASN1_COLLATE_PRIMITIVE			 105
 | 
			
		||||
#define ASN1_F_ASN1_COLLECT				 106
 | 
			
		||||
@@ -981,7 +960,6 @@ void ERR_load_ASN1_strings(void);
 | 
			
		||||
#define ASN1_F_ASN1_DUP					 111
 | 
			
		||||
#define ASN1_F_ASN1_ENUMERATED_SET			 112
 | 
			
		||||
#define ASN1_F_ASN1_ENUMERATED_TO_BN			 113
 | 
			
		||||
#define ASN1_F_ASN1_GENERATE_V3				 178
 | 
			
		||||
#define ASN1_F_ASN1_GET_OBJECT				 114
 | 
			
		||||
#define ASN1_F_ASN1_HEADER_NEW				 115
 | 
			
		||||
#define ASN1_F_ASN1_I2D_BIO				 116
 | 
			
		||||
@@ -997,7 +975,6 @@ void ERR_load_ASN1_strings(void);
 | 
			
		||||
#define ASN1_F_ASN1_SEQ_PACK				 126
 | 
			
		||||
#define ASN1_F_ASN1_SEQ_UNPACK				 127
 | 
			
		||||
#define ASN1_F_ASN1_SIGN				 128
 | 
			
		||||
#define ASN1_F_ASN1_STR2TYPE				 179
 | 
			
		||||
#define ASN1_F_ASN1_STRING_TABLE_ADD			 129
 | 
			
		||||
#define ASN1_F_ASN1_STRING_TYPE_NEW			 130
 | 
			
		||||
#define ASN1_F_ASN1_TEMPLATE_D2I			 131
 | 
			
		||||
@@ -1008,7 +985,6 @@ void ERR_load_ASN1_strings(void);
 | 
			
		||||
#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING		 135
 | 
			
		||||
#define ASN1_F_ASN1_UNPACK_STRING			 136
 | 
			
		||||
#define ASN1_F_ASN1_VERIFY				 137
 | 
			
		||||
#define ASN1_F_BITSTR_CB				 180
 | 
			
		||||
#define ASN1_F_BN_TO_ASN1_ENUMERATED			 138
 | 
			
		||||
#define ASN1_F_BN_TO_ASN1_INTEGER			 139
 | 
			
		||||
#define ASN1_F_COLLECT_DATA				 140
 | 
			
		||||
@@ -1033,14 +1009,12 @@ void ERR_load_ASN1_strings(void);
 | 
			
		||||
#define ASN1_F_D2I_X509_PKEY				 159
 | 
			
		||||
#define ASN1_F_I2D_ASN1_TIME				 160
 | 
			
		||||
#define ASN1_F_I2D_DSA_PUBKEY				 161
 | 
			
		||||
#define ASN1_F_I2D_EC_PUBKEY				 181
 | 
			
		||||
#define ASN1_F_I2D_NETSCAPE_RSA				 162
 | 
			
		||||
#define ASN1_F_I2D_PRIVATEKEY				 163
 | 
			
		||||
#define ASN1_F_I2D_PUBLICKEY				 164
 | 
			
		||||
#define ASN1_F_I2D_RSA_PUBKEY				 165
 | 
			
		||||
#define ASN1_F_LONG_C2I					 166
 | 
			
		||||
#define ASN1_F_OID_MODULE_INIT				 174
 | 
			
		||||
#define ASN1_F_PARSE_TAGGING				 182
 | 
			
		||||
#define ASN1_F_PKCS5_PBE2_SET				 167
 | 
			
		||||
#define ASN1_F_X509_CINF_NEW				 168
 | 
			
		||||
#define ASN1_F_X509_CRL_ADD0_REVOKED			 169
 | 
			
		||||
@@ -1063,7 +1037,6 @@ void ERR_load_ASN1_strings(void);
 | 
			
		||||
#define ASN1_R_DATA_IS_WRONG				 109
 | 
			
		||||
#define ASN1_R_DECODE_ERROR				 110
 | 
			
		||||
#define ASN1_R_DECODING_ERROR				 111
 | 
			
		||||
#define ASN1_R_DEPTH_EXCEEDED				 174
 | 
			
		||||
#define ASN1_R_ENCODE_ERROR				 112
 | 
			
		||||
#define ASN1_R_ERROR_GETTING_TIME			 173
 | 
			
		||||
#define ASN1_R_ERROR_LOADING_SECTION			 172
 | 
			
		||||
@@ -1078,57 +1051,38 @@ void ERR_load_ASN1_strings(void);
 | 
			
		||||
#define ASN1_R_FIELD_MISSING				 121
 | 
			
		||||
#define ASN1_R_FIRST_NUM_TOO_LARGE			 122
 | 
			
		||||
#define ASN1_R_HEADER_TOO_LONG				 123
 | 
			
		||||
#define ASN1_R_ILLEGAL_BITSTRING_FORMAT			 175
 | 
			
		||||
#define ASN1_R_ILLEGAL_BOOLEAN				 176
 | 
			
		||||
#define ASN1_R_ILLEGAL_CHARACTERS			 124
 | 
			
		||||
#define ASN1_R_ILLEGAL_FORMAT				 177
 | 
			
		||||
#define ASN1_R_ILLEGAL_HEX				 178
 | 
			
		||||
#define ASN1_R_ILLEGAL_IMPLICIT_TAG			 179
 | 
			
		||||
#define ASN1_R_ILLEGAL_INTEGER				 180
 | 
			
		||||
#define ASN1_R_ILLEGAL_NESTED_TAGGING			 181
 | 
			
		||||
#define ASN1_R_ILLEGAL_NULL				 125
 | 
			
		||||
#define ASN1_R_ILLEGAL_NULL_VALUE			 182
 | 
			
		||||
#define ASN1_R_ILLEGAL_OBJECT				 183
 | 
			
		||||
#define ASN1_R_ILLEGAL_OPTIONAL_ANY			 126
 | 
			
		||||
#define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE		 170
 | 
			
		||||
#define ASN1_R_ILLEGAL_TAGGED_ANY			 127
 | 
			
		||||
#define ASN1_R_ILLEGAL_TIME_VALUE			 184
 | 
			
		||||
#define ASN1_R_INTEGER_NOT_ASCII_FORMAT			 185
 | 
			
		||||
#define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG		 128
 | 
			
		||||
#define ASN1_R_INVALID_BMPSTRING_LENGTH			 129
 | 
			
		||||
#define ASN1_R_INVALID_DIGIT				 130
 | 
			
		||||
#define ASN1_R_INVALID_MODIFIER				 186
 | 
			
		||||
#define ASN1_R_INVALID_NUMBER				 187
 | 
			
		||||
#define ASN1_R_INVALID_SEPARATOR			 131
 | 
			
		||||
#define ASN1_R_INVALID_TIME_FORMAT			 132
 | 
			
		||||
#define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH		 133
 | 
			
		||||
#define ASN1_R_INVALID_UTF8STRING			 134
 | 
			
		||||
#define ASN1_R_IV_TOO_LARGE				 135
 | 
			
		||||
#define ASN1_R_LENGTH_ERROR				 136
 | 
			
		||||
#define ASN1_R_LIST_ERROR				 188
 | 
			
		||||
#define ASN1_R_MISSING_EOC				 137
 | 
			
		||||
#define ASN1_R_MISSING_SECOND_NUMBER			 138
 | 
			
		||||
#define ASN1_R_MISSING_VALUE				 189
 | 
			
		||||
#define ASN1_R_MSTRING_NOT_UNIVERSAL			 139
 | 
			
		||||
#define ASN1_R_MSTRING_WRONG_TAG			 140
 | 
			
		||||
#define ASN1_R_NON_HEX_CHARACTERS			 141
 | 
			
		||||
#define ASN1_R_NOT_ASCII_FORMAT				 190
 | 
			
		||||
#define ASN1_R_NOT_ENOUGH_DATA				 142
 | 
			
		||||
#define ASN1_R_NO_MATCHING_CHOICE_TYPE			 143
 | 
			
		||||
#define ASN1_R_NULL_IS_WRONG_LENGTH			 144
 | 
			
		||||
#define ASN1_R_OBJECT_NOT_ASCII_FORMAT			 191
 | 
			
		||||
#define ASN1_R_ODD_NUMBER_OF_CHARS			 145
 | 
			
		||||
#define ASN1_R_PRIVATE_KEY_HEADER_MISSING		 146
 | 
			
		||||
#define ASN1_R_SECOND_NUMBER_TOO_LARGE			 147
 | 
			
		||||
#define ASN1_R_SEQUENCE_LENGTH_MISMATCH			 148
 | 
			
		||||
#define ASN1_R_SEQUENCE_NOT_CONSTRUCTED			 149
 | 
			
		||||
#define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG		 192
 | 
			
		||||
#define ASN1_R_SHORT_LINE				 150
 | 
			
		||||
#define ASN1_R_STRING_TOO_LONG				 151
 | 
			
		||||
#define ASN1_R_STRING_TOO_SHORT				 152
 | 
			
		||||
#define ASN1_R_TAG_VALUE_TOO_HIGH			 153
 | 
			
		||||
#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154
 | 
			
		||||
#define ASN1_R_TIME_NOT_ASCII_FORMAT			 193
 | 
			
		||||
#define ASN1_R_TOO_LONG					 155
 | 
			
		||||
#define ASN1_R_TYPE_NOT_CONSTRUCTED			 156
 | 
			
		||||
#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY			 157
 | 
			
		||||
@@ -1138,13 +1092,10 @@ void ERR_load_ASN1_strings(void);
 | 
			
		||||
#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM		 161
 | 
			
		||||
#define ASN1_R_UNKNOWN_OBJECT_TYPE			 162
 | 
			
		||||
#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE			 163
 | 
			
		||||
#define ASN1_R_UNKNOWN_TAG				 194
 | 
			
		||||
#define ASN1_R_UNKOWN_FORMAT				 195
 | 
			
		||||
#define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE		 164
 | 
			
		||||
#define ASN1_R_UNSUPPORTED_CIPHER			 165
 | 
			
		||||
#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM		 166
 | 
			
		||||
#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE		 167
 | 
			
		||||
#define ASN1_R_UNSUPPORTED_TYPE				 196
 | 
			
		||||
#define ASN1_R_WRONG_TAG				 168
 | 
			
		||||
#define ASN1_R_WRONG_TYPE				 169
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -70,8 +70,6 @@ static ERR_STRING_DATA ASN1_str_functs[]=
 | 
			
		||||
{ERR_PACK(0,ASN1_F_A2I_ASN1_ENUMERATED,0),	"a2i_ASN1_ENUMERATED"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_A2I_ASN1_INTEGER,0),	"a2i_ASN1_INTEGER"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_A2I_ASN1_STRING,0),	"a2i_ASN1_STRING"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_APPEND_TAG,0),	"APPEND_TAG"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_CB,0),	"ASN1_CB"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_CHECK_TLEN,0),	"ASN1_CHECK_TLEN"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_COLLATE_PRIMITIVE,0),	"ASN1_COLLATE_PRIMITIVE"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_COLLECT,0),	"ASN1_COLLECT"},
 | 
			
		||||
@@ -82,7 +80,6 @@ static ERR_STRING_DATA ASN1_str_functs[]=
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_DUP,0),	"ASN1_dup"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_SET,0),	"ASN1_ENUMERATED_set"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_TO_BN,0),	"ASN1_ENUMERATED_to_BN"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_GENERATE_V3,0),	"ASN1_generate_v3"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_GET_OBJECT,0),	"ASN1_get_object"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_HEADER_NEW,0),	"ASN1_HEADER_new"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_I2D_BIO,0),	"ASN1_i2d_bio"},
 | 
			
		||||
@@ -98,7 +95,6 @@ static ERR_STRING_DATA ASN1_str_functs[]=
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_SEQ_PACK,0),	"ASN1_seq_pack"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_SEQ_UNPACK,0),	"ASN1_seq_unpack"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_SIGN,0),	"ASN1_sign"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_STR2TYPE,0),	"ASN1_STR2TYPE"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_STRING_TABLE_ADD,0),	"ASN1_STRING_TABLE_add"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_STRING_TYPE_NEW,0),	"ASN1_STRING_type_new"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_D2I,0),	"ASN1_TEMPLATE_D2I"},
 | 
			
		||||
@@ -109,7 +105,6 @@ static ERR_STRING_DATA ASN1_str_functs[]=
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_OCTETSTRING,0),	"ASN1_TYPE_get_octetstring"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_UNPACK_STRING,0),	"ASN1_unpack_string"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_ASN1_VERIFY,0),	"ASN1_verify"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_BITSTR_CB,0),	"BITSTR_CB"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_BN_TO_ASN1_ENUMERATED,0),	"BN_to_ASN1_ENUMERATED"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_BN_TO_ASN1_INTEGER,0),	"BN_to_ASN1_INTEGER"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_COLLECT_DATA,0),	"COLLECT_DATA"},
 | 
			
		||||
@@ -134,14 +129,12 @@ static ERR_STRING_DATA ASN1_str_functs[]=
 | 
			
		||||
{ERR_PACK(0,ASN1_F_D2I_X509_PKEY,0),	"d2i_X509_PKEY"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_I2D_ASN1_TIME,0),	"I2D_ASN1_TIME"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_I2D_DSA_PUBKEY,0),	"i2d_DSA_PUBKEY"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_I2D_EC_PUBKEY,0),	"i2d_EC_PUBKEY"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_I2D_NETSCAPE_RSA,0),	"i2d_Netscape_RSA"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_I2D_PRIVATEKEY,0),	"i2d_PrivateKey"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_I2D_PUBLICKEY,0),	"i2d_PublicKey"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_I2D_RSA_PUBKEY,0),	"i2d_RSA_PUBKEY"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_LONG_C2I,0),	"LONG_C2I"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_OID_MODULE_INIT,0),	"OID_MODULE_INIT"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_PARSE_TAGGING,0),	"PARSE_TAGGING"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_PKCS5_PBE2_SET,0),	"PKCS5_pbe2_set"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_X509_CINF_NEW,0),	"X509_CINF_NEW"},
 | 
			
		||||
{ERR_PACK(0,ASN1_F_X509_CRL_ADD0_REVOKED,0),	"X509_CRL_add0_revoked"},
 | 
			
		||||
@@ -167,7 +160,6 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
 | 
			
		||||
{ASN1_R_DATA_IS_WRONG                    ,"data is wrong"},
 | 
			
		||||
{ASN1_R_DECODE_ERROR                     ,"decode error"},
 | 
			
		||||
{ASN1_R_DECODING_ERROR                   ,"decoding error"},
 | 
			
		||||
{ASN1_R_DEPTH_EXCEEDED                   ,"depth exceeded"},
 | 
			
		||||
{ASN1_R_ENCODE_ERROR                     ,"encode error"},
 | 
			
		||||
{ASN1_R_ERROR_GETTING_TIME               ,"error getting time"},
 | 
			
		||||
{ASN1_R_ERROR_LOADING_SECTION            ,"error loading section"},
 | 
			
		||||
@@ -182,57 +174,38 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
 | 
			
		||||
{ASN1_R_FIELD_MISSING                    ,"field missing"},
 | 
			
		||||
{ASN1_R_FIRST_NUM_TOO_LARGE              ,"first num too large"},
 | 
			
		||||
{ASN1_R_HEADER_TOO_LONG                  ,"header too long"},
 | 
			
		||||
{ASN1_R_ILLEGAL_BITSTRING_FORMAT         ,"illegal bitstring format"},
 | 
			
		||||
{ASN1_R_ILLEGAL_BOOLEAN                  ,"illegal boolean"},
 | 
			
		||||
{ASN1_R_ILLEGAL_CHARACTERS               ,"illegal characters"},
 | 
			
		||||
{ASN1_R_ILLEGAL_FORMAT                   ,"illegal format"},
 | 
			
		||||
{ASN1_R_ILLEGAL_HEX                      ,"illegal hex"},
 | 
			
		||||
{ASN1_R_ILLEGAL_IMPLICIT_TAG             ,"illegal implicit tag"},
 | 
			
		||||
{ASN1_R_ILLEGAL_INTEGER                  ,"illegal integer"},
 | 
			
		||||
{ASN1_R_ILLEGAL_NESTED_TAGGING           ,"illegal nested tagging"},
 | 
			
		||||
{ASN1_R_ILLEGAL_NULL                     ,"illegal null"},
 | 
			
		||||
{ASN1_R_ILLEGAL_NULL_VALUE               ,"illegal null value"},
 | 
			
		||||
{ASN1_R_ILLEGAL_OBJECT                   ,"illegal object"},
 | 
			
		||||
{ASN1_R_ILLEGAL_OPTIONAL_ANY             ,"illegal optional any"},
 | 
			
		||||
{ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE ,"illegal options on item template"},
 | 
			
		||||
{ASN1_R_ILLEGAL_TAGGED_ANY               ,"illegal tagged any"},
 | 
			
		||||
{ASN1_R_ILLEGAL_TIME_VALUE               ,"illegal time value"},
 | 
			
		||||
{ASN1_R_INTEGER_NOT_ASCII_FORMAT         ,"integer not ascii format"},
 | 
			
		||||
{ASN1_R_INTEGER_TOO_LARGE_FOR_LONG       ,"integer too large for long"},
 | 
			
		||||
{ASN1_R_INVALID_BMPSTRING_LENGTH         ,"invalid bmpstring length"},
 | 
			
		||||
{ASN1_R_INVALID_DIGIT                    ,"invalid digit"},
 | 
			
		||||
{ASN1_R_INVALID_MODIFIER                 ,"invalid modifier"},
 | 
			
		||||
{ASN1_R_INVALID_NUMBER                   ,"invalid number"},
 | 
			
		||||
{ASN1_R_INVALID_SEPARATOR                ,"invalid separator"},
 | 
			
		||||
{ASN1_R_INVALID_TIME_FORMAT              ,"invalid time format"},
 | 
			
		||||
{ASN1_R_INVALID_UNIVERSALSTRING_LENGTH   ,"invalid universalstring length"},
 | 
			
		||||
{ASN1_R_INVALID_UTF8STRING               ,"invalid utf8string"},
 | 
			
		||||
{ASN1_R_IV_TOO_LARGE                     ,"iv too large"},
 | 
			
		||||
{ASN1_R_LENGTH_ERROR                     ,"length error"},
 | 
			
		||||
{ASN1_R_LIST_ERROR                       ,"list error"},
 | 
			
		||||
{ASN1_R_MISSING_EOC                      ,"missing eoc"},
 | 
			
		||||
{ASN1_R_MISSING_SECOND_NUMBER            ,"missing second number"},
 | 
			
		||||
{ASN1_R_MISSING_VALUE                    ,"missing value"},
 | 
			
		||||
{ASN1_R_MSTRING_NOT_UNIVERSAL            ,"mstring not universal"},
 | 
			
		||||
{ASN1_R_MSTRING_WRONG_TAG                ,"mstring wrong tag"},
 | 
			
		||||
{ASN1_R_NON_HEX_CHARACTERS               ,"non hex characters"},
 | 
			
		||||
{ASN1_R_NOT_ASCII_FORMAT                 ,"not ascii format"},
 | 
			
		||||
{ASN1_R_NOT_ENOUGH_DATA                  ,"not enough data"},
 | 
			
		||||
{ASN1_R_NO_MATCHING_CHOICE_TYPE          ,"no matching choice type"},
 | 
			
		||||
{ASN1_R_NULL_IS_WRONG_LENGTH             ,"null is wrong length"},
 | 
			
		||||
{ASN1_R_OBJECT_NOT_ASCII_FORMAT          ,"object not ascii format"},
 | 
			
		||||
{ASN1_R_ODD_NUMBER_OF_CHARS              ,"odd number of chars"},
 | 
			
		||||
{ASN1_R_PRIVATE_KEY_HEADER_MISSING       ,"private key header missing"},
 | 
			
		||||
{ASN1_R_SECOND_NUMBER_TOO_LARGE          ,"second number too large"},
 | 
			
		||||
{ASN1_R_SEQUENCE_LENGTH_MISMATCH         ,"sequence length mismatch"},
 | 
			
		||||
{ASN1_R_SEQUENCE_NOT_CONSTRUCTED         ,"sequence not constructed"},
 | 
			
		||||
{ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG     ,"sequence or set needs config"},
 | 
			
		||||
{ASN1_R_SHORT_LINE                       ,"short line"},
 | 
			
		||||
{ASN1_R_STRING_TOO_LONG                  ,"string too long"},
 | 
			
		||||
{ASN1_R_STRING_TOO_SHORT                 ,"string too short"},
 | 
			
		||||
{ASN1_R_TAG_VALUE_TOO_HIGH               ,"tag value too high"},
 | 
			
		||||
{ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD,"the asn1 object identifier is not known for this md"},
 | 
			
		||||
{ASN1_R_TIME_NOT_ASCII_FORMAT            ,"time not ascii format"},
 | 
			
		||||
{ASN1_R_TOO_LONG                         ,"too long"},
 | 
			
		||||
{ASN1_R_TYPE_NOT_CONSTRUCTED             ,"type not constructed"},
 | 
			
		||||
{ASN1_R_UNABLE_TO_DECODE_RSA_KEY         ,"unable to decode rsa key"},
 | 
			
		||||
@@ -242,13 +215,10 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
 | 
			
		||||
{ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM ,"unknown message digest algorithm"},
 | 
			
		||||
{ASN1_R_UNKNOWN_OBJECT_TYPE              ,"unknown object type"},
 | 
			
		||||
{ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE          ,"unknown public key type"},
 | 
			
		||||
{ASN1_R_UNKNOWN_TAG                      ,"unknown tag"},
 | 
			
		||||
{ASN1_R_UNKOWN_FORMAT                    ,"unkown format"},
 | 
			
		||||
{ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE  ,"unsupported any defined by type"},
 | 
			
		||||
{ASN1_R_UNSUPPORTED_CIPHER               ,"unsupported cipher"},
 | 
			
		||||
{ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM ,"unsupported encryption algorithm"},
 | 
			
		||||
{ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE      ,"unsupported public key type"},
 | 
			
		||||
{ASN1_R_UNSUPPORTED_TYPE                 ,"unsupported type"},
 | 
			
		||||
{ASN1_R_WRONG_TAG                        ,"wrong tag"},
 | 
			
		||||
{ASN1_R_WRONG_TYPE                       ,"wrong type"},
 | 
			
		||||
{0,NULL}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,842 +0,0 @@
 | 
			
		||||
/* asn1_gen.c */
 | 
			
		||||
/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
 | 
			
		||||
 * project 2002.
 | 
			
		||||
 */
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright (c) 2002 The OpenSSL Project.  All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *
 | 
			
		||||
 * 1. Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer. 
 | 
			
		||||
 *
 | 
			
		||||
 * 2. Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * 3. All advertising materials mentioning features or use of this
 | 
			
		||||
 *    software must display the following acknowledgment:
 | 
			
		||||
 *    "This product includes software developed by the OpenSSL Project
 | 
			
		||||
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 | 
			
		||||
 *
 | 
			
		||||
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 | 
			
		||||
 *    endorse or promote products derived from this software without
 | 
			
		||||
 *    prior written permission. For written permission, please contact
 | 
			
		||||
 *    licensing@OpenSSL.org.
 | 
			
		||||
 *
 | 
			
		||||
 * 5. Products derived from this software may not be called "OpenSSL"
 | 
			
		||||
 *    nor may "OpenSSL" appear in their names without prior written
 | 
			
		||||
 *    permission of the OpenSSL Project.
 | 
			
		||||
 *
 | 
			
		||||
 * 6. Redistributions of any form whatsoever must retain the following
 | 
			
		||||
 *    acknowledgment:
 | 
			
		||||
 *    "This product includes software developed by the OpenSSL Project
 | 
			
		||||
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 | 
			
		||||
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 | 
			
		||||
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
 | 
			
		||||
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 | 
			
		||||
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 | 
			
		||||
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 | 
			
		||||
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 | 
			
		||||
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 | 
			
		||||
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 | 
			
		||||
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 | 
			
		||||
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
 * ====================================================================
 | 
			
		||||
 *
 | 
			
		||||
 * This product includes cryptographic software written by Eric Young
 | 
			
		||||
 * (eay@cryptsoft.com).  This product includes software written by Tim
 | 
			
		||||
 * Hudson (tjh@cryptsoft.com).
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "cryptlib.h"
 | 
			
		||||
#include <openssl/asn1.h>
 | 
			
		||||
#include <openssl/x509v3.h>
 | 
			
		||||
 | 
			
		||||
#define ASN1_GEN_FLAG		0x10000
 | 
			
		||||
#define ASN1_GEN_FLAG_IMP	(ASN1_GEN_FLAG|1)
 | 
			
		||||
#define ASN1_GEN_FLAG_EXP	(ASN1_GEN_FLAG|2)
 | 
			
		||||
#define ASN1_GEN_FLAG_TAG	(ASN1_GEN_FLAG|3)
 | 
			
		||||
#define ASN1_GEN_FLAG_BITWRAP	(ASN1_GEN_FLAG|4)
 | 
			
		||||
#define ASN1_GEN_FLAG_OCTWRAP	(ASN1_GEN_FLAG|5)
 | 
			
		||||
#define ASN1_GEN_FLAG_SEQWRAP	(ASN1_GEN_FLAG|6)
 | 
			
		||||
#define ASN1_GEN_FLAG_SETWRAP	(ASN1_GEN_FLAG|7)
 | 
			
		||||
#define ASN1_GEN_FLAG_FORMAT	(ASN1_GEN_FLAG|8)
 | 
			
		||||
 | 
			
		||||
#define ASN1_GEN_STR(str,val)	{str, sizeof(str) - 1, val}
 | 
			
		||||
 | 
			
		||||
#define ASN1_FLAG_EXP_MAX	20
 | 
			
		||||
 | 
			
		||||
/* Input formats */
 | 
			
		||||
 | 
			
		||||
/* ASCII: default */
 | 
			
		||||
#define ASN1_GEN_FORMAT_ASCII	1
 | 
			
		||||
/* UTF8 */
 | 
			
		||||
#define ASN1_GEN_FORMAT_UTF8	2
 | 
			
		||||
/* Hex */
 | 
			
		||||
#define ASN1_GEN_FORMAT_HEX	3
 | 
			
		||||
/* List of bits */
 | 
			
		||||
#define ASN1_GEN_FORMAT_BITLIST	4
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct tag_name_st
 | 
			
		||||
	{
 | 
			
		||||
	char *strnam;
 | 
			
		||||
	int len;
 | 
			
		||||
	int tag;
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
typedef struct
 | 
			
		||||
	{
 | 
			
		||||
	int exp_tag;
 | 
			
		||||
	int exp_class;
 | 
			
		||||
	int exp_constructed;
 | 
			
		||||
	int exp_pad;
 | 
			
		||||
	long exp_len;
 | 
			
		||||
	} tag_exp_type;
 | 
			
		||||
 | 
			
		||||
typedef struct
 | 
			
		||||
	{
 | 
			
		||||
	int imp_tag;
 | 
			
		||||
	int imp_class;
 | 
			
		||||
	int utype;
 | 
			
		||||
	int format;
 | 
			
		||||
	const char *str;
 | 
			
		||||
	tag_exp_type exp_list[ASN1_FLAG_EXP_MAX];
 | 
			
		||||
	int exp_count;
 | 
			
		||||
	} tag_exp_arg;
 | 
			
		||||
 | 
			
		||||
static int bitstr_cb(const char *elem, int len, void *bitstr);
 | 
			
		||||
static int asn1_cb(const char *elem, int len, void *bitstr);
 | 
			
		||||
static int append_exp(tag_exp_arg *arg, int exp_tag, int exp_class, int exp_constructed, int exp_pad, int imp_ok);
 | 
			
		||||
static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass);
 | 
			
		||||
static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf);
 | 
			
		||||
static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype);
 | 
			
		||||
static int asn1_str2tag(const char *tagstr, int len);
 | 
			
		||||
 | 
			
		||||
ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf)
 | 
			
		||||
	{
 | 
			
		||||
	X509V3_CTX cnf;
 | 
			
		||||
 | 
			
		||||
	if (!nconf)
 | 
			
		||||
		return ASN1_generate_v3(str, NULL);
 | 
			
		||||
 | 
			
		||||
	X509V3_set_nconf(&cnf, nconf);
 | 
			
		||||
	return ASN1_generate_v3(str, &cnf);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf)
 | 
			
		||||
	{
 | 
			
		||||
	ASN1_TYPE *ret;
 | 
			
		||||
	tag_exp_arg asn1_tags;
 | 
			
		||||
	tag_exp_type *etmp;
 | 
			
		||||
 | 
			
		||||
	int i, len;
 | 
			
		||||
 | 
			
		||||
	unsigned char *orig_der = NULL, *new_der = NULL;
 | 
			
		||||
	unsigned char *cpy_start, *p;
 | 
			
		||||
	int cpy_len;
 | 
			
		||||
	long hdr_len;
 | 
			
		||||
	int hdr_constructed = 0, hdr_tag, hdr_class;
 | 
			
		||||
	int r;
 | 
			
		||||
 | 
			
		||||
	asn1_tags.imp_tag = -1;
 | 
			
		||||
	asn1_tags.imp_class = -1;
 | 
			
		||||
	asn1_tags.format = ASN1_GEN_FORMAT_ASCII;
 | 
			
		||||
	asn1_tags.exp_count = 0;
 | 
			
		||||
	if (CONF_parse_list(str, ',', 1, asn1_cb, &asn1_tags) != 0)
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	if ((asn1_tags.utype == V_ASN1_SEQUENCE) || (asn1_tags.utype == V_ASN1_SET))
 | 
			
		||||
		{
 | 
			
		||||
		if (!cnf)
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_GENERATE_V3, ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG);
 | 
			
		||||
			return NULL;
 | 
			
		||||
			}
 | 
			
		||||
		ret = asn1_multi(asn1_tags.utype, asn1_tags.str, cnf);
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		ret = asn1_str2type(asn1_tags.str, asn1_tags.format, asn1_tags.utype);
 | 
			
		||||
 | 
			
		||||
	if (!ret)
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	/* If no tagging return base type */
 | 
			
		||||
	if ((asn1_tags.imp_tag == -1) && (asn1_tags.exp_count == 0))
 | 
			
		||||
		return ret;
 | 
			
		||||
 | 
			
		||||
	/* Generate the encoding */
 | 
			
		||||
	cpy_len = i2d_ASN1_TYPE(ret, &orig_der);
 | 
			
		||||
	ASN1_TYPE_free(ret);
 | 
			
		||||
	ret = NULL;
 | 
			
		||||
	/* Set point to start copying for modified encoding */
 | 
			
		||||
	cpy_start = orig_der;
 | 
			
		||||
 | 
			
		||||
	/* Do we need IMPLICIT tagging? */
 | 
			
		||||
	if (asn1_tags.imp_tag != -1)
 | 
			
		||||
		{
 | 
			
		||||
		/* If IMPLICIT we will replace the underlying tag */
 | 
			
		||||
		/* Skip existing tag+len */
 | 
			
		||||
		r = ASN1_get_object(&cpy_start, &hdr_len, &hdr_tag, &hdr_class, cpy_len);
 | 
			
		||||
		if (r & 0x80)
 | 
			
		||||
			goto err;
 | 
			
		||||
		/* Update copy length */
 | 
			
		||||
		cpy_len -= cpy_start - orig_der;
 | 
			
		||||
		/* For IMPLICIT tagging the length should match the
 | 
			
		||||
		 * original length and constructed flag should be
 | 
			
		||||
		 * consistent.
 | 
			
		||||
		 */
 | 
			
		||||
		if (r & 0x1)
 | 
			
		||||
			{
 | 
			
		||||
			/* Indefinite length constructed */
 | 
			
		||||
			hdr_constructed = 2;
 | 
			
		||||
			hdr_len = 0;
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
			/* Just retain constructed flag */
 | 
			
		||||
			hdr_constructed = r & V_ASN1_CONSTRUCTED;
 | 
			
		||||
		/* Work out new length with IMPLICIT tag: ignore constructed
 | 
			
		||||
		 * because it will mess up if indefinite length
 | 
			
		||||
		 */
 | 
			
		||||
		len = ASN1_object_size(0, hdr_len, asn1_tags.imp_tag);
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		len = cpy_len;
 | 
			
		||||
 | 
			
		||||
	/* Work out length in any EXPLICIT, starting from end */
 | 
			
		||||
 | 
			
		||||
	for(i = 0, etmp = asn1_tags.exp_list + asn1_tags.exp_count - 1; i < asn1_tags.exp_count; i++, etmp--)
 | 
			
		||||
		{
 | 
			
		||||
		/* Content length: number of content octets + any padding */
 | 
			
		||||
		len += etmp->exp_pad;
 | 
			
		||||
		etmp->exp_len = len;
 | 
			
		||||
		/* Total object length: length including new header */
 | 
			
		||||
		len = ASN1_object_size(0, len, etmp->exp_tag);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	/* Allocate buffer for new encoding */
 | 
			
		||||
 | 
			
		||||
	new_der = OPENSSL_malloc(len);
 | 
			
		||||
 | 
			
		||||
	/* Generate tagged encoding */
 | 
			
		||||
 | 
			
		||||
	p = new_der;
 | 
			
		||||
 | 
			
		||||
	/* Output explicit tags first */
 | 
			
		||||
 | 
			
		||||
	for (i = 0, etmp = asn1_tags.exp_list; i < asn1_tags.exp_count; i++, etmp++)
 | 
			
		||||
		{
 | 
			
		||||
		ASN1_put_object(&p, etmp->exp_constructed, etmp->exp_len,
 | 
			
		||||
					etmp->exp_tag, etmp->exp_class);
 | 
			
		||||
		if (etmp->exp_pad)
 | 
			
		||||
			*p++ = 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	/* If IMPLICIT, output tag */
 | 
			
		||||
 | 
			
		||||
	if (asn1_tags.imp_tag != -1)
 | 
			
		||||
		ASN1_put_object(&p, hdr_constructed, hdr_len,
 | 
			
		||||
					asn1_tags.imp_tag, asn1_tags.imp_class);
 | 
			
		||||
 | 
			
		||||
	/* Copy across original encoding */
 | 
			
		||||
	memcpy(p, cpy_start, cpy_len);
 | 
			
		||||
 | 
			
		||||
	p = new_der;
 | 
			
		||||
 | 
			
		||||
	/* Obtain new ASN1_TYPE structure */
 | 
			
		||||
	ret = d2i_ASN1_TYPE(NULL, &p, len);
 | 
			
		||||
 | 
			
		||||
	err:
 | 
			
		||||
	if (orig_der)
 | 
			
		||||
		OPENSSL_free(orig_der);
 | 
			
		||||
	if (new_der)
 | 
			
		||||
		OPENSSL_free(new_der);
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int asn1_cb(const char *elem, int len, void *bitstr)
 | 
			
		||||
	{
 | 
			
		||||
	tag_exp_arg *arg = bitstr;
 | 
			
		||||
	int i;
 | 
			
		||||
	int utype;
 | 
			
		||||
	int vlen = 0;
 | 
			
		||||
	const char *p, *vstart = NULL;
 | 
			
		||||
 | 
			
		||||
	int tmp_tag, tmp_class;
 | 
			
		||||
 | 
			
		||||
	for(i = 0, p = elem; i < len; p++, i++)
 | 
			
		||||
		{
 | 
			
		||||
		/* Look for the ':' in name value pairs */
 | 
			
		||||
		if (*p == ':')
 | 
			
		||||
			{
 | 
			
		||||
			vstart = p + 1;
 | 
			
		||||
			vlen = len - (vstart - elem);
 | 
			
		||||
			len = p - elem;
 | 
			
		||||
			break;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	utype = asn1_str2tag(elem, len);
 | 
			
		||||
 | 
			
		||||
	if (utype == -1)
 | 
			
		||||
		{
 | 
			
		||||
		ASN1err(ASN1_F_ASN1_CB, ASN1_R_UNKNOWN_TAG);
 | 
			
		||||
		ERR_add_error_data(2, "tag=", elem);
 | 
			
		||||
		return -1;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	/* If this is not a modifier mark end of string and exit */
 | 
			
		||||
	if (!(utype & ASN1_GEN_FLAG))
 | 
			
		||||
		{
 | 
			
		||||
		arg->utype = utype;
 | 
			
		||||
		arg->str = vstart;
 | 
			
		||||
		/* If no value and not end of string, error */
 | 
			
		||||
		if (!vstart && elem[len])
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_CB, ASN1_R_MISSING_VALUE);
 | 
			
		||||
			return -1;
 | 
			
		||||
			}
 | 
			
		||||
		return 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	switch(utype)
 | 
			
		||||
		{
 | 
			
		||||
 | 
			
		||||
		case ASN1_GEN_FLAG_IMP:
 | 
			
		||||
		/* Check for illegal multiple IMPLICIT tagging */
 | 
			
		||||
		if (arg->imp_tag != -1)
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_CB, ASN1_R_ILLEGAL_NESTED_TAGGING);
 | 
			
		||||
			return -1;
 | 
			
		||||
			}
 | 
			
		||||
		if (!parse_tagging(vstart, vlen, &arg->imp_tag, &arg->imp_class))
 | 
			
		||||
			return -1;
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		case ASN1_GEN_FLAG_EXP:
 | 
			
		||||
 | 
			
		||||
		if (!parse_tagging(vstart, vlen, &tmp_tag, &tmp_class))
 | 
			
		||||
			return -1;
 | 
			
		||||
		if (!append_exp(arg, tmp_tag, tmp_class, 1, 0, 0))
 | 
			
		||||
			return -1;
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		case ASN1_GEN_FLAG_SEQWRAP:
 | 
			
		||||
		if (!append_exp(arg, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, 1, 0, 1))
 | 
			
		||||
			return -1;
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		case ASN1_GEN_FLAG_SETWRAP:
 | 
			
		||||
		if (!append_exp(arg, V_ASN1_SET, V_ASN1_UNIVERSAL, 1, 0, 1))
 | 
			
		||||
			return -1;
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		case ASN1_GEN_FLAG_BITWRAP:
 | 
			
		||||
		if (!append_exp(arg, V_ASN1_BIT_STRING, V_ASN1_UNIVERSAL, 0, 1, 1))
 | 
			
		||||
			return -1;
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		case ASN1_GEN_FLAG_OCTWRAP:
 | 
			
		||||
		if (!append_exp(arg, V_ASN1_OCTET_STRING, V_ASN1_UNIVERSAL, 0, 0, 1))
 | 
			
		||||
			return -1;
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		case ASN1_GEN_FLAG_FORMAT:
 | 
			
		||||
		if (!strncmp(vstart, "ASCII", 5))
 | 
			
		||||
			arg->format = ASN1_GEN_FORMAT_ASCII;
 | 
			
		||||
		else if (!strncmp(vstart, "UTF8", 4))
 | 
			
		||||
			arg->format = ASN1_GEN_FORMAT_UTF8;
 | 
			
		||||
		else if (!strncmp(vstart, "HEX", 3))
 | 
			
		||||
			arg->format = ASN1_GEN_FORMAT_HEX;
 | 
			
		||||
		else if (!strncmp(vstart, "BITLIST", 3))
 | 
			
		||||
			arg->format = ASN1_GEN_FORMAT_BITLIST;
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_CB, ASN1_R_UNKOWN_FORMAT);
 | 
			
		||||
			return -1;
 | 
			
		||||
			}
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	return 1;
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass)
 | 
			
		||||
	{
 | 
			
		||||
	char erch[2];
 | 
			
		||||
	long tag_num;
 | 
			
		||||
	char *eptr;
 | 
			
		||||
	if (!vstart)
 | 
			
		||||
		return 0;
 | 
			
		||||
	tag_num = strtoul(vstart, &eptr, 10);
 | 
			
		||||
	/* Check we haven't gone past max length: should be impossible */
 | 
			
		||||
	if (eptr && *eptr && (eptr > vstart + vlen))
 | 
			
		||||
		return 0;
 | 
			
		||||
	if (tag_num < 0)
 | 
			
		||||
		{
 | 
			
		||||
		ASN1err(ASN1_F_PARSE_TAGGING, ASN1_R_INVALID_NUMBER);
 | 
			
		||||
		return 0;
 | 
			
		||||
		}
 | 
			
		||||
	*ptag = tag_num;
 | 
			
		||||
	/* If we have non numeric characters, parse them */
 | 
			
		||||
	if (eptr)
 | 
			
		||||
		vlen -= eptr - vstart;
 | 
			
		||||
	else 
 | 
			
		||||
		vlen = 0;
 | 
			
		||||
	if (vlen)
 | 
			
		||||
		{
 | 
			
		||||
		switch (*eptr)
 | 
			
		||||
			{
 | 
			
		||||
 | 
			
		||||
			case 'U':
 | 
			
		||||
			*pclass = V_ASN1_UNIVERSAL;
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
			case 'A':
 | 
			
		||||
			*pclass = V_ASN1_APPLICATION;
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
			case 'P':
 | 
			
		||||
			*pclass = V_ASN1_PRIVATE;
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
			case 'C':
 | 
			
		||||
			*pclass = V_ASN1_CONTEXT_SPECIFIC;
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
			default:
 | 
			
		||||
			erch[0] = *eptr;
 | 
			
		||||
			erch[1] = 0;
 | 
			
		||||
			ASN1err(ASN1_F_PARSE_TAGGING, ASN1_R_INVALID_MODIFIER);
 | 
			
		||||
			ERR_add_error_data(2, "Char=", erch);
 | 
			
		||||
			return 0;
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		*pclass = V_ASN1_CONTEXT_SPECIFIC;
 | 
			
		||||
 | 
			
		||||
	return 1;
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/* Handle multiple types: SET and SEQUENCE */
 | 
			
		||||
 | 
			
		||||
static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf)
 | 
			
		||||
	{
 | 
			
		||||
	ASN1_TYPE *ret = NULL, *typ = NULL;
 | 
			
		||||
	STACK_OF(ASN1_TYPE) *sk = NULL;
 | 
			
		||||
	STACK_OF(CONF_VALUE) *sect = NULL;
 | 
			
		||||
	unsigned char *der = NULL, *p;
 | 
			
		||||
	int derlen;
 | 
			
		||||
	int i, is_set;
 | 
			
		||||
	sk = sk_ASN1_TYPE_new_null();
 | 
			
		||||
	if (section)
 | 
			
		||||
		{
 | 
			
		||||
		if (!cnf)
 | 
			
		||||
			goto bad;
 | 
			
		||||
		sect = X509V3_get_section(cnf, (char *)section);
 | 
			
		||||
		if (!sect)
 | 
			
		||||
			goto bad;
 | 
			
		||||
		for (i = 0; i < sk_CONF_VALUE_num(sect); i++)
 | 
			
		||||
			{
 | 
			
		||||
			typ = ASN1_generate_v3(sk_CONF_VALUE_value(sect, i)->value, cnf);
 | 
			
		||||
			if (!typ)
 | 
			
		||||
				goto bad;
 | 
			
		||||
			sk_ASN1_TYPE_push(sk, typ);
 | 
			
		||||
			typ = NULL;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	/* Now we has a STACK of the components, convert to the correct form */
 | 
			
		||||
 | 
			
		||||
	if (utype == V_ASN1_SET)
 | 
			
		||||
		is_set = 1;
 | 
			
		||||
	else
 | 
			
		||||
		is_set = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	derlen = i2d_ASN1_SET((STACK *)sk, NULL, i2d_ASN1_TYPE, utype, V_ASN1_UNIVERSAL, is_set);
 | 
			
		||||
	der = OPENSSL_malloc(derlen);
 | 
			
		||||
	p = der;
 | 
			
		||||
	i2d_ASN1_SET((STACK *)sk, &p, i2d_ASN1_TYPE, utype, V_ASN1_UNIVERSAL, is_set);
 | 
			
		||||
 | 
			
		||||
	if (!(ret = ASN1_TYPE_new()))
 | 
			
		||||
		goto bad;
 | 
			
		||||
 | 
			
		||||
	if (!(ret->value.asn1_string = ASN1_STRING_type_new(utype)))
 | 
			
		||||
		goto bad;
 | 
			
		||||
 | 
			
		||||
	ret->type = utype;
 | 
			
		||||
 | 
			
		||||
	ret->value.asn1_string->data = der;
 | 
			
		||||
	ret->value.asn1_string->length = derlen;
 | 
			
		||||
 | 
			
		||||
	der = NULL;
 | 
			
		||||
 | 
			
		||||
	bad:
 | 
			
		||||
 | 
			
		||||
	if (der)
 | 
			
		||||
		OPENSSL_free(der);
 | 
			
		||||
 | 
			
		||||
	if (sk)
 | 
			
		||||
		sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
 | 
			
		||||
	if (typ)
 | 
			
		||||
		ASN1_TYPE_free(typ);
 | 
			
		||||
	if (sect)
 | 
			
		||||
		X509V3_section_free(cnf, sect);
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int append_exp(tag_exp_arg *arg, int exp_tag, int exp_class, int exp_constructed, int exp_pad, int imp_ok)
 | 
			
		||||
	{
 | 
			
		||||
	tag_exp_type *exp_tmp;
 | 
			
		||||
	/* Can only have IMPLICIT if permitted */
 | 
			
		||||
	if ((arg->imp_tag != -1) && !imp_ok)
 | 
			
		||||
		{
 | 
			
		||||
		ASN1err(ASN1_F_APPEND_TAG, ASN1_R_ILLEGAL_IMPLICIT_TAG);
 | 
			
		||||
		return 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (arg->exp_count == ASN1_FLAG_EXP_MAX)
 | 
			
		||||
		{
 | 
			
		||||
		ASN1err(ASN1_F_APPEND_TAG, ASN1_R_DEPTH_EXCEEDED);
 | 
			
		||||
		return 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	exp_tmp = &arg->exp_list[arg->exp_count++];
 | 
			
		||||
 | 
			
		||||
	/* If IMPLICIT set tag to implicit value then
 | 
			
		||||
	 * reset implicit tag since it has been used.
 | 
			
		||||
	 */
 | 
			
		||||
	if (arg->imp_tag != -1)
 | 
			
		||||
		{
 | 
			
		||||
		exp_tmp->exp_tag = arg->imp_tag;
 | 
			
		||||
		exp_tmp->exp_class = arg->imp_class;
 | 
			
		||||
		arg->imp_tag = -1;
 | 
			
		||||
		arg->imp_class = -1;
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
		exp_tmp->exp_tag = exp_tag;
 | 
			
		||||
		exp_tmp->exp_class = exp_class;
 | 
			
		||||
		}
 | 
			
		||||
	exp_tmp->exp_constructed = exp_constructed;
 | 
			
		||||
	exp_tmp->exp_pad = exp_pad;
 | 
			
		||||
 | 
			
		||||
	return 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int asn1_str2tag(const char *tagstr, int len)
 | 
			
		||||
	{
 | 
			
		||||
	int i;
 | 
			
		||||
	static struct tag_name_st *tntmp, tnst [] = {
 | 
			
		||||
		ASN1_GEN_STR("BOOL", V_ASN1_BOOLEAN),
 | 
			
		||||
		ASN1_GEN_STR("BOOLEAN", V_ASN1_BOOLEAN),
 | 
			
		||||
		ASN1_GEN_STR("NULL", V_ASN1_NULL),
 | 
			
		||||
		ASN1_GEN_STR("INT", V_ASN1_INTEGER),
 | 
			
		||||
		ASN1_GEN_STR("INTEGER", V_ASN1_INTEGER),
 | 
			
		||||
		ASN1_GEN_STR("ENUM", V_ASN1_ENUMERATED),
 | 
			
		||||
		ASN1_GEN_STR("ENUMERATED", V_ASN1_ENUMERATED),
 | 
			
		||||
		ASN1_GEN_STR("OID", V_ASN1_OBJECT),
 | 
			
		||||
		ASN1_GEN_STR("OBJECT", V_ASN1_OBJECT),
 | 
			
		||||
		ASN1_GEN_STR("UTCTIME", V_ASN1_UTCTIME),
 | 
			
		||||
		ASN1_GEN_STR("UTC", V_ASN1_UTCTIME),
 | 
			
		||||
		ASN1_GEN_STR("GENERALIZEDTIME", V_ASN1_GENERALIZEDTIME),
 | 
			
		||||
		ASN1_GEN_STR("GENTIME", V_ASN1_GENERALIZEDTIME),
 | 
			
		||||
		ASN1_GEN_STR("OCT", V_ASN1_OCTET_STRING),
 | 
			
		||||
		ASN1_GEN_STR("OCTETSTRING", V_ASN1_OCTET_STRING),
 | 
			
		||||
		ASN1_GEN_STR("BITSTR", V_ASN1_BIT_STRING),
 | 
			
		||||
		ASN1_GEN_STR("BITSTRING", V_ASN1_BIT_STRING),
 | 
			
		||||
		ASN1_GEN_STR("UNIVERSALSTRING", V_ASN1_UNIVERSALSTRING),
 | 
			
		||||
		ASN1_GEN_STR("UNIV", V_ASN1_UNIVERSALSTRING),
 | 
			
		||||
		ASN1_GEN_STR("IA5", V_ASN1_IA5STRING),
 | 
			
		||||
		ASN1_GEN_STR("IA5STRING", V_ASN1_IA5STRING),
 | 
			
		||||
		ASN1_GEN_STR("UTF8", V_ASN1_UTF8STRING),
 | 
			
		||||
		ASN1_GEN_STR("UTF8String", V_ASN1_UTF8STRING),
 | 
			
		||||
		ASN1_GEN_STR("BMP", V_ASN1_BMPSTRING),
 | 
			
		||||
		ASN1_GEN_STR("BMPSTRING", V_ASN1_BMPSTRING),
 | 
			
		||||
		ASN1_GEN_STR("VISIBLESTRING", V_ASN1_VISIBLESTRING),
 | 
			
		||||
		ASN1_GEN_STR("VISIBLE", V_ASN1_VISIBLESTRING),
 | 
			
		||||
		ASN1_GEN_STR("PRINTABLESTRING", V_ASN1_PRINTABLESTRING),
 | 
			
		||||
		ASN1_GEN_STR("PRINTABLE", V_ASN1_PRINTABLESTRING),
 | 
			
		||||
		ASN1_GEN_STR("T61", V_ASN1_T61STRING),
 | 
			
		||||
		ASN1_GEN_STR("T61STRING", V_ASN1_T61STRING),
 | 
			
		||||
		ASN1_GEN_STR("TELETEXSTRING", V_ASN1_T61STRING),
 | 
			
		||||
		ASN1_GEN_STR("GeneralString", V_ASN1_GENERALSTRING),
 | 
			
		||||
		ASN1_GEN_STR("GENSTR", V_ASN1_GENERALSTRING),
 | 
			
		||||
 | 
			
		||||
		/* Special cases */
 | 
			
		||||
		ASN1_GEN_STR("SEQUENCE", V_ASN1_SEQUENCE),
 | 
			
		||||
		ASN1_GEN_STR("SEQ", V_ASN1_SEQUENCE),
 | 
			
		||||
		ASN1_GEN_STR("SET", V_ASN1_SET),
 | 
			
		||||
		/* type modifiers */
 | 
			
		||||
		/* Explicit tag */
 | 
			
		||||
		ASN1_GEN_STR("EXP", ASN1_GEN_FLAG_EXP),
 | 
			
		||||
		ASN1_GEN_STR("EXPLICIT", ASN1_GEN_FLAG_EXP),
 | 
			
		||||
		/* Implicit tag */
 | 
			
		||||
		ASN1_GEN_STR("IMP", ASN1_GEN_FLAG_IMP),
 | 
			
		||||
		ASN1_GEN_STR("IMPLICIT", ASN1_GEN_FLAG_IMP),
 | 
			
		||||
		/* OCTET STRING wrapper */
 | 
			
		||||
		ASN1_GEN_STR("OCTWRAP", ASN1_GEN_FLAG_OCTWRAP),
 | 
			
		||||
		/* SEQUENCE wrapper */
 | 
			
		||||
		ASN1_GEN_STR("SEQWRAP", ASN1_GEN_FLAG_SEQWRAP),
 | 
			
		||||
		/* SET wrapper */
 | 
			
		||||
		ASN1_GEN_STR("SETWRAP", ASN1_GEN_FLAG_SETWRAP),
 | 
			
		||||
		/* BIT STRING wrapper */
 | 
			
		||||
		ASN1_GEN_STR("BITWRAP", ASN1_GEN_FLAG_BITWRAP),
 | 
			
		||||
		ASN1_GEN_STR("FORM", ASN1_GEN_FLAG_FORMAT),
 | 
			
		||||
		ASN1_GEN_STR("FORMAT", ASN1_GEN_FLAG_FORMAT),
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	if (len == -1)
 | 
			
		||||
		len = strlen(tagstr);
 | 
			
		||||
	
 | 
			
		||||
	tntmp = tnst;	
 | 
			
		||||
	for (i = 0; i < sizeof(tnst) / sizeof(struct tag_name_st); i++, tntmp++)
 | 
			
		||||
		{
 | 
			
		||||
		if ((len == tntmp->len) && !strncmp(tntmp->strnam, tagstr, len))
 | 
			
		||||
			return tntmp->tag;
 | 
			
		||||
		}
 | 
			
		||||
	
 | 
			
		||||
	return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype)
 | 
			
		||||
	{
 | 
			
		||||
	ASN1_TYPE *atmp = NULL;
 | 
			
		||||
 | 
			
		||||
	CONF_VALUE vtmp;
 | 
			
		||||
 | 
			
		||||
	unsigned char *rdata;
 | 
			
		||||
	long rdlen;
 | 
			
		||||
 | 
			
		||||
	int no_unused = 1;
 | 
			
		||||
 | 
			
		||||
	if (!(atmp = ASN1_TYPE_new()))
 | 
			
		||||
		{
 | 
			
		||||
		ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE);
 | 
			
		||||
		return NULL;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (!str)
 | 
			
		||||
		str = "";
 | 
			
		||||
 | 
			
		||||
	switch(utype)
 | 
			
		||||
		{
 | 
			
		||||
 | 
			
		||||
		case V_ASN1_NULL:
 | 
			
		||||
		if (str && *str)
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_NULL_VALUE);
 | 
			
		||||
			goto bad_form;
 | 
			
		||||
			}
 | 
			
		||||
		break;
 | 
			
		||||
		
 | 
			
		||||
		case V_ASN1_BOOLEAN:
 | 
			
		||||
		if (format != ASN1_GEN_FORMAT_ASCII)
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_NOT_ASCII_FORMAT);
 | 
			
		||||
			goto bad_form;
 | 
			
		||||
			}
 | 
			
		||||
		vtmp.value = (char *)str;
 | 
			
		||||
		if (!X509V3_get_value_bool(&vtmp, &atmp->value.boolean))
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_BOOLEAN);
 | 
			
		||||
			goto bad_str;
 | 
			
		||||
			}
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		case V_ASN1_INTEGER:
 | 
			
		||||
		case V_ASN1_ENUMERATED:
 | 
			
		||||
		if (format != ASN1_GEN_FORMAT_ASCII)
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_INTEGER_NOT_ASCII_FORMAT);
 | 
			
		||||
			goto bad_form;
 | 
			
		||||
			}
 | 
			
		||||
		if (!(atmp->value.integer = s2i_ASN1_INTEGER(NULL, (char *)str)))
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_INTEGER);
 | 
			
		||||
			goto bad_str;
 | 
			
		||||
			}
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		case V_ASN1_OBJECT:
 | 
			
		||||
		if (format != ASN1_GEN_FORMAT_ASCII)
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_OBJECT_NOT_ASCII_FORMAT);
 | 
			
		||||
			goto bad_form;
 | 
			
		||||
			}
 | 
			
		||||
		if (!(atmp->value.object = OBJ_txt2obj(str, 0)))
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_OBJECT);
 | 
			
		||||
			goto bad_str;
 | 
			
		||||
			}
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		case V_ASN1_UTCTIME:
 | 
			
		||||
		case V_ASN1_GENERALIZEDTIME:
 | 
			
		||||
		if (format != ASN1_GEN_FORMAT_ASCII)
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_TIME_NOT_ASCII_FORMAT);
 | 
			
		||||
			goto bad_form;
 | 
			
		||||
			}
 | 
			
		||||
		if (!(atmp->value.asn1_string = ASN1_STRING_new()))
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE);
 | 
			
		||||
			goto bad_str;
 | 
			
		||||
			}
 | 
			
		||||
		if (!ASN1_STRING_set(atmp->value.asn1_string, str, -1))
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE);
 | 
			
		||||
			goto bad_str;
 | 
			
		||||
			}
 | 
			
		||||
		atmp->value.asn1_string->type = utype;
 | 
			
		||||
		if (!ASN1_TIME_check(atmp->value.asn1_string))
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_TIME_VALUE);
 | 
			
		||||
			goto bad_str;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		case V_ASN1_BMPSTRING:
 | 
			
		||||
		case V_ASN1_PRINTABLESTRING:
 | 
			
		||||
		case V_ASN1_IA5STRING:
 | 
			
		||||
		case V_ASN1_T61STRING:
 | 
			
		||||
		case V_ASN1_UTF8STRING:
 | 
			
		||||
		case V_ASN1_VISIBLESTRING:
 | 
			
		||||
		case V_ASN1_UNIVERSALSTRING:
 | 
			
		||||
		case V_ASN1_GENERALSTRING:
 | 
			
		||||
 | 
			
		||||
		if (format == ASN1_GEN_FORMAT_ASCII)
 | 
			
		||||
			format = MBSTRING_ASC;
 | 
			
		||||
		else if (format == ASN1_GEN_FORMAT_UTF8)
 | 
			
		||||
			format = MBSTRING_UTF8;
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_FORMAT);
 | 
			
		||||
			goto bad_form;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		if (ASN1_mbstring_copy(&atmp->value.asn1_string, (unsigned char *)str,
 | 
			
		||||
						-1, format, ASN1_tag2bit(utype)) <= 0)
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE);
 | 
			
		||||
			goto bad_str;
 | 
			
		||||
			}
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		case V_ASN1_BIT_STRING:
 | 
			
		||||
 | 
			
		||||
		case V_ASN1_OCTET_STRING:
 | 
			
		||||
 | 
			
		||||
		if (!(atmp->value.asn1_string = ASN1_STRING_new()))
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE);
 | 
			
		||||
			goto bad_form;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		if (format == ASN1_GEN_FORMAT_HEX)
 | 
			
		||||
			{
 | 
			
		||||
 | 
			
		||||
			if (!(rdata = string_to_hex((char *)str, &rdlen)))
 | 
			
		||||
				{
 | 
			
		||||
				ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_HEX);
 | 
			
		||||
				goto bad_str;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
			atmp->value.asn1_string->data = rdata;
 | 
			
		||||
			atmp->value.asn1_string->length = rdlen;
 | 
			
		||||
			atmp->value.asn1_string->type = utype;
 | 
			
		||||
 | 
			
		||||
			}
 | 
			
		||||
		else if (format == ASN1_GEN_FORMAT_ASCII)
 | 
			
		||||
			ASN1_STRING_set(atmp->value.asn1_string, str, -1);
 | 
			
		||||
		else if ((format == ASN1_GEN_FORMAT_BITLIST) && (utype == V_ASN1_BIT_STRING))
 | 
			
		||||
			{
 | 
			
		||||
			if (!CONF_parse_list(str, ',', 1, bitstr_cb, atmp->value.bit_string))
 | 
			
		||||
				{
 | 
			
		||||
				ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_LIST_ERROR);
 | 
			
		||||
				goto bad_str;
 | 
			
		||||
				}
 | 
			
		||||
			no_unused = 0;
 | 
			
		||||
			
 | 
			
		||||
			}
 | 
			
		||||
		else 
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_BITSTRING_FORMAT);
 | 
			
		||||
			goto bad_form;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		if ((utype == V_ASN1_BIT_STRING) && no_unused)
 | 
			
		||||
			{
 | 
			
		||||
			atmp->value.asn1_string->flags
 | 
			
		||||
				&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);
 | 
			
		||||
        		atmp->value.asn1_string->flags
 | 
			
		||||
				|= ASN1_STRING_FLAG_BITS_LEFT;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		default:
 | 
			
		||||
		ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_UNSUPPORTED_TYPE);
 | 
			
		||||
		goto bad_str;
 | 
			
		||||
		break;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	atmp->type = utype;
 | 
			
		||||
	return atmp;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	bad_str:
 | 
			
		||||
	ERR_add_error_data(2, "string=", str);
 | 
			
		||||
	bad_form:
 | 
			
		||||
 | 
			
		||||
	ASN1_TYPE_free(atmp);
 | 
			
		||||
	return NULL;
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int bitstr_cb(const char *elem, int len, void *bitstr)
 | 
			
		||||
	{
 | 
			
		||||
	long bitnum;
 | 
			
		||||
	char *eptr;
 | 
			
		||||
	if (!elem)
 | 
			
		||||
		return 0;
 | 
			
		||||
	bitnum = strtoul(elem, &eptr, 10);
 | 
			
		||||
	if (eptr && *eptr && (eptr != elem + len))
 | 
			
		||||
		return 0;
 | 
			
		||||
	if (bitnum < 0)
 | 
			
		||||
		{
 | 
			
		||||
		ASN1err(ASN1_F_BITSTR_CB, ASN1_R_INVALID_NUMBER);
 | 
			
		||||
		return 0;
 | 
			
		||||
		}
 | 
			
		||||
	if (!ASN1_BIT_STRING_set_bit(bitstr, bitnum, 1))
 | 
			
		||||
		{
 | 
			
		||||
		ASN1err(ASN1_F_BITSTR_CB, ERR_R_MALLOC_FAILURE);
 | 
			
		||||
		return 0;
 | 
			
		||||
		}
 | 
			
		||||
	return 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -104,10 +104,12 @@ int ASN1_get_object(unsigned char **pp, long *plength, int *ptag, int *pclass,
 | 
			
		||||
			l<<=7L;
 | 
			
		||||
			l|= *(p++)&0x7f;
 | 
			
		||||
			if (--max == 0) goto err;
 | 
			
		||||
			if (l > (INT_MAX >> 7L)) goto err;
 | 
			
		||||
			}
 | 
			
		||||
		l<<=7L;
 | 
			
		||||
		l|= *(p++)&0x7f;
 | 
			
		||||
		tag=(int)l;
 | 
			
		||||
		if (--max == 0) goto err;
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		{ 
 | 
			
		||||
@@ -203,22 +205,13 @@ void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag,
 | 
			
		||||
			}
 | 
			
		||||
		p += ttag;
 | 
			
		||||
		}
 | 
			
		||||
	if (constructed == 2)
 | 
			
		||||
		*(p++)=0x80;
 | 
			
		||||
	if ((constructed == 2) && (length == 0))
 | 
			
		||||
		*(p++)=0x80; /* der_put_length would output 0 instead */
 | 
			
		||||
	else
 | 
			
		||||
		asn1_put_length(&p,length);
 | 
			
		||||
	*pp=p;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int ASN1_put_eoc(unsigned char **pp)
 | 
			
		||||
	{
 | 
			
		||||
	unsigned char *p = *pp;
 | 
			
		||||
	*p++ = 0;
 | 
			
		||||
	*p++ = 0;
 | 
			
		||||
	*pp = p;
 | 
			
		||||
	return 2;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static void asn1_put_length(unsigned char **pp, int length)
 | 
			
		||||
	{
 | 
			
		||||
	unsigned char *p= *pp;
 | 
			
		||||
@@ -256,8 +249,8 @@ int ASN1_object_size(int constructed, int length, int tag)
 | 
			
		||||
			ret++;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	if (constructed == 2)
 | 
			
		||||
		return ret + 3;
 | 
			
		||||
	if ((length == 0) && (constructed == 2))
 | 
			
		||||
		ret+=2;
 | 
			
		||||
	ret++;
 | 
			
		||||
	if (length > 127)
 | 
			
		||||
		{
 | 
			
		||||
 
 | 
			
		||||
@@ -256,11 +256,9 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
 | 
			
		||||
 | 
			
		||||
				opp=op;
 | 
			
		||||
				os=d2i_ASN1_OCTET_STRING(NULL,&opp,len+hl);
 | 
			
		||||
				if (os != NULL && os->length > 0)
 | 
			
		||||
				if (os != NULL)
 | 
			
		||||
					{
 | 
			
		||||
					opp=os->data;
 | 
			
		||||
					/* testing whether the octet string is
 | 
			
		||||
					 * printable */
 | 
			
		||||
					for (i=0; i<os->length; i++)
 | 
			
		||||
						{
 | 
			
		||||
						if ((	(opp[i] < ' ') &&
 | 
			
		||||
@@ -273,8 +271,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
 | 
			
		||||
							break;
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
					if (printable)
 | 
			
		||||
					/* printable string */
 | 
			
		||||
					if (printable && (os->length > 0))
 | 
			
		||||
						{
 | 
			
		||||
						if (BIO_write(bp,":",1) <= 0)
 | 
			
		||||
							goto end;
 | 
			
		||||
@@ -282,21 +279,8 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
 | 
			
		||||
							os->length) <= 0)
 | 
			
		||||
							goto end;
 | 
			
		||||
						}
 | 
			
		||||
					else if (!dump)
 | 
			
		||||
					/* not printable => print octet string
 | 
			
		||||
					 * as hex dump */
 | 
			
		||||
						{
 | 
			
		||||
						if (BIO_write(bp,"[HEX DUMP]:",11) <= 0)
 | 
			
		||||
							goto end;
 | 
			
		||||
						for (i=0; i<os->length; i++)
 | 
			
		||||
							{
 | 
			
		||||
							if (BIO_printf(bp,"%02X"
 | 
			
		||||
								, opp[i]) <= 0)
 | 
			
		||||
								goto end;
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
					else
 | 
			
		||||
					/* print the normal dump */
 | 
			
		||||
					if (!printable && (os->length > 0)
 | 
			
		||||
						&& dump)
 | 
			
		||||
						{
 | 
			
		||||
						if (!nl) 
 | 
			
		||||
							{
 | 
			
		||||
@@ -304,15 +288,11 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
 | 
			
		||||
								goto end;
 | 
			
		||||
							}
 | 
			
		||||
						if (BIO_dump_indent(bp,(char *)opp,
 | 
			
		||||
							((dump == -1 || dump > 
 | 
			
		||||
							os->length)?os->length:dump),
 | 
			
		||||
							((dump == -1 || dump > os->length)?os->length:dump),
 | 
			
		||||
							dump_indent) <= 0)
 | 
			
		||||
							goto end;
 | 
			
		||||
						nl=1;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				if (os != NULL)
 | 
			
		||||
					{
 | 
			
		||||
					M_ASN1_OCTET_STRING_free(os);
 | 
			
		||||
					os=NULL;
 | 
			
		||||
					}
 | 
			
		||||
 
 | 
			
		||||
@@ -112,7 +112,7 @@ extern "C" {
 | 
			
		||||
/* Macros to aid ASN1 template writing */
 | 
			
		||||
 | 
			
		||||
#define ASN1_ITEM_TEMPLATE(tname) \
 | 
			
		||||
	static const ASN1_TEMPLATE tname##_item_tt 
 | 
			
		||||
	const static ASN1_TEMPLATE tname##_item_tt 
 | 
			
		||||
 | 
			
		||||
#define ASN1_ITEM_TEMPLATE_END(tname) \
 | 
			
		||||
	;\
 | 
			
		||||
@@ -150,7 +150,7 @@ extern "C" {
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define ASN1_SEQUENCE(tname) \
 | 
			
		||||
	static const ASN1_TEMPLATE tname##_seq_tt[] 
 | 
			
		||||
	const static ASN1_TEMPLATE tname##_seq_tt[] 
 | 
			
		||||
 | 
			
		||||
#define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)
 | 
			
		||||
 | 
			
		||||
@@ -166,37 +166,22 @@ extern "C" {
 | 
			
		||||
		#stname \
 | 
			
		||||
	ASN1_ITEM_end(tname)
 | 
			
		||||
 | 
			
		||||
#define ASN1_NDEF_SEQUENCE(tname) \
 | 
			
		||||
	ASN1_SEQUENCE(tname)
 | 
			
		||||
 | 
			
		||||
#define ASN1_SEQUENCE_cb(tname, cb) \
 | 
			
		||||
	static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
 | 
			
		||||
	const static ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
 | 
			
		||||
	ASN1_SEQUENCE(tname)
 | 
			
		||||
 | 
			
		||||
#define ASN1_BROKEN_SEQUENCE(tname) \
 | 
			
		||||
	static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \
 | 
			
		||||
	const static ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \
 | 
			
		||||
	ASN1_SEQUENCE(tname)
 | 
			
		||||
 | 
			
		||||
#define ASN1_SEQUENCE_ref(tname, cb, lck) \
 | 
			
		||||
	static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \
 | 
			
		||||
	const static ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \
 | 
			
		||||
	ASN1_SEQUENCE(tname)
 | 
			
		||||
 | 
			
		||||
#define ASN1_SEQUENCE_enc(tname, enc, cb) \
 | 
			
		||||
	static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \
 | 
			
		||||
	const static ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \
 | 
			
		||||
	ASN1_SEQUENCE(tname)
 | 
			
		||||
 | 
			
		||||
#define ASN1_NDEF_SEQUENCE_END(tname) \
 | 
			
		||||
	;\
 | 
			
		||||
	ASN1_ITEM_start(tname) \
 | 
			
		||||
		ASN1_ITYPE_NDEF_SEQUENCE,\
 | 
			
		||||
		V_ASN1_SEQUENCE,\
 | 
			
		||||
		tname##_seq_tt,\
 | 
			
		||||
		sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
 | 
			
		||||
		NULL,\
 | 
			
		||||
		sizeof(tname),\
 | 
			
		||||
		#tname \
 | 
			
		||||
	ASN1_ITEM_end(tname)
 | 
			
		||||
 | 
			
		||||
#define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)
 | 
			
		||||
 | 
			
		||||
#define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
 | 
			
		||||
@@ -239,10 +224,10 @@ extern "C" {
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define ASN1_CHOICE(tname) \
 | 
			
		||||
	static const ASN1_TEMPLATE tname##_ch_tt[] 
 | 
			
		||||
	const static ASN1_TEMPLATE tname##_ch_tt[] 
 | 
			
		||||
 | 
			
		||||
#define ASN1_CHOICE_cb(tname, cb) \
 | 
			
		||||
	static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
 | 
			
		||||
	const static ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
 | 
			
		||||
	ASN1_CHOICE(tname)
 | 
			
		||||
 | 
			
		||||
#define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)
 | 
			
		||||
@@ -368,20 +353,16 @@ extern "C" {
 | 
			
		||||
#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \
 | 
			
		||||
			ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
 | 
			
		||||
 | 
			
		||||
/* EXPLICIT OPTIONAL using indefinite length constructed form */
 | 
			
		||||
#define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \
 | 
			
		||||
			ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)
 | 
			
		||||
 | 
			
		||||
/* Macros for the ASN1_ADB structure */
 | 
			
		||||
 | 
			
		||||
#define ASN1_ADB(name) \
 | 
			
		||||
	static const ASN1_ADB_TABLE name##_adbtbl[] 
 | 
			
		||||
	const static ASN1_ADB_TABLE name##_adbtbl[] 
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
 | 
			
		||||
 | 
			
		||||
#define ASN1_ADB_END(name, flags, field, app_table, def, none) \
 | 
			
		||||
	;\
 | 
			
		||||
	static const ASN1_ADB name##_adb = {\
 | 
			
		||||
	const static ASN1_ADB name##_adb = {\
 | 
			
		||||
		flags,\
 | 
			
		||||
		offsetof(name, field),\
 | 
			
		||||
		app_table,\
 | 
			
		||||
@@ -395,9 +376,9 @@ extern "C" {
 | 
			
		||||
 | 
			
		||||
#define ASN1_ADB_END(name, flags, field, app_table, def, none) \
 | 
			
		||||
	;\
 | 
			
		||||
	static const ASN1_ITEM *name##_adb(void) \
 | 
			
		||||
	const static ASN1_ITEM *name##_adb(void) \
 | 
			
		||||
	{ \
 | 
			
		||||
	static const ASN1_ADB internal_adb = \
 | 
			
		||||
	const static ASN1_ADB internal_adb = \
 | 
			
		||||
		{\
 | 
			
		||||
		flags,\
 | 
			
		||||
		offsetof(name, field),\
 | 
			
		||||
@@ -416,7 +397,7 @@ extern "C" {
 | 
			
		||||
#define ADB_ENTRY(val, template) {val, template}
 | 
			
		||||
 | 
			
		||||
#define ASN1_ADB_TEMPLATE(name) \
 | 
			
		||||
	static const ASN1_TEMPLATE name##_tt 
 | 
			
		||||
	const static ASN1_TEMPLATE name##_tt 
 | 
			
		||||
 | 
			
		||||
/* This is the ASN1 template structure that defines
 | 
			
		||||
 * a wrapper round the actual type. It determines the
 | 
			
		||||
@@ -537,13 +518,6 @@ struct ASN1_ADB_TABLE_st {
 | 
			
		||||
 | 
			
		||||
#define ASN1_TFLG_COMBINE	(0x1<<10)
 | 
			
		||||
 | 
			
		||||
/* This flag when present in a SEQUENCE OF, SET OF
 | 
			
		||||
 * or EXPLICIT causes indefinite length constructed
 | 
			
		||||
 * encoding to be used if required.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define ASN1_TFLG_NDEF		(0x1<<11)
 | 
			
		||||
 | 
			
		||||
/* This is the actual ASN1 item itself */
 | 
			
		||||
 | 
			
		||||
struct ASN1_ITEM_st {
 | 
			
		||||
@@ -596,10 +570,6 @@ const char *sname;		/* Structure name */
 | 
			
		||||
 * has a special meaning, it is used as a mask
 | 
			
		||||
 * of acceptable types using the B_ASN1 constants.
 | 
			
		||||
 *
 | 
			
		||||
 * NDEF_SEQUENCE is the same as SEQUENCE except
 | 
			
		||||
 * that it will use indefinite length constructed
 | 
			
		||||
 * encoding if requested.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define ASN1_ITYPE_PRIMITIVE	0x0
 | 
			
		||||
@@ -614,8 +584,6 @@ const char *sname;		/* Structure name */
 | 
			
		||||
 | 
			
		||||
#define ASN1_ITYPE_MSTRING	0x5
 | 
			
		||||
 | 
			
		||||
#define ASN1_ITYPE_NDEF_SEQUENCE	0x6
 | 
			
		||||
 | 
			
		||||
/* Cache for ASN1 tag and length, so we
 | 
			
		||||
 * don't keep re-reading it for things
 | 
			
		||||
 * like CHOICE
 | 
			
		||||
@@ -775,9 +743,6 @@ typedef struct ASN1_AUX_st {
 | 
			
		||||
#define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \
 | 
			
		||||
			IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)
 | 
			
		||||
 | 
			
		||||
#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \
 | 
			
		||||
		IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)
 | 
			
		||||
 | 
			
		||||
#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \
 | 
			
		||||
	stname *fname##_new(void) \
 | 
			
		||||
	{ \
 | 
			
		||||
@@ -802,12 +767,6 @@ typedef struct ASN1_AUX_st {
 | 
			
		||||
		return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
 | 
			
		||||
	} 
 | 
			
		||||
 | 
			
		||||
#define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \
 | 
			
		||||
	int i2d_##stname##_NDEF(stname *a, unsigned char **out) \
 | 
			
		||||
	{ \
 | 
			
		||||
		return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\
 | 
			
		||||
	} 
 | 
			
		||||
 | 
			
		||||
/* This includes evil casts to remove const: they will go away when full
 | 
			
		||||
 * ASN1 constification is done.
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
@@ -68,9 +68,6 @@
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
#include <openssl/dsa.h>
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
#include <openssl/ec.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, unsigned char **pp,
 | 
			
		||||
	     long length)
 | 
			
		||||
@@ -110,16 +107,6 @@ EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, unsigned char **pp,
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		break;
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
	case EVP_PKEY_EC:
 | 
			
		||||
		if ((ret->pkey.eckey = d2i_ECPrivateKey(NULL, 
 | 
			
		||||
			(const unsigned char **)pp, length)) == NULL)
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_ASN1_LIB);
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		break;
 | 
			
		||||
#endif
 | 
			
		||||
	default:
 | 
			
		||||
		ASN1err(ASN1_F_D2I_PRIVATEKEY,ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE);
 | 
			
		||||
@@ -151,10 +138,7 @@ EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, unsigned char **pp,
 | 
			
		||||
	/* Since we only need to discern "traditional format" RSA and DSA
 | 
			
		||||
	 * keys we can just count the elements.
 | 
			
		||||
         */
 | 
			
		||||
	if(sk_ASN1_TYPE_num(inkey) == 6) 
 | 
			
		||||
		keytype = EVP_PKEY_DSA;
 | 
			
		||||
	else if (sk_ASN1_TYPE_num(inkey) == 4)
 | 
			
		||||
		keytype = EVP_PKEY_EC;
 | 
			
		||||
	if(sk_ASN1_TYPE_num(inkey) == 6) keytype = EVP_PKEY_DSA;
 | 
			
		||||
	else keytype = EVP_PKEY_RSA;
 | 
			
		||||
	sk_ASN1_TYPE_pop_free(inkey, ASN1_TYPE_free);
 | 
			
		||||
	return d2i_PrivateKey(keytype, a, pp, length);
 | 
			
		||||
 
 | 
			
		||||
@@ -68,9 +68,6 @@
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
#include <openssl/dsa.h>
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
#include <openssl/ec.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, unsigned char **pp,
 | 
			
		||||
	     long length)
 | 
			
		||||
@@ -103,23 +100,13 @@ EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, unsigned char **pp,
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
	case EVP_PKEY_DSA:
 | 
			
		||||
		if ((ret->pkey.dsa=d2i_DSAPublicKey(&(ret->pkey.dsa),
 | 
			
		||||
		if ((ret->pkey.dsa=d2i_DSAPublicKey(NULL,
 | 
			
		||||
			(const unsigned char **)pp,length)) == NULL) /* TMP UGLY CAST */
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_ASN1_LIB);
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		break;
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
	case EVP_PKEY_EC:
 | 
			
		||||
		if ((ret->pkey.eckey = o2i_ECPublicKey(&(ret->pkey.eckey),
 | 
			
		||||
			(const unsigned char **)pp, length)) == NULL)
 | 
			
		||||
			{
 | 
			
		||||
			ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_ASN1_LIB);
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
	break;
 | 
			
		||||
#endif
 | 
			
		||||
	default:
 | 
			
		||||
		ASN1err(ASN1_F_D2I_PUBLICKEY,ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE);
 | 
			
		||||
 
 | 
			
		||||
@@ -67,9 +67,6 @@
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
#include <openssl/dsa.h>
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
#include <openssl/ec.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp)
 | 
			
		||||
	{
 | 
			
		||||
@@ -86,12 +83,6 @@ int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp)
 | 
			
		||||
		return(i2d_DSAPrivateKey(a->pkey.dsa,pp));
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
	if (a->type == EVP_PKEY_EC)
 | 
			
		||||
		{
 | 
			
		||||
		return(i2d_ECPrivateKey(a->pkey.eckey, pp));
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	ASN1err(ASN1_F_I2D_PRIVATEKEY,ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE);
 | 
			
		||||
	return(-1);
 | 
			
		||||
 
 | 
			
		||||
@@ -67,9 +67,6 @@
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
#include <openssl/dsa.h>
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
#include <openssl/ec.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp)
 | 
			
		||||
	{
 | 
			
		||||
@@ -82,10 +79,6 @@ int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp)
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
	case EVP_PKEY_DSA:
 | 
			
		||||
		return(i2d_DSAPublicKey(a->pkey.dsa,pp));
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
	case EVP_PKEY_EC:
 | 
			
		||||
		return(i2o_ECPublicKey(a->pkey.eckey, pp));
 | 
			
		||||
#endif
 | 
			
		||||
	default:
 | 
			
		||||
		ASN1err(ASN1_F_I2D_PUBLICKEY,ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE);
 | 
			
		||||
 
 | 
			
		||||
@@ -56,9 +56,9 @@
 | 
			
		||||
 * [including the GNU Public Licence.]
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_RSA
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "cryptlib.h"
 | 
			
		||||
#ifndef OPENSSL_NO_RSA
 | 
			
		||||
#include <openssl/rsa.h>
 | 
			
		||||
#include <openssl/objects.h>
 | 
			
		||||
#include <openssl/asn1t.h>
 | 
			
		||||
 
 | 
			
		||||
@@ -121,7 +121,7 @@ int X509_CRL_print(BIO *out, X509_CRL *x)
 | 
			
		||||
		r = sk_X509_REVOKED_value(rev, i);
 | 
			
		||||
		BIO_printf(out,"    Serial Number: ");
 | 
			
		||||
		i2a_ASN1_INTEGER(out,r->serialNumber);
 | 
			
		||||
		BIO_printf(out,"\n        Revocation Date: ");
 | 
			
		||||
		BIO_printf(out,"\n        Revocation Date: ","");
 | 
			
		||||
		ASN1_TIME_print(out,r->revocationDate);
 | 
			
		||||
		BIO_printf(out,"\n");
 | 
			
		||||
		X509V3_extensions_print(out, "CRL entry extensions",
 | 
			
		||||
 
 | 
			
		||||
@@ -55,15 +55,9 @@
 | 
			
		||||
 * copied and put under another distribution licence
 | 
			
		||||
 * [including the GNU Public Licence.]
 | 
			
		||||
 */
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 | 
			
		||||
 * Binary polynomial ECC support in OpenSSL originally developed by 
 | 
			
		||||
 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "cryptlib.h"
 | 
			
		||||
#include <openssl/objects.h>
 | 
			
		||||
#include <openssl/buffer.h>
 | 
			
		||||
#include <openssl/bn.h>
 | 
			
		||||
#ifndef OPENSSL_NO_RSA
 | 
			
		||||
@@ -75,14 +69,9 @@
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
#include <openssl/dsa.h>
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
#include <openssl/ec.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static int print(BIO *fp,const char *str,BIGNUM *num,
 | 
			
		||||
		unsigned char *buf,int off);
 | 
			
		||||
static int print_bin(BIO *fp, const char *str, const unsigned char *num,
 | 
			
		||||
		size_t len, int off);
 | 
			
		||||
#ifndef OPENSSL_NO_RSA
 | 
			
		||||
#ifndef OPENSSL_NO_FP_API
 | 
			
		||||
int RSA_print_fp(FILE *fp, const RSA *x, int off)
 | 
			
		||||
@@ -238,313 +227,6 @@ err:
 | 
			
		||||
	}
 | 
			
		||||
#endif /* !OPENSSL_NO_DSA */
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
#ifndef OPENSSL_NO_FP_API
 | 
			
		||||
int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off)
 | 
			
		||||
	{
 | 
			
		||||
	BIO *b;
 | 
			
		||||
	int ret;
 | 
			
		||||
 | 
			
		||||
	if ((b=BIO_new(BIO_s_file())) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		ECerr(EC_F_ECPKPARAMETERS_PRINT_FP,ERR_R_BUF_LIB);
 | 
			
		||||
		return(0);
 | 
			
		||||
		}
 | 
			
		||||
	BIO_set_fp(b, fp, BIO_NOCLOSE);
 | 
			
		||||
	ret = ECPKParameters_print(b, x, off);
 | 
			
		||||
	BIO_free(b);
 | 
			
		||||
	return(ret);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off)
 | 
			
		||||
	{
 | 
			
		||||
	BIO *b;
 | 
			
		||||
	int ret;
 | 
			
		||||
 
 | 
			
		||||
	if ((b=BIO_new(BIO_s_file())) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		ECerr(EC_F_EC_KEY_PRINT_FP, ERR_R_BIO_LIB);
 | 
			
		||||
		return(0);
 | 
			
		||||
		}
 | 
			
		||||
	BIO_set_fp(b, fp, BIO_NOCLOSE);
 | 
			
		||||
	ret = EC_KEY_print(b, x, off);
 | 
			
		||||
	BIO_free(b);
 | 
			
		||||
	return(ret);
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
 | 
			
		||||
	{
 | 
			
		||||
	unsigned char *buffer=NULL;
 | 
			
		||||
	size_t	buf_len=0, i;
 | 
			
		||||
	int     ret=0, reason=ERR_R_BIO_LIB;
 | 
			
		||||
	BN_CTX  *ctx=NULL;
 | 
			
		||||
	EC_POINT *point=NULL;
 | 
			
		||||
	BIGNUM	*p=NULL, *a=NULL, *b=NULL, *gen=NULL,
 | 
			
		||||
		*order=NULL, *cofactor=NULL;
 | 
			
		||||
	const unsigned char *seed;
 | 
			
		||||
	size_t	seed_len=0;
 | 
			
		||||
	
 | 
			
		||||
	static const char *gen_compressed = "Generator (compressed):";
 | 
			
		||||
	static const char *gen_uncompressed = "Generator (uncompressed):";
 | 
			
		||||
	static const char *gen_hybrid = "Generator (hybrid):";
 | 
			
		||||
 
 | 
			
		||||
	if (!x)
 | 
			
		||||
		{
 | 
			
		||||
		reason = ERR_R_PASSED_NULL_PARAMETER;
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (EC_GROUP_get_asn1_flag(x))
 | 
			
		||||
		{
 | 
			
		||||
		/* the curve parameter are given by an asn1 OID */
 | 
			
		||||
		int nid;
 | 
			
		||||
 | 
			
		||||
		if (!BIO_indent(bp, off, 128))
 | 
			
		||||
			goto err;
 | 
			
		||||
 | 
			
		||||
		nid = EC_GROUP_get_nid(x);
 | 
			
		||||
		if (nid == 0)
 | 
			
		||||
			goto err;
 | 
			
		||||
 | 
			
		||||
		if (BIO_printf(bp, "ASN1 OID: %s", OBJ_nid2sn(nid)) <= 0)
 | 
			
		||||
			goto err;
 | 
			
		||||
		if (BIO_printf(bp, "\n") <= 0)
 | 
			
		||||
			goto err;
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
		/* explicit parameters */
 | 
			
		||||
		int is_char_two = 0;
 | 
			
		||||
		point_conversion_form_t form;
 | 
			
		||||
		int tmp_nid = EC_METHOD_get_field_type(EC_GROUP_method_of(x));
 | 
			
		||||
 | 
			
		||||
		if (tmp_nid == NID_X9_62_characteristic_two_field)
 | 
			
		||||
			is_char_two = 1;
 | 
			
		||||
 | 
			
		||||
		if ((p = BN_new()) == NULL || (a = BN_new()) == NULL ||
 | 
			
		||||
			(b = BN_new()) == NULL || (order = BN_new()) == NULL ||
 | 
			
		||||
			(cofactor = BN_new()) == NULL)
 | 
			
		||||
			{
 | 
			
		||||
			reason = ERR_R_MALLOC_FAILURE;
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		if (is_char_two)
 | 
			
		||||
			{
 | 
			
		||||
			if (!EC_GROUP_get_curve_GF2m(x, p, a, b, ctx))
 | 
			
		||||
				{
 | 
			
		||||
				reason = ERR_R_EC_LIB;
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		else /* prime field */
 | 
			
		||||
			{
 | 
			
		||||
			if (!EC_GROUP_get_curve_GFp(x, p, a, b, ctx))
 | 
			
		||||
				{
 | 
			
		||||
				reason = ERR_R_EC_LIB;
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		if ((point = EC_GROUP_get0_generator(x)) == NULL)
 | 
			
		||||
			{
 | 
			
		||||
			reason = ERR_R_EC_LIB;
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		if (!EC_GROUP_get_order(x, order, NULL) || 
 | 
			
		||||
            		!EC_GROUP_get_cofactor(x, cofactor, NULL))
 | 
			
		||||
			{
 | 
			
		||||
			reason = ERR_R_EC_LIB;
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		
 | 
			
		||||
		form = EC_GROUP_get_point_conversion_form(x);
 | 
			
		||||
 | 
			
		||||
		if ((gen = EC_POINT_point2bn(x, point, 
 | 
			
		||||
				form, NULL, ctx)) == NULL)
 | 
			
		||||
			{
 | 
			
		||||
			reason = ERR_R_EC_LIB;
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		buf_len = (size_t)BN_num_bytes(p);
 | 
			
		||||
		if (buf_len < (i = (size_t)BN_num_bytes(a)))
 | 
			
		||||
			buf_len = i;
 | 
			
		||||
		if (buf_len < (i = (size_t)BN_num_bytes(b)))
 | 
			
		||||
			buf_len = i;
 | 
			
		||||
		if (buf_len < (i = (size_t)BN_num_bytes(gen)))
 | 
			
		||||
			buf_len = i;
 | 
			
		||||
		if (buf_len < (i = (size_t)BN_num_bytes(order)))
 | 
			
		||||
			buf_len = i;
 | 
			
		||||
		if (buf_len < (i = (size_t)BN_num_bytes(cofactor))) 
 | 
			
		||||
			buf_len = i;
 | 
			
		||||
 | 
			
		||||
		if ((seed = EC_GROUP_get0_seed(x)) != NULL)
 | 
			
		||||
			seed_len = EC_GROUP_get_seed_len(x);
 | 
			
		||||
 | 
			
		||||
		buf_len += 10;
 | 
			
		||||
		if ((buffer = OPENSSL_malloc(buf_len)) == NULL)
 | 
			
		||||
			{
 | 
			
		||||
			reason = ERR_R_MALLOC_FAILURE;
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		if (!BIO_indent(bp, off, 128))
 | 
			
		||||
			goto err;
 | 
			
		||||
 | 
			
		||||
		/* print the 'short name' of the field type */
 | 
			
		||||
		if (BIO_printf(bp, "Field Type: %s\n", OBJ_nid2sn(tmp_nid))
 | 
			
		||||
			<= 0)
 | 
			
		||||
			goto err;  
 | 
			
		||||
 | 
			
		||||
		if (is_char_two)
 | 
			
		||||
			{
 | 
			
		||||
			/* print the 'short name' of the base type OID */
 | 
			
		||||
			int basis_type = EC_GROUP_get_basis_type(x);
 | 
			
		||||
			if (basis_type == 0)
 | 
			
		||||
				goto err;
 | 
			
		||||
 | 
			
		||||
			if (!BIO_indent(bp, off, 128))
 | 
			
		||||
				goto err;
 | 
			
		||||
 | 
			
		||||
			if (BIO_printf(bp, "Basis Type: %s\n", 
 | 
			
		||||
				OBJ_nid2sn(basis_type)) <= 0)
 | 
			
		||||
				goto err;
 | 
			
		||||
 | 
			
		||||
			/* print the polynomial */
 | 
			
		||||
			if ((p != NULL) && !print(bp, "Polynomial:", p, buffer,
 | 
			
		||||
				off))
 | 
			
		||||
				goto err;
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			if ((p != NULL) && !print(bp, "Prime:", p, buffer,off))
 | 
			
		||||
				goto err;
 | 
			
		||||
			}
 | 
			
		||||
		if ((a != NULL) && !print(bp, "A:   ", a, buffer, off)) 
 | 
			
		||||
			goto err;
 | 
			
		||||
		if ((b != NULL) && !print(bp, "B:   ", b, buffer, off))
 | 
			
		||||
			goto err;
 | 
			
		||||
		if (form == POINT_CONVERSION_COMPRESSED)
 | 
			
		||||
			{
 | 
			
		||||
			if ((gen != NULL) && !print(bp, gen_compressed, gen,
 | 
			
		||||
				buffer, off))
 | 
			
		||||
				goto err;
 | 
			
		||||
			}
 | 
			
		||||
		else if (form == POINT_CONVERSION_UNCOMPRESSED)
 | 
			
		||||
			{
 | 
			
		||||
			if ((gen != NULL) && !print(bp, gen_uncompressed, gen,
 | 
			
		||||
				buffer, off))
 | 
			
		||||
				goto err;
 | 
			
		||||
			}
 | 
			
		||||
		else /* form == POINT_CONVERSION_HYBRID */
 | 
			
		||||
			{
 | 
			
		||||
			if ((gen != NULL) && !print(bp, gen_hybrid, gen,
 | 
			
		||||
				buffer, off))
 | 
			
		||||
				goto err;
 | 
			
		||||
			}
 | 
			
		||||
		if ((order != NULL) && !print(bp, "Order: ", order, 
 | 
			
		||||
			buffer, off)) goto err;
 | 
			
		||||
		if ((cofactor != NULL) && !print(bp, "Cofactor: ", cofactor, 
 | 
			
		||||
			buffer, off)) goto err;
 | 
			
		||||
		if (seed && !print_bin(bp, "Seed:", seed, seed_len, off))
 | 
			
		||||
			goto err;
 | 
			
		||||
		}
 | 
			
		||||
	ret=1;
 | 
			
		||||
err:
 | 
			
		||||
	if (!ret)
 | 
			
		||||
 		ECerr(EC_F_ECPKPARAMETERS_PRINT, reason);
 | 
			
		||||
	if (p) 
 | 
			
		||||
		BN_free(p);
 | 
			
		||||
	if (a) 
 | 
			
		||||
		BN_free(a);
 | 
			
		||||
	if (b)
 | 
			
		||||
		BN_free(b);
 | 
			
		||||
	if (gen)
 | 
			
		||||
		BN_free(gen);
 | 
			
		||||
	if (order)
 | 
			
		||||
		BN_free(order);
 | 
			
		||||
	if (cofactor)
 | 
			
		||||
		BN_free(cofactor);
 | 
			
		||||
	if (ctx)
 | 
			
		||||
		BN_CTX_free(ctx);
 | 
			
		||||
	if (buffer != NULL) 
 | 
			
		||||
		OPENSSL_free(buffer);
 | 
			
		||||
	return(ret);	
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int EC_KEY_print(BIO *bp, const EC_KEY *x, int off)
 | 
			
		||||
	{
 | 
			
		||||
	unsigned char *buffer=NULL;
 | 
			
		||||
	size_t	buf_len=0, i;
 | 
			
		||||
	int     ret=0, reason=ERR_R_BIO_LIB;
 | 
			
		||||
	BIGNUM  *pub_key=NULL, *order=NULL;
 | 
			
		||||
	BN_CTX  *ctx=NULL;
 | 
			
		||||
 
 | 
			
		||||
	if (!x || !x->group)
 | 
			
		||||
		{
 | 
			
		||||
		reason = ERR_R_PASSED_NULL_PARAMETER;
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if ((pub_key = EC_POINT_point2bn(x->group, x->pub_key,
 | 
			
		||||
		x->conv_form, NULL, ctx)) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		reason = ERR_R_EC_LIB;
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	buf_len = (size_t)BN_num_bytes(pub_key);
 | 
			
		||||
	if (x->priv_key)
 | 
			
		||||
		{
 | 
			
		||||
		if ((i = (size_t)BN_num_bytes(x->priv_key)) > buf_len)
 | 
			
		||||
			buf_len = i;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	buf_len += 10;
 | 
			
		||||
	if ((buffer = OPENSSL_malloc(buf_len)) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		reason = ERR_R_MALLOC_FAILURE;
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (x->priv_key != NULL)
 | 
			
		||||
		{
 | 
			
		||||
		if (!BIO_indent(bp, off, 128))
 | 
			
		||||
			goto err;
 | 
			
		||||
		if ((order = BN_new()) == NULL)
 | 
			
		||||
			goto err;
 | 
			
		||||
		if (!EC_GROUP_get_order(x->group, order, NULL))
 | 
			
		||||
			goto err;
 | 
			
		||||
		if (BIO_printf(bp, "Private-Key: (%d bit)\n", 
 | 
			
		||||
			BN_num_bits(order)) <= 0) goto err;
 | 
			
		||||
		}
 | 
			
		||||
  
 | 
			
		||||
	if ((x->priv_key != NULL) && !print(bp, "priv:", x->priv_key, 
 | 
			
		||||
		buffer, off))
 | 
			
		||||
		goto err;
 | 
			
		||||
	if ((pub_key != NULL) && !print(bp, "pub: ", pub_key,
 | 
			
		||||
		buffer, off))
 | 
			
		||||
		goto err;
 | 
			
		||||
	if (!ECPKParameters_print(bp, x->group, off))
 | 
			
		||||
		goto err;
 | 
			
		||||
	ret=1;
 | 
			
		||||
err:
 | 
			
		||||
	if (!ret)
 | 
			
		||||
 		ECerr(EC_F_EC_KEY_PRINT, reason);
 | 
			
		||||
	if (pub_key) 
 | 
			
		||||
		BN_free(pub_key);
 | 
			
		||||
	if (order)
 | 
			
		||||
		BN_free(order);
 | 
			
		||||
	if (ctx)
 | 
			
		||||
		BN_CTX_free(ctx);
 | 
			
		||||
	if (buffer != NULL)
 | 
			
		||||
		OPENSSL_free(buffer);
 | 
			
		||||
	return(ret);
 | 
			
		||||
	}
 | 
			
		||||
#endif /* OPENSSL_NO_EC */
 | 
			
		||||
 | 
			
		||||
static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf,
 | 
			
		||||
	     int off)
 | 
			
		||||
	{
 | 
			
		||||
@@ -552,15 +234,9 @@ static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf,
 | 
			
		||||
	const char *neg;
 | 
			
		||||
 | 
			
		||||
	if (num == NULL) return(1);
 | 
			
		||||
	neg = (BN_get_sign(num))?"-":"";
 | 
			
		||||
	neg=(num->neg)?"-":"";
 | 
			
		||||
	if(!BIO_indent(bp,off,128))
 | 
			
		||||
		return 0;
 | 
			
		||||
	if (BN_is_zero(num))
 | 
			
		||||
		{
 | 
			
		||||
		if (BIO_printf(bp, "%s 0\n", number) <= 0)
 | 
			
		||||
			return 0;
 | 
			
		||||
		return 1;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (BN_num_bytes(num) <= BN_BYTES)
 | 
			
		||||
		{
 | 
			
		||||
@@ -596,44 +272,6 @@ static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf,
 | 
			
		||||
	return(1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int print_bin(BIO *fp, const char *name, const unsigned char *buf,
 | 
			
		||||
		size_t len, int off)
 | 
			
		||||
	{
 | 
			
		||||
	size_t i;
 | 
			
		||||
	char str[128];
 | 
			
		||||
 | 
			
		||||
	if (buf == NULL)
 | 
			
		||||
		return 1;
 | 
			
		||||
	if (off)
 | 
			
		||||
		{
 | 
			
		||||
		if (off > 128)
 | 
			
		||||
			off=128;
 | 
			
		||||
		memset(str,' ',off);
 | 
			
		||||
		if (BIO_write(fp, str, off) <= 0)
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (BIO_printf(fp,"%s", name) <= 0)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	for (i=0; i<len; i++)
 | 
			
		||||
		{
 | 
			
		||||
		if ((i%15) == 0)
 | 
			
		||||
			{
 | 
			
		||||
			str[0]='\n';
 | 
			
		||||
			memset(&(str[1]),' ',off+4);
 | 
			
		||||
			if (BIO_write(fp, str, off+1+4) <= 0)
 | 
			
		||||
				return 0;
 | 
			
		||||
			}
 | 
			
		||||
		if (BIO_printf(fp,"%02x%s",buf[i],((i+1) == len)?"":":") <= 0)
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
	if (BIO_write(fp,"\n",1) <= 0)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	return 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_DH
 | 
			
		||||
#ifndef OPENSSL_NO_FP_API
 | 
			
		||||
int DHparams_print_fp(FILE *fp, const DH *x)
 | 
			
		||||
@@ -747,59 +385,3 @@ err:
 | 
			
		||||
 | 
			
		||||
#endif /* !OPENSSL_NO_DSA */
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
#ifndef OPENSSL_NO_FP_API
 | 
			
		||||
int ECParameters_print_fp(FILE *fp, const EC_KEY *x)
 | 
			
		||||
	{
 | 
			
		||||
	BIO *b;
 | 
			
		||||
	int ret;
 | 
			
		||||
 
 | 
			
		||||
	if ((b=BIO_new(BIO_s_file())) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		ECerr(EC_F_ECPARAMETERS_PRINT_FP, ERR_R_BIO_LIB);
 | 
			
		||||
		return(0);
 | 
			
		||||
		}
 | 
			
		||||
	BIO_set_fp(b, fp, BIO_NOCLOSE);
 | 
			
		||||
	ret = ECParameters_print(b, x);
 | 
			
		||||
	BIO_free(b);
 | 
			
		||||
	return(ret);
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int ECParameters_print(BIO *bp, const EC_KEY *x)
 | 
			
		||||
	{
 | 
			
		||||
	int     reason=ERR_R_EC_LIB, ret=0;
 | 
			
		||||
	BIGNUM	*order=NULL;
 | 
			
		||||
 
 | 
			
		||||
	if (!x || !x->group)
 | 
			
		||||
		{
 | 
			
		||||
		reason = ERR_R_PASSED_NULL_PARAMETER;;
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if ((order = BN_new()) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		reason = ERR_R_MALLOC_FAILURE;
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (!EC_GROUP_get_order(x->group, order, NULL))
 | 
			
		||||
		{
 | 
			
		||||
		reason = ERR_R_EC_LIB;
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
	if (BIO_printf(bp, "ECDSA-Parameters: (%d bit)\n", 
 | 
			
		||||
		BN_num_bits(order)) <= 0)
 | 
			
		||||
		goto err;
 | 
			
		||||
	if (!ECPKParameters_print(bp, x->group, 4))
 | 
			
		||||
		goto err;
 | 
			
		||||
	ret=1;
 | 
			
		||||
err:
 | 
			
		||||
	if (order)
 | 
			
		||||
		BN_free(order);
 | 
			
		||||
	ECerr(EC_F_ECPARAMETERS_PRINT, reason);
 | 
			
		||||
	return(ret);
 | 
			
		||||
	}
 | 
			
		||||
  
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -159,14 +159,6 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long
 | 
			
		||||
			DSA_print(bp,pkey->pkey.dsa,16);
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
		if (pkey->type == EVP_PKEY_EC)
 | 
			
		||||
		{
 | 
			
		||||
			BIO_printf(bp, "%12sEC Public Key: \n","");
 | 
			
		||||
			EC_KEY_print(bp, pkey->pkey.eckey, 16);
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
#endif
 | 
			
		||||
			BIO_printf(bp,"%12sUnknown Public Key:\n","");
 | 
			
		||||
 | 
			
		||||
@@ -254,7 +246,7 @@ get_next:
 | 
			
		||||
				obj=X509_EXTENSION_get_object(ex);
 | 
			
		||||
				i2a_ASN1_OBJECT(bp,obj);
 | 
			
		||||
				j=X509_EXTENSION_get_critical(ex);
 | 
			
		||||
				if (BIO_printf(bp,": %s\n",j?"critical":"") <= 0)
 | 
			
		||||
				if (BIO_printf(bp,": %s\n",j?"critical":"","") <= 0)
 | 
			
		||||
					goto err;
 | 
			
		||||
				if(!X509V3_EXT_print(bp, ex, 0, 16))
 | 
			
		||||
					{
 | 
			
		||||
 
 | 
			
		||||
@@ -93,15 +93,6 @@ int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki)
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
		if (pkey->type == EVP_PKEY_EC)
 | 
			
		||||
		{
 | 
			
		||||
			BIO_printf(out, "  EC Public Key:\n");
 | 
			
		||||
			EC_KEY_print(out, pkey->pkey.eckey,2);
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
			BIO_printf(out,"  Unknown Public Key:\n");
 | 
			
		||||
		EVP_PKEY_free(pkey);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -66,9 +66,6 @@
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
#include <openssl/dsa.h>
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
#include <openssl/ec.h>
 | 
			
		||||
#endif
 | 
			
		||||
#include <openssl/objects.h>
 | 
			
		||||
#include <openssl/x509.h>
 | 
			
		||||
#include <openssl/x509v3.h>
 | 
			
		||||
@@ -231,14 +228,6 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
 | 
			
		||||
			DSA_print(bp,pkey->pkey.dsa,16);
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
		if (pkey->type == EVP_PKEY_EC)
 | 
			
		||||
			{
 | 
			
		||||
			BIO_printf(bp, "%12sEC Public Key:\n","");
 | 
			
		||||
			EC_KEY_print(bp, pkey->pkey.eckey, 16);
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
#endif
 | 
			
		||||
			BIO_printf(bp,"%12sUnknown Public Key:\n","");
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -289,7 +289,6 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, unsigned char **in, long len, const ASN1
 | 
			
		||||
				goto auxerr;
 | 
			
		||||
		return 1;
 | 
			
		||||
 | 
			
		||||
		case ASN1_ITYPE_NDEF_SEQUENCE:
 | 
			
		||||
		case ASN1_ITYPE_SEQUENCE:
 | 
			
		||||
		p = *in;
 | 
			
		||||
		tmplen = len;
 | 
			
		||||
@@ -692,6 +691,7 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval, unsigned char **in, long inl
 | 
			
		||||
 | 
			
		||||
int asn1_ex_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it)
 | 
			
		||||
{
 | 
			
		||||
	ASN1_VALUE **opval = NULL;
 | 
			
		||||
	ASN1_STRING *stmp;
 | 
			
		||||
	ASN1_TYPE *typ = NULL;
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
@@ -706,6 +706,7 @@ int asn1_ex_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype, char
 | 
			
		||||
			*pval = (ASN1_VALUE *)typ;
 | 
			
		||||
		} else typ = (ASN1_TYPE *)*pval;
 | 
			
		||||
		if(utype != typ->type) ASN1_TYPE_set(typ, utype, NULL);
 | 
			
		||||
		opval = pval;
 | 
			
		||||
		pval = (ASN1_VALUE **)&typ->value.ptr;
 | 
			
		||||
	}
 | 
			
		||||
	switch(utype) {
 | 
			
		||||
@@ -797,7 +798,12 @@ int asn1_ex_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype, char
 | 
			
		||||
 | 
			
		||||
	ret = 1;
 | 
			
		||||
	err:
 | 
			
		||||
	if(!ret) ASN1_TYPE_free(typ);
 | 
			
		||||
	if(!ret)
 | 
			
		||||
		{
 | 
			
		||||
		ASN1_TYPE_free(typ);
 | 
			
		||||
		if (opval)
 | 
			
		||||
			*opval = NULL;
 | 
			
		||||
		}
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
 * project 2000.
 | 
			
		||||
 */
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright (c) 2000-2002 The OpenSSL Project.  All rights reserved.
 | 
			
		||||
 * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
@@ -63,57 +63,38 @@
 | 
			
		||||
#include <openssl/asn1t.h>
 | 
			
		||||
#include <openssl/objects.h>
 | 
			
		||||
 | 
			
		||||
static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
 | 
			
		||||
					const ASN1_ITEM *it,
 | 
			
		||||
					int tag, int aclass);
 | 
			
		||||
static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
 | 
			
		||||
					int skcontlen, const ASN1_ITEM *item,
 | 
			
		||||
					int do_sort, int iclass);
 | 
			
		||||
static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
 | 
			
		||||
					const ASN1_TEMPLATE *tt,
 | 
			
		||||
					int tag, int aclass);
 | 
			
		||||
static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out,
 | 
			
		||||
					const ASN1_ITEM *it, int flags);
 | 
			
		||||
static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass);
 | 
			
		||||
static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *seq, unsigned char **out, int skcontlen, const ASN1_ITEM *item, int isset);
 | 
			
		||||
 | 
			
		||||
/* Top level i2d equivalents: the 'ndef' variant instructs the encoder
 | 
			
		||||
 * to use indefinite length constructed encoding, where appropriate
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
 | 
			
		||||
{
 | 
			
		||||
	return asn1_item_flags_i2d(val, out, it, ASN1_TFLG_NDEF);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
 | 
			
		||||
{
 | 
			
		||||
	return asn1_item_flags_i2d(val, out, it, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Encode an ASN1 item, this is use by the
 | 
			
		||||
/* Encode an ASN1 item, this is compatible with the
 | 
			
		||||
 * standard 'i2d' function. 'out' points to 
 | 
			
		||||
 * a buffer to output the data to.
 | 
			
		||||
 * a buffer to output the data to, in future we will
 | 
			
		||||
 * have more advanced versions that can output data
 | 
			
		||||
 * a piece at a time and this will simply be a special
 | 
			
		||||
 * case.
 | 
			
		||||
 *
 | 
			
		||||
 * The new i2d has one additional feature. If the output
 | 
			
		||||
 * buffer is NULL (i.e. *out == NULL) then a buffer is
 | 
			
		||||
 * allocated and populated with the encoding.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it, int flags)
 | 
			
		||||
 | 
			
		||||
int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
 | 
			
		||||
{
 | 
			
		||||
	if(out && !*out) {
 | 
			
		||||
		unsigned char *p, *buf;
 | 
			
		||||
		int len;
 | 
			
		||||
		len = ASN1_item_ex_i2d(&val, NULL, it, -1, flags);
 | 
			
		||||
		len = ASN1_item_ex_i2d(&val, NULL, it, -1, 0);
 | 
			
		||||
		if(len <= 0) return len;
 | 
			
		||||
		buf = OPENSSL_malloc(len);
 | 
			
		||||
		if(!buf) return -1;
 | 
			
		||||
		p = buf;
 | 
			
		||||
		ASN1_item_ex_i2d(&val, &p, it, -1, flags);
 | 
			
		||||
		ASN1_item_ex_i2d(&val, &p, it, -1, 0);
 | 
			
		||||
		*out = buf;
 | 
			
		||||
		return len;
 | 
			
		||||
	}
 | 
			
		||||
		
 | 
			
		||||
	return ASN1_item_ex_i2d(&val, out, it, -1, flags);
 | 
			
		||||
	return ASN1_item_ex_i2d(&val, out, it, -1, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Encode an item, taking care of IMPLICIT tagging (if any).
 | 
			
		||||
@@ -121,34 +102,31 @@ static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_
 | 
			
		||||
 * used in external types.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
 | 
			
		||||
			const ASN1_ITEM *it, int tag, int aclass)
 | 
			
		||||
int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass)
 | 
			
		||||
{
 | 
			
		||||
	const ASN1_TEMPLATE *tt = NULL;
 | 
			
		||||
	unsigned char *p = NULL;
 | 
			
		||||
	int i, seqcontlen, seqlen, ndef = 1;
 | 
			
		||||
	int i, seqcontlen, seqlen;
 | 
			
		||||
	ASN1_STRING *strtmp;
 | 
			
		||||
	const ASN1_COMPAT_FUNCS *cf;
 | 
			
		||||
	const ASN1_EXTERN_FUNCS *ef;
 | 
			
		||||
	const ASN1_AUX *aux = it->funcs;
 | 
			
		||||
	ASN1_aux_cb *asn1_cb = 0;
 | 
			
		||||
 | 
			
		||||
	if((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	if(aux && aux->asn1_cb)
 | 
			
		||||
		 asn1_cb = aux->asn1_cb;
 | 
			
		||||
	ASN1_aux_cb *asn1_cb;
 | 
			
		||||
	if((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval) return 0;
 | 
			
		||||
	if(aux && aux->asn1_cb) asn1_cb = aux->asn1_cb;
 | 
			
		||||
	else asn1_cb = 0;
 | 
			
		||||
 | 
			
		||||
	switch(it->itype) {
 | 
			
		||||
 | 
			
		||||
		case ASN1_ITYPE_PRIMITIVE:
 | 
			
		||||
		if(it->templates)
 | 
			
		||||
			return asn1_template_ex_i2d(pval, out, it->templates,
 | 
			
		||||
								tag, aclass);
 | 
			
		||||
			return ASN1_template_i2d(pval, out, it->templates);
 | 
			
		||||
		return asn1_i2d_ex_primitive(pval, out, it, tag, aclass);
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		case ASN1_ITYPE_MSTRING:
 | 
			
		||||
		return asn1_i2d_ex_primitive(pval, out, it, -1, aclass);
 | 
			
		||||
		strtmp = (ASN1_STRING *)*pval;
 | 
			
		||||
		return asn1_i2d_ex_primitive(pval, out, it, -1, 0);
 | 
			
		||||
 | 
			
		||||
		case ASN1_ITYPE_CHOICE:
 | 
			
		||||
		if(asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it))
 | 
			
		||||
@@ -159,8 +137,7 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
 | 
			
		||||
			const ASN1_TEMPLATE *chtt;
 | 
			
		||||
			chtt = it->templates + i;
 | 
			
		||||
			pchval = asn1_get_field_ptr(pval, chtt);
 | 
			
		||||
			return asn1_template_ex_i2d(pchval, out, chtt,
 | 
			
		||||
								-1, aclass);
 | 
			
		||||
			return ASN1_template_i2d(pchval, out, chtt);
 | 
			
		||||
		} 
 | 
			
		||||
		/* Fixme: error condition if selector out of range */
 | 
			
		||||
		if(asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it))
 | 
			
		||||
@@ -184,11 +161,6 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
 | 
			
		||||
			*p = aclass | tag | (*p & V_ASN1_CONSTRUCTED);
 | 
			
		||||
		return i;
 | 
			
		||||
		
 | 
			
		||||
		case ASN1_ITYPE_NDEF_SEQUENCE:
 | 
			
		||||
		/* Use indefinite length constructed if requested */
 | 
			
		||||
		if (aclass & ASN1_TFLG_NDEF) ndef = 2;
 | 
			
		||||
		/* fall through */
 | 
			
		||||
 | 
			
		||||
		case ASN1_ITYPE_SEQUENCE:
 | 
			
		||||
		i = asn1_enc_restore(&seqcontlen, out, pval, it);
 | 
			
		||||
		/* An error occurred */
 | 
			
		||||
@@ -200,9 +172,7 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
 | 
			
		||||
		/* If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL */
 | 
			
		||||
		if(tag == -1) {
 | 
			
		||||
			tag = V_ASN1_SEQUENCE;
 | 
			
		||||
			/* Retain any other flags in aclass */
 | 
			
		||||
			aclass = (aclass & ~ASN1_TFLG_TAG_CLASS)
 | 
			
		||||
					| V_ASN1_UNIVERSAL;
 | 
			
		||||
			aclass = V_ASN1_UNIVERSAL;
 | 
			
		||||
		}
 | 
			
		||||
		if(asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it))
 | 
			
		||||
				return 0;
 | 
			
		||||
@@ -214,13 +184,13 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
 | 
			
		||||
			if(!seqtt) return 0;
 | 
			
		||||
			pseqval = asn1_get_field_ptr(pval, seqtt);
 | 
			
		||||
			/* FIXME: check for errors in enhanced version */
 | 
			
		||||
			seqcontlen += asn1_template_ex_i2d(pseqval, NULL, seqtt,
 | 
			
		||||
								-1, aclass);
 | 
			
		||||
			/* FIXME: special handling of indefinite length encoding */
 | 
			
		||||
			seqcontlen += ASN1_template_i2d(pseqval, NULL, seqtt);
 | 
			
		||||
		}
 | 
			
		||||
		seqlen = ASN1_object_size(ndef, seqcontlen, tag);
 | 
			
		||||
		seqlen = ASN1_object_size(1, seqcontlen, tag);
 | 
			
		||||
		if(!out) return seqlen;
 | 
			
		||||
		/* Output SEQUENCE header */
 | 
			
		||||
		ASN1_put_object(out, ndef, seqcontlen, tag, aclass);
 | 
			
		||||
		ASN1_put_object(out, 1, seqcontlen, tag, aclass);
 | 
			
		||||
		for(i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
 | 
			
		||||
			const ASN1_TEMPLATE *seqtt;
 | 
			
		||||
			ASN1_VALUE **pseqval;
 | 
			
		||||
@@ -228,9 +198,8 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
 | 
			
		||||
			if(!seqtt) return 0;
 | 
			
		||||
			pseqval = asn1_get_field_ptr(pval, seqtt);
 | 
			
		||||
			/* FIXME: check for errors in enhanced version */
 | 
			
		||||
			asn1_template_ex_i2d(pseqval, out, seqtt, -1, aclass);
 | 
			
		||||
			ASN1_template_i2d(pseqval, out, seqtt);
 | 
			
		||||
		}
 | 
			
		||||
		if (ndef == 2) ASN1_put_eoc(out);
 | 
			
		||||
		if(asn1_cb  && !asn1_cb(ASN1_OP_I2D_POST, pval, it))
 | 
			
		||||
				return 0;
 | 
			
		||||
		return seqlen;
 | 
			
		||||
@@ -243,94 +212,40 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
 | 
			
		||||
 | 
			
		||||
int ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt)
 | 
			
		||||
{
 | 
			
		||||
	return asn1_template_ex_i2d(pval, out, tt, -1, 0);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt, int tag, int iclass)
 | 
			
		||||
{
 | 
			
		||||
	int i, ret, flags, ttag, tclass, ndef;
 | 
			
		||||
	int i, ret, flags, aclass;
 | 
			
		||||
	flags = tt->flags;
 | 
			
		||||
	/* Work out tag and class to use: tagging may come
 | 
			
		||||
	 * either from the template or the arguments, not both
 | 
			
		||||
	 * because this would create ambiguity. Additionally
 | 
			
		||||
	 * the iclass argument may contain some additional flags
 | 
			
		||||
	 * which should be noted and passed down to other levels.
 | 
			
		||||
	 */
 | 
			
		||||
	if (flags & ASN1_TFLG_TAG_MASK)
 | 
			
		||||
		{
 | 
			
		||||
		/* Error if argument and template tagging */
 | 
			
		||||
		if (tag != -1)
 | 
			
		||||
			/* FIXME: error code here */
 | 
			
		||||
			return -1;
 | 
			
		||||
		/* Get tagging from template */
 | 
			
		||||
		ttag = tt->tag;
 | 
			
		||||
		tclass = flags & ASN1_TFLG_TAG_CLASS;
 | 
			
		||||
		}
 | 
			
		||||
	else if (tag != -1)
 | 
			
		||||
		{
 | 
			
		||||
		/* No template tagging, get from arguments */
 | 
			
		||||
		ttag = tag;
 | 
			
		||||
		tclass = iclass & ASN1_TFLG_TAG_CLASS;
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
		ttag = -1;
 | 
			
		||||
		tclass = 0;
 | 
			
		||||
		}
 | 
			
		||||
	/* 
 | 
			
		||||
	 * Remove any class mask from iflag.
 | 
			
		||||
	 */
 | 
			
		||||
	iclass &= ~ASN1_TFLG_TAG_CLASS;
 | 
			
		||||
 | 
			
		||||
	/* At this point 'ttag' contains the outer tag to use,
 | 
			
		||||
	 * 'tclass' is the class and iclass is any flags passed
 | 
			
		||||
	 * to this function.
 | 
			
		||||
	 */
 | 
			
		||||
 | 
			
		||||
	/* if template and arguments require ndef, use it */
 | 
			
		||||
	if ((flags & ASN1_TFLG_NDEF) && (iclass & ASN1_TFLG_NDEF))
 | 
			
		||||
		ndef = 2;
 | 
			
		||||
	else ndef = 1;
 | 
			
		||||
 | 
			
		||||
	aclass = flags & ASN1_TFLG_TAG_CLASS;
 | 
			
		||||
	if(flags & ASN1_TFLG_SK_MASK) {
 | 
			
		||||
		/* SET OF, SEQUENCE OF */
 | 
			
		||||
		STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval;
 | 
			
		||||
		int isset, sktag, skaclass;
 | 
			
		||||
		int skcontlen, sklen;
 | 
			
		||||
		ASN1_VALUE *skitem;
 | 
			
		||||
 | 
			
		||||
		if(!*pval) return 0;
 | 
			
		||||
 | 
			
		||||
		if(flags & ASN1_TFLG_SET_OF) {
 | 
			
		||||
			isset = 1;
 | 
			
		||||
			/* 2 means we reorder */
 | 
			
		||||
			if(flags & ASN1_TFLG_SEQUENCE_OF) isset = 2;
 | 
			
		||||
		} else isset = 0;
 | 
			
		||||
 | 
			
		||||
		/* Work out inner tag value: if EXPLICIT
 | 
			
		||||
		 * or no tagging use underlying type.
 | 
			
		||||
		 */
 | 
			
		||||
		if((ttag != -1) && !(flags & ASN1_TFLG_EXPTAG)) {
 | 
			
		||||
			sktag = ttag;
 | 
			
		||||
			skaclass = tclass;
 | 
			
		||||
		/* First work out inner tag value */
 | 
			
		||||
		if(flags & ASN1_TFLG_IMPTAG) {
 | 
			
		||||
			sktag = tt->tag;
 | 
			
		||||
			skaclass = aclass;
 | 
			
		||||
		} else {
 | 
			
		||||
			skaclass = V_ASN1_UNIVERSAL;
 | 
			
		||||
			if(isset) sktag = V_ASN1_SET;
 | 
			
		||||
			else sktag = V_ASN1_SEQUENCE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* Determine total length of items */
 | 
			
		||||
		/* Now work out length of items */
 | 
			
		||||
		skcontlen = 0;
 | 
			
		||||
		for(i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
 | 
			
		||||
			skitem = sk_ASN1_VALUE_value(sk, i);
 | 
			
		||||
			skcontlen += ASN1_item_ex_i2d(&skitem, NULL,
 | 
			
		||||
							ASN1_ITEM_ptr(tt->item),
 | 
			
		||||
							-1, iclass);
 | 
			
		||||
			skcontlen += ASN1_item_ex_i2d(&skitem, NULL, ASN1_ITEM_ptr(tt->item), -1, 0);
 | 
			
		||||
		}
 | 
			
		||||
		sklen = ASN1_object_size(ndef, skcontlen, sktag);
 | 
			
		||||
		sklen = ASN1_object_size(1, skcontlen, sktag);
 | 
			
		||||
		/* If EXPLICIT need length of surrounding tag */
 | 
			
		||||
		if(flags & ASN1_TFLG_EXPTAG)
 | 
			
		||||
			ret = ASN1_object_size(ndef, sklen, ttag);
 | 
			
		||||
			ret = ASN1_object_size(1, sklen, tt->tag);
 | 
			
		||||
		else ret = sklen;
 | 
			
		||||
 | 
			
		||||
		if(!out) return ret;
 | 
			
		||||
@@ -338,17 +253,11 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const AS
 | 
			
		||||
		/* Now encode this lot... */
 | 
			
		||||
		/* EXPLICIT tag */
 | 
			
		||||
		if(flags & ASN1_TFLG_EXPTAG)
 | 
			
		||||
			ASN1_put_object(out, ndef, sklen, ttag, tclass);
 | 
			
		||||
			ASN1_put_object(out, 1, sklen, tt->tag, aclass);
 | 
			
		||||
		/* SET or SEQUENCE and IMPLICIT tag */
 | 
			
		||||
		ASN1_put_object(out, ndef, skcontlen, sktag, skaclass);
 | 
			
		||||
		/* And the stuff itself */
 | 
			
		||||
		asn1_set_seq_out(sk, out, skcontlen, ASN1_ITEM_ptr(tt->item),
 | 
			
		||||
								isset, iclass);
 | 
			
		||||
		if (ndef == 2) {
 | 
			
		||||
			ASN1_put_eoc(out);
 | 
			
		||||
			if(flags & ASN1_TFLG_EXPTAG)
 | 
			
		||||
				ASN1_put_eoc(out);
 | 
			
		||||
		}
 | 
			
		||||
		ASN1_put_object(out, 1, skcontlen, sktag, skaclass);
 | 
			
		||||
		/* And finally the stuff itself */
 | 
			
		||||
		asn1_set_seq_out(sk, out, skcontlen, ASN1_ITEM_ptr(tt->item), isset);
 | 
			
		||||
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
@@ -356,25 +265,23 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const AS
 | 
			
		||||
	if(flags & ASN1_TFLG_EXPTAG) {
 | 
			
		||||
		/* EXPLICIT tagging */
 | 
			
		||||
		/* Find length of tagged item */
 | 
			
		||||
		i = ASN1_item_ex_i2d(pval, NULL, ASN1_ITEM_ptr(tt->item),
 | 
			
		||||
								-1, iclass);
 | 
			
		||||
		i = ASN1_item_ex_i2d(pval, NULL, ASN1_ITEM_ptr(tt->item), -1, 0);
 | 
			
		||||
		if(!i) return 0;
 | 
			
		||||
		/* Find length of EXPLICIT tag */
 | 
			
		||||
		ret = ASN1_object_size(ndef, i, ttag);
 | 
			
		||||
		ret = ASN1_object_size(1, i, tt->tag);
 | 
			
		||||
		if(out) {
 | 
			
		||||
			/* Output tag and item */
 | 
			
		||||
			ASN1_put_object(out, ndef, i, ttag, tclass);
 | 
			
		||||
			ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item),
 | 
			
		||||
								-1, iclass);
 | 
			
		||||
			if (ndef == 2) ASN1_put_eoc(out);
 | 
			
		||||
			ASN1_put_object(out, 1, i, tt->tag, aclass);
 | 
			
		||||
			ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item), -1, 0);
 | 
			
		||||
		}
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Either normal or IMPLICIT tagging: combine class and flags */
 | 
			
		||||
	return ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item),
 | 
			
		||||
						ttag, tclass | iclass);
 | 
			
		||||
 | 
			
		||||
	if(flags & ASN1_TFLG_IMPTAG) {
 | 
			
		||||
		/* IMPLICIT tagging */
 | 
			
		||||
		return ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item), tt->tag, aclass);
 | 
			
		||||
	}
 | 
			
		||||
	/* Nothing special: treat as normal */
 | 
			
		||||
	return ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item), -1, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Temporary structure used to hold DER encoding of items for SET OF */
 | 
			
		||||
@@ -397,9 +304,7 @@ static int der_cmp(const void *a, const void *b)
 | 
			
		||||
 | 
			
		||||
/* Output the content octets of SET OF or SEQUENCE OF */
 | 
			
		||||
 | 
			
		||||
static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
 | 
			
		||||
					int skcontlen, const ASN1_ITEM *item,
 | 
			
		||||
					int do_sort, int iclass)
 | 
			
		||||
static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out, int skcontlen, const ASN1_ITEM *item, int do_sort)
 | 
			
		||||
{
 | 
			
		||||
	int i;
 | 
			
		||||
	ASN1_VALUE *skitem;
 | 
			
		||||
@@ -418,7 +323,7 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
 | 
			
		||||
	if(!do_sort) {
 | 
			
		||||
		for(i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
 | 
			
		||||
			skitem = sk_ASN1_VALUE_value(sk, i);
 | 
			
		||||
			ASN1_item_ex_i2d(&skitem, out, item, -1, iclass);
 | 
			
		||||
			ASN1_item_i2d(skitem, out, item);
 | 
			
		||||
		}
 | 
			
		||||
		return 1;
 | 
			
		||||
	}
 | 
			
		||||
@@ -427,7 +332,7 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
 | 
			
		||||
	for(i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) {
 | 
			
		||||
		skitem = sk_ASN1_VALUE_value(sk, i);
 | 
			
		||||
		tder->data = p;
 | 
			
		||||
		tder->length = ASN1_item_ex_i2d(&skitem, &p, item, -1, iclass);
 | 
			
		||||
		tder->length = ASN1_item_i2d(skitem, &p, item);
 | 
			
		||||
		tder->field = skitem;
 | 
			
		||||
	}
 | 
			
		||||
	/* Now sort them */
 | 
			
		||||
@@ -454,7 +359,6 @@ static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, const A
 | 
			
		||||
	int len;
 | 
			
		||||
	int utype;
 | 
			
		||||
	int usetag;
 | 
			
		||||
	int ndef = 0;
 | 
			
		||||
 | 
			
		||||
	utype = it->utype;
 | 
			
		||||
 | 
			
		||||
@@ -477,30 +381,19 @@ static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, const A
 | 
			
		||||
 | 
			
		||||
	/* -1 means omit type */
 | 
			
		||||
 | 
			
		||||
	if(len == -1)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	/* -2 return is special meaning use ndef */
 | 
			
		||||
	if (len == -2)
 | 
			
		||||
		{
 | 
			
		||||
		ndef = 2;
 | 
			
		||||
		len = 0;
 | 
			
		||||
		}
 | 
			
		||||
	if(len == -1) return 0;
 | 
			
		||||
 | 
			
		||||
	/* If not implicitly tagged get tag from underlying type */
 | 
			
		||||
	if(tag == -1) tag = utype;
 | 
			
		||||
 | 
			
		||||
	/* Output tag+length followed by content octets */
 | 
			
		||||
	if(out) {
 | 
			
		||||
		if(usetag) ASN1_put_object(out, ndef, len, tag, aclass);
 | 
			
		||||
		if(usetag) ASN1_put_object(out, 0, len, tag, aclass);
 | 
			
		||||
		asn1_ex_i2c(pval, *out, &utype, it);
 | 
			
		||||
		if (ndef)
 | 
			
		||||
			ASN1_put_eoc(out);
 | 
			
		||||
		else
 | 
			
		||||
		*out += len;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(usetag) return ASN1_object_size(ndef, len, tag);
 | 
			
		||||
	if(usetag) return ASN1_object_size(0, len, tag);
 | 
			
		||||
	return len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -593,18 +486,6 @@ int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype, const ASN1_
 | 
			
		||||
		default:
 | 
			
		||||
		/* All based on ASN1_STRING and handled the same */
 | 
			
		||||
		strtmp = (ASN1_STRING *)*pval;
 | 
			
		||||
		/* Special handling for NDEF */
 | 
			
		||||
		if ((it->size == ASN1_TFLG_NDEF)
 | 
			
		||||
			&& (strtmp->flags & ASN1_STRING_FLAG_NDEF))
 | 
			
		||||
			{
 | 
			
		||||
			if (cout)
 | 
			
		||||
				{
 | 
			
		||||
				strtmp->data = cout;
 | 
			
		||||
				strtmp->length = 0;
 | 
			
		||||
				}
 | 
			
		||||
			/* Special return code */
 | 
			
		||||
			return -2;
 | 
			
		||||
			}
 | 
			
		||||
		cont = strtmp->data;
 | 
			
		||||
		len = strtmp->length;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -130,7 +130,6 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int c
 | 
			
		||||
		if(ef && ef->asn1_ex_free) ef->asn1_ex_free(pval, it);
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		case ASN1_ITYPE_NDEF_SEQUENCE:
 | 
			
		||||
		case ASN1_ITYPE_SEQUENCE:
 | 
			
		||||
		if(asn1_do_lock(pval, -1, it) > 0) return;
 | 
			
		||||
		if(asn1_cb) {
 | 
			
		||||
 
 | 
			
		||||
@@ -155,7 +155,6 @@ static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int
 | 
			
		||||
				goto auxerr;
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		case ASN1_ITYPE_NDEF_SEQUENCE:
 | 
			
		||||
		case ASN1_ITYPE_SEQUENCE:
 | 
			
		||||
		if(asn1_cb) {
 | 
			
		||||
			i = asn1_cb(ASN1_OP_NEW_PRE, pval, it);
 | 
			
		||||
@@ -232,7 +231,6 @@ static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
 | 
			
		||||
		case ASN1_ITYPE_COMPAT:
 | 
			
		||||
		case ASN1_ITYPE_CHOICE:
 | 
			
		||||
		case ASN1_ITYPE_SEQUENCE:
 | 
			
		||||
		case ASN1_ITYPE_NDEF_SEQUENCE:
 | 
			
		||||
		*pval = NULL;
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -131,7 +131,3 @@ IMPLEMENT_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)
 | 
			
		||||
IMPLEMENT_ASN1_TYPE_ex(ASN1_BOOLEAN, ASN1_BOOLEAN, -1)
 | 
			
		||||
IMPLEMENT_ASN1_TYPE_ex(ASN1_TBOOLEAN, ASN1_BOOLEAN, 1)
 | 
			
		||||
IMPLEMENT_ASN1_TYPE_ex(ASN1_FBOOLEAN, ASN1_BOOLEAN, 0)
 | 
			
		||||
 | 
			
		||||
/* Special, OCTET STRING with indefinite length constructed support */
 | 
			
		||||
 | 
			
		||||
IMPLEMENT_ASN1_TYPE_ex(ASN1_OCTET_STRING_NDEF, ASN1_OCTET_STRING, ASN1_TFLG_NDEF)
 | 
			
		||||
 
 | 
			
		||||
@@ -102,8 +102,7 @@ int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it)
 | 
			
		||||
{
 | 
			
		||||
	const ASN1_AUX *aux;
 | 
			
		||||
	int *lck, ret;
 | 
			
		||||
	if((it->itype != ASN1_ITYPE_SEQUENCE)
 | 
			
		||||
	   && (it->itype != ASN1_ITYPE_NDEF_SEQUENCE)) return 0;
 | 
			
		||||
	if(it->itype != ASN1_ITYPE_SEQUENCE) return 0;
 | 
			
		||||
	aux = it->funcs;
 | 
			
		||||
	if(!aux || !(aux->flags & ASN1_AFLG_REFCOUNT)) return 0;
 | 
			
		||||
	lck = offset2ptr(*pval, aux->ref_offset);
 | 
			
		||||
 
 | 
			
		||||
@@ -64,8 +64,7 @@
 | 
			
		||||
/* Minor tweak to operation: free up EVP_PKEY */
 | 
			
		||||
static int pubkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
 | 
			
		||||
{
 | 
			
		||||
	if (operation == ASN1_OP_FREE_POST)
 | 
			
		||||
		{
 | 
			
		||||
	if(operation == ASN1_OP_FREE_POST) {
 | 
			
		||||
		X509_PUBKEY *pubkey = (X509_PUBKEY *)*pval;
 | 
			
		||||
		EVP_PKEY_free(pubkey->pkey);
 | 
			
		||||
	}
 | 
			
		||||
@@ -109,8 +108,9 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
 | 
			
		||||
			a->parameter->type=V_ASN1_NULL;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
	else if (pkey->type == EVP_PKEY_DSA)
 | 
			
		||||
		if (pkey->type == EVP_PKEY_DSA)
 | 
			
		||||
		{
 | 
			
		||||
		unsigned char *pp;
 | 
			
		||||
		DSA *dsa;
 | 
			
		||||
@@ -128,62 +128,8 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
 | 
			
		||||
		ASN1_STRING_set(a->parameter->value.sequence,p,i);
 | 
			
		||||
		OPENSSL_free(p);
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
	else if (pkey->type == EVP_PKEY_EC)
 | 
			
		||||
		{
 | 
			
		||||
		int nid=0;
 | 
			
		||||
		unsigned char *pp;
 | 
			
		||||
		EC_KEY *eckey;
 | 
			
		||||
		
 | 
			
		||||
		eckey = pkey->pkey.eckey;
 | 
			
		||||
		ASN1_TYPE_free(a->parameter);
 | 
			
		||||
 | 
			
		||||
		if ((a->parameter = ASN1_TYPE_new()) == NULL)
 | 
			
		||||
			{
 | 
			
		||||
			X509err(X509_F_X509_PUBKEY_SET, ERR_R_ASN1_LIB);
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		if (EC_GROUP_get_asn1_flag(eckey->group)
 | 
			
		||||
                     && (nid = EC_GROUP_get_nid(eckey->group)))
 | 
			
		||||
			{
 | 
			
		||||
			/* just set the OID */
 | 
			
		||||
			a->parameter->type = V_ASN1_OBJECT;
 | 
			
		||||
			a->parameter->value.object = OBJ_nid2obj(nid);
 | 
			
		||||
			}
 | 
			
		||||
		else /* explicit parameters */
 | 
			
		||||
			{
 | 
			
		||||
			if ((i = i2d_ECParameters(eckey, NULL)) == 0)
 | 
			
		||||
				{
 | 
			
		||||
				X509err(X509_F_X509_PUBKEY_SET, ERR_R_EC_LIB);
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			if ((p = (unsigned char *) OPENSSL_malloc(i)) == NULL)
 | 
			
		||||
				{
 | 
			
		||||
				X509err(X509_F_X509_PUBKEY_SET, ERR_R_MALLOC_FAILURE);
 | 
			
		||||
				goto err;
 | 
			
		||||
				}	
 | 
			
		||||
			pp = p;
 | 
			
		||||
			if (!i2d_ECParameters(eckey, &pp))
 | 
			
		||||
				{
 | 
			
		||||
				X509err(X509_F_X509_PUBKEY_SET, ERR_R_EC_LIB);
 | 
			
		||||
				OPENSSL_free(p);
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			a->parameter->type = V_ASN1_SEQUENCE;
 | 
			
		||||
			if ((a->parameter->value.sequence = ASN1_STRING_new()) == NULL)
 | 
			
		||||
				{
 | 
			
		||||
				X509err(X509_F_X509_PUBKEY_SET, ERR_R_ASN1_LIB);
 | 
			
		||||
				OPENSSL_free(p);
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			ASN1_STRING_set(a->parameter->value.sequence, p, i);
 | 
			
		||||
			OPENSSL_free(p);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
	else if (1)
 | 
			
		||||
		{
 | 
			
		||||
		X509err(X509_F_X509_PUBKEY_SET,X509_R_UNSUPPORTED_ALGORITHM);
 | 
			
		||||
		goto err;
 | 
			
		||||
@@ -227,7 +173,7 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
 | 
			
		||||
	long j;
 | 
			
		||||
	int type;
 | 
			
		||||
	unsigned char *p;
 | 
			
		||||
#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_ECDSA)
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
	const unsigned char *cp;
 | 
			
		||||
	X509_ALGOR *a;
 | 
			
		||||
#endif
 | 
			
		||||
@@ -243,31 +189,21 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
 | 
			
		||||
	if (key->public_key == NULL) goto err;
 | 
			
		||||
 | 
			
		||||
	type=OBJ_obj2nid(key->algor->algorithm);
 | 
			
		||||
	if ((ret = EVP_PKEY_new()) == NULL)
 | 
			
		||||
	p=key->public_key->data;
 | 
			
		||||
        j=key->public_key->length;
 | 
			
		||||
        if ((ret=d2i_PublicKey(type,NULL,&p,(long)j)) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		X509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE);
 | 
			
		||||
		X509err(X509_F_X509_PUBKEY_GET,X509_R_ERR_ASN1_LIB);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	ret->type = EVP_PKEY_type(type);
 | 
			
		||||
	ret->save_parameters=0;
 | 
			
		||||
 | 
			
		||||
	/* the parameters must be extracted before the public key (ECDSA!) */
 | 
			
		||||
	
 | 
			
		||||
#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_ECDSA)
 | 
			
		||||
	a=key->algor;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	if (0)
 | 
			
		||||
		;
 | 
			
		||||
#ifndef OPENSSL_NO_DSA
 | 
			
		||||
	else if (ret->type == EVP_PKEY_DSA)
 | 
			
		||||
	a=key->algor;
 | 
			
		||||
	if (ret->type == EVP_PKEY_DSA)
 | 
			
		||||
		{
 | 
			
		||||
		if (a->parameter && (a->parameter->type == V_ASN1_SEQUENCE))
 | 
			
		||||
			{
 | 
			
		||||
			if ((ret->pkey.dsa = DSA_new()) == NULL)
 | 
			
		||||
				{
 | 
			
		||||
				X509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE);
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			ret->pkey.dsa->write_params=0;
 | 
			
		||||
			cp=p=a->parameter->value.sequence->data;
 | 
			
		||||
			j=a->parameter->value.sequence->length;
 | 
			
		||||
@@ -277,58 +213,6 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
 | 
			
		||||
		ret->save_parameters=1;
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
	else if (ret->type == EVP_PKEY_EC)
 | 
			
		||||
		{
 | 
			
		||||
		if (a->parameter && (a->parameter->type == V_ASN1_SEQUENCE))
 | 
			
		||||
			{
 | 
			
		||||
			/* type == V_ASN1_SEQUENCE => we have explicit parameters
 | 
			
		||||
                         * (e.g. parameters in the X9_62_EC_PARAMETERS-structure )
 | 
			
		||||
			 */
 | 
			
		||||
			if ((ret->pkey.eckey= EC_KEY_new()) == NULL)
 | 
			
		||||
				{
 | 
			
		||||
				X509err(X509_F_X509_PUBKEY_GET, 
 | 
			
		||||
					ERR_R_MALLOC_FAILURE);
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			cp = p = a->parameter->value.sequence->data;
 | 
			
		||||
			j = a->parameter->value.sequence->length;
 | 
			
		||||
			if (!d2i_ECParameters(&ret->pkey.eckey, &cp, (long)j))
 | 
			
		||||
				{
 | 
			
		||||
				X509err(X509_F_X509_PUBKEY_GET, ERR_R_EC_LIB);
 | 
			
		||||
				goto err;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		else if (a->parameter && (a->parameter->type == V_ASN1_OBJECT))
 | 
			
		||||
			{
 | 
			
		||||
			/* type == V_ASN1_OBJECT => the parameters are given
 | 
			
		||||
			 * by an asn1 OID
 | 
			
		||||
			 */
 | 
			
		||||
			EC_KEY *eckey;
 | 
			
		||||
			if (ret->pkey.eckey == NULL)
 | 
			
		||||
				ret->pkey.eckey = EC_KEY_new();
 | 
			
		||||
			eckey = ret->pkey.eckey;
 | 
			
		||||
			if (eckey->group)
 | 
			
		||||
				EC_GROUP_free(eckey->group);
 | 
			
		||||
			if ((eckey->group = EC_GROUP_new_by_nid(
 | 
			
		||||
                             OBJ_obj2nid(a->parameter->value.object))) == NULL)
 | 
			
		||||
				goto err;
 | 
			
		||||
			EC_GROUP_set_asn1_flag(eckey->group, 
 | 
			
		||||
						OPENSSL_EC_NAMED_CURVE);
 | 
			
		||||
			}
 | 
			
		||||
			/* the case implicitlyCA is currently not implemented */
 | 
			
		||||
		ret->save_parameters = 1;
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	p=key->public_key->data;
 | 
			
		||||
        j=key->public_key->length;
 | 
			
		||||
        if ((ret = d2i_PublicKey(type, &ret, &p, (long)j)) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		X509err(X509_F_X509_PUBKEY_GET, X509_R_ERR_ASN1_LIB);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	key->pkey=ret;
 | 
			
		||||
	CRYPTO_add(&ret->references,1,CRYPTO_LOCK_EVP_PKEY);
 | 
			
		||||
	return(ret);
 | 
			
		||||
@@ -352,8 +236,7 @@ EVP_PKEY *d2i_PUBKEY(EVP_PKEY **a, unsigned char **pp,
 | 
			
		||||
	pktmp = X509_PUBKEY_get(xpk);
 | 
			
		||||
	X509_PUBKEY_free(xpk);
 | 
			
		||||
	if(!pktmp) return NULL;
 | 
			
		||||
	if(a)
 | 
			
		||||
		{
 | 
			
		||||
	if(a) {
 | 
			
		||||
		EVP_PKEY_free(*a);
 | 
			
		||||
		*a = pktmp;
 | 
			
		||||
	}
 | 
			
		||||
@@ -388,8 +271,7 @@ RSA *d2i_RSA_PUBKEY(RSA **a, unsigned char **pp,
 | 
			
		||||
	EVP_PKEY_free(pkey);
 | 
			
		||||
	if(!key) return NULL;
 | 
			
		||||
	*pp = q;
 | 
			
		||||
	if (a)
 | 
			
		||||
		{
 | 
			
		||||
	if(a) {
 | 
			
		||||
		RSA_free(*a);
 | 
			
		||||
		*a = key;
 | 
			
		||||
	}
 | 
			
		||||
@@ -402,8 +284,7 @@ int i2d_RSA_PUBKEY(RSA *a, unsigned char **pp)
 | 
			
		||||
	int ret;
 | 
			
		||||
	if(!a) return 0;
 | 
			
		||||
	pktmp = EVP_PKEY_new();
 | 
			
		||||
	if (!pktmp)
 | 
			
		||||
		{
 | 
			
		||||
	if(!pktmp) {
 | 
			
		||||
		ASN1err(ASN1_F_I2D_RSA_PUBKEY, ERR_R_MALLOC_FAILURE);
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
@@ -428,8 +309,7 @@ DSA *d2i_DSA_PUBKEY(DSA **a, unsigned char **pp,
 | 
			
		||||
	EVP_PKEY_free(pkey);
 | 
			
		||||
	if(!key) return NULL;
 | 
			
		||||
	*pp = q;
 | 
			
		||||
	if (a)
 | 
			
		||||
		{
 | 
			
		||||
	if(a) {
 | 
			
		||||
		DSA_free(*a);
 | 
			
		||||
		*a = key;
 | 
			
		||||
	}
 | 
			
		||||
@@ -442,8 +322,7 @@ int i2d_DSA_PUBKEY(DSA *a, unsigned char **pp)
 | 
			
		||||
	int ret;
 | 
			
		||||
	if(!a) return 0;
 | 
			
		||||
	pktmp = EVP_PKEY_new();
 | 
			
		||||
	if(!pktmp)
 | 
			
		||||
		{
 | 
			
		||||
	if(!pktmp) {
 | 
			
		||||
		ASN1err(ASN1_F_I2D_DSA_PUBKEY, ERR_R_MALLOC_FAILURE);
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
@@ -453,41 +332,3 @@ int i2d_DSA_PUBKEY(DSA *a, unsigned char **pp)
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_EC
 | 
			
		||||
EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, unsigned char **pp, long length)
 | 
			
		||||
	{
 | 
			
		||||
	EVP_PKEY *pkey;
 | 
			
		||||
	EC_KEY *key;
 | 
			
		||||
	unsigned char *q;
 | 
			
		||||
	q = *pp;
 | 
			
		||||
	pkey = d2i_PUBKEY(NULL, &q, length);
 | 
			
		||||
	if (!pkey) return(NULL);
 | 
			
		||||
	key = EVP_PKEY_get1_EC_KEY(pkey);
 | 
			
		||||
	EVP_PKEY_free(pkey);
 | 
			
		||||
	if (!key)  return(NULL);
 | 
			
		||||
	*pp = q;
 | 
			
		||||
	if (a)
 | 
			
		||||
		{
 | 
			
		||||
		EC_KEY_free(*a);
 | 
			
		||||
		*a = key;
 | 
			
		||||
		}
 | 
			
		||||
	return(key);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp)
 | 
			
		||||
	{
 | 
			
		||||
	EVP_PKEY *pktmp;
 | 
			
		||||
	int ret;
 | 
			
		||||
	if (!a)	return(0);
 | 
			
		||||
	if ((pktmp = EVP_PKEY_new()) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		ASN1err(ASN1_F_I2D_EC_PUBKEY, ERR_R_MALLOC_FAILURE);
 | 
			
		||||
		return(0);
 | 
			
		||||
		}
 | 
			
		||||
	EVP_PKEY_set1_EC_KEY(pktmp, a);
 | 
			
		||||
	ret = i2d_PUBKEY(pktmp, pp);
 | 
			
		||||
	EVP_PKEY_free(pktmp);
 | 
			
		||||
	return(ret);
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -91,14 +91,6 @@ static X509_CERT_AUX *aux_get(X509 *x)
 | 
			
		||||
int X509_alias_set1(X509 *x, unsigned char *name, int len)
 | 
			
		||||
{
 | 
			
		||||
	X509_CERT_AUX *aux;
 | 
			
		||||
	if (!name)
 | 
			
		||||
		{
 | 
			
		||||
		if (!x || !x->aux || !x->aux->alias)
 | 
			
		||||
			return 1;
 | 
			
		||||
		ASN1_UTF8STRING_free(x->aux->alias);
 | 
			
		||||
		x->aux->alias = NULL;
 | 
			
		||||
		return 1;
 | 
			
		||||
		}
 | 
			
		||||
	if(!(aux = aux_get(x))) return 0;
 | 
			
		||||
	if(!aux->alias && !(aux->alias = ASN1_UTF8STRING_new())) return 0;
 | 
			
		||||
	return ASN1_STRING_set(aux->alias, name, len);
 | 
			
		||||
@@ -107,14 +99,6 @@ int X509_alias_set1(X509 *x, unsigned char *name, int len)
 | 
			
		||||
int X509_keyid_set1(X509 *x, unsigned char *id, int len)
 | 
			
		||||
{
 | 
			
		||||
	X509_CERT_AUX *aux;
 | 
			
		||||
	if (!id)
 | 
			
		||||
		{
 | 
			
		||||
		if (!x || !x->aux || !x->aux->keyid)
 | 
			
		||||
			return 1;
 | 
			
		||||
		ASN1_OCTET_STRING_free(x->aux->keyid);
 | 
			
		||||
		x->aux->keyid = NULL;
 | 
			
		||||
		return 1;
 | 
			
		||||
		}
 | 
			
		||||
	if(!(aux = aux_get(x))) return 0;
 | 
			
		||||
	if(!aux->keyid && !(aux->keyid = ASN1_OCTET_STRING_new())) return 0;
 | 
			
		||||
	return ASN1_STRING_set(aux->keyid, id, len);
 | 
			
		||||
@@ -127,13 +111,6 @@ unsigned char *X509_alias_get0(X509 *x, int *len)
 | 
			
		||||
	return x->aux->alias->data;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
unsigned char *X509_keyid_get0(X509 *x, int *len)
 | 
			
		||||
{
 | 
			
		||||
	if(!x->aux || !x->aux->keyid) return NULL;
 | 
			
		||||
	if(len) *len = x->aux->keyid->length;
 | 
			
		||||
	return x->aux->keyid->data;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj)
 | 
			
		||||
{
 | 
			
		||||
	X509_CERT_AUX *aux;
 | 
			
		||||
@@ -172,9 +149,3 @@ void X509_reject_clear(X509 *x)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ASN1_SEQUENCE(X509_CERT_PAIR) = {
 | 
			
		||||
	ASN1_EXP_OPT(X509_CERT_PAIR, forward, X509, 0),
 | 
			
		||||
	ASN1_EXP_OPT(X509_CERT_PAIR, reverse, X509, 1)
 | 
			
		||||
} ASN1_SEQUENCE_END(X509_CERT_PAIR)
 | 
			
		||||
 | 
			
		||||
IMPLEMENT_ASN1_FUNCTIONS(X509_CERT_PAIR)
 | 
			
		||||
 
 | 
			
		||||
@@ -62,7 +62,6 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <openssl/opensslconf.h> /* To see if OPENSSL_NO_BF is defined */
 | 
			
		||||
 | 
			
		||||
#include "../e_os.h"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -56,6 +56,8 @@
 | 
			
		||||
 * [including the GNU Public Licence.]
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_SOCK
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
@@ -63,8 +65,6 @@
 | 
			
		||||
#include "cryptlib.h"
 | 
			
		||||
#include <openssl/bio.h>
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_SOCK
 | 
			
		||||
 | 
			
		||||
#ifdef OPENSSL_SYS_WIN16
 | 
			
		||||
#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */
 | 
			
		||||
#else
 | 
			
		||||
 
 | 
			
		||||
@@ -127,7 +127,7 @@ static int nbiof_read(BIO *b, char *out, int outl)
 | 
			
		||||
	{
 | 
			
		||||
	NBIO_TEST *nt;
 | 
			
		||||
	int ret=0;
 | 
			
		||||
#if 1
 | 
			
		||||
#if 0
 | 
			
		||||
	int num;
 | 
			
		||||
	unsigned char n;
 | 
			
		||||
#endif
 | 
			
		||||
@@ -137,7 +137,7 @@ static int nbiof_read(BIO *b, char *out, int outl)
 | 
			
		||||
	nt=(NBIO_TEST *)b->ptr;
 | 
			
		||||
 | 
			
		||||
	BIO_clear_retry_flags(b);
 | 
			
		||||
#if 1
 | 
			
		||||
#if 0
 | 
			
		||||
	RAND_pseudo_bytes(&n,1);
 | 
			
		||||
	num=(n&0x07);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -59,14 +59,13 @@
 | 
			
		||||
#ifndef HEADER_BIO_H
 | 
			
		||||
#define HEADER_BIO_H
 | 
			
		||||
 | 
			
		||||
#include <openssl/e_os2.h>
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_FP_API
 | 
			
		||||
# include <stdio.h>
 | 
			
		||||
#endif
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
 | 
			
		||||
#include <openssl/crypto.h>
 | 
			
		||||
#include <openssl/e_os2.h>
 | 
			
		||||
 | 
			
		||||
#ifdef  __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
@@ -612,17 +611,10 @@ void BIO_copy_next_retry(BIO *b);
 | 
			
		||||
 | 
			
		||||
/*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/
 | 
			
		||||
 | 
			
		||||
#ifndef __GNUC__
 | 
			
		||||
#define __attribute__(x)
 | 
			
		||||
#endif
 | 
			
		||||
int BIO_printf(BIO *bio, const char *format, ...)
 | 
			
		||||
	__attribute__((__format__(__printf__,2,3)));
 | 
			
		||||
int BIO_vprintf(BIO *bio, const char *format, va_list args)
 | 
			
		||||
	__attribute__((__format__(__printf__,2,0)));
 | 
			
		||||
int BIO_snprintf(char *buf, size_t n, const char *format, ...)
 | 
			
		||||
	__attribute__((__format__(__printf__,3,4)));
 | 
			
		||||
int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
 | 
			
		||||
	__attribute__((__format__(__printf__,3,0)));
 | 
			
		||||
int BIO_printf(BIO *bio, const char *format, ...);
 | 
			
		||||
int BIO_vprintf(BIO *bio, const char *format, va_list args);
 | 
			
		||||
int BIO_snprintf(char *buf, size_t n, const char *format, ...);
 | 
			
		||||
int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args);
 | 
			
		||||
 | 
			
		||||
/* BEGIN ERROR CODES */
 | 
			
		||||
/* The following lines are auto generated by the script mkerr.pl. Any changes
 | 
			
		||||
 
 | 
			
		||||
@@ -61,7 +61,6 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <openssl/err.h>
 | 
			
		||||
#include <openssl/bio.h>
 | 
			
		||||
#include <openssl/opensslconf.h> /* To see if OPENSSL_NO_ERR is defined */
 | 
			
		||||
 | 
			
		||||
/* BEGIN ERROR CODES */
 | 
			
		||||
#ifndef OPENSSL_NO_ERR
 | 
			
		||||
 
 | 
			
		||||
@@ -56,14 +56,14 @@
 | 
			
		||||
 * [including the GNU Public Licence.]
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_SOCK
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#define USE_SOCKETS
 | 
			
		||||
#include "cryptlib.h"
 | 
			
		||||
#include <openssl/bio.h>
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_SOCK
 | 
			
		||||
 | 
			
		||||
#ifdef OPENSSL_SYS_WIN16
 | 
			
		||||
#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */
 | 
			
		||||
#else
 | 
			
		||||
 
 | 
			
		||||
@@ -56,14 +56,14 @@
 | 
			
		||||
 * [including the GNU Public Licence.]
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_SOCK
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#define USE_SOCKETS
 | 
			
		||||
#include "cryptlib.h"
 | 
			
		||||
#include <openssl/bio.h>
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_SOCK
 | 
			
		||||
 | 
			
		||||
#ifdef OPENSSL_SYS_WIN16
 | 
			
		||||
#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */
 | 
			
		||||
#else
 | 
			
		||||
 
 | 
			
		||||
@@ -213,12 +213,29 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
 | 
			
		||||
		b->shutdown=(int)num&BIO_CLOSE;
 | 
			
		||||
		b->ptr=(char *)ptr;
 | 
			
		||||
		b->init=1;
 | 
			
		||||
#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS)
 | 
			
		||||
		/* Set correct text/binary mode */
 | 
			
		||||
#if defined(OPENSSL_SYS_WINDOWS)
 | 
			
		||||
		if (num & BIO_FP_TEXT)
 | 
			
		||||
			_setmode(fileno((FILE *)ptr),_O_TEXT);
 | 
			
		||||
		else
 | 
			
		||||
			_setmode(fileno((FILE *)ptr),_O_BINARY);
 | 
			
		||||
#elif defined(OPENSSL_SYS_MSDOS)
 | 
			
		||||
		{
 | 
			
		||||
		int fd = fileno((FILE*)ptr);
 | 
			
		||||
		/* Set correct text/binary mode */
 | 
			
		||||
		if (num & BIO_FP_TEXT)
 | 
			
		||||
			_setmode(fd,_O_TEXT);
 | 
			
		||||
		/* Dangerous to set stdin/stdout to raw (unless redirected) */
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			if (fd == STDIN_FILENO || fd == STDOUT_FILENO)
 | 
			
		||||
				{
 | 
			
		||||
				if (isatty(fd) <= 0)
 | 
			
		||||
					_setmode(fd,_O_BINARY);
 | 
			
		||||
				}
 | 
			
		||||
			else
 | 
			
		||||
				_setmode(fd,_O_BINARY);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
#elif defined(OPENSSL_SYS_OS2)
 | 
			
		||||
		if (num & BIO_FP_TEXT)
 | 
			
		||||
			setmode(fileno((FILE *)ptr), O_TEXT);
 | 
			
		||||
 
 | 
			
		||||
@@ -56,6 +56,8 @@
 | 
			
		||||
 * [including the GNU Public Licence.]
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_NO_SOCK
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#define USE_SOCKETS
 | 
			
		||||
@@ -300,3 +302,4 @@ int BIO_sock_non_fatal_error(int err)
 | 
			
		||||
		}
 | 
			
		||||
	return(0);
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -32,14 +32,12 @@ LIB=$(TOP)/libcrypto.a
 | 
			
		||||
LIBSRC=	bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c \
 | 
			
		||||
	bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \
 | 
			
		||||
	bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c \
 | 
			
		||||
	bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_gf2m.c bn_nist.c \
 | 
			
		||||
	bn_depr.c
 | 
			
		||||
	bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c
 | 
			
		||||
 | 
			
		||||
LIBOBJ=	bn_add.o bn_div.o bn_exp.o bn_lib.o bn_ctx.o bn_mul.o bn_mod.o \
 | 
			
		||||
	bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \
 | 
			
		||||
	bn_kron.o bn_sqrt.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) \
 | 
			
		||||
	bn_recp.o bn_mont.o bn_mpi.o bn_exp2.o bn_gf2m.o bn_nist.o \
 | 
			
		||||
	bn_depr.o
 | 
			
		||||
	bn_recp.o bn_mont.o bn_mpi.o bn_exp2.o
 | 
			
		||||
 | 
			
		||||
SRC= $(LIBSRC)
 | 
			
		||||
 | 
			
		||||
@@ -194,14 +192,6 @@ bn_ctx.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
 | 
			
		||||
bn_ctx.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
 | 
			
		||||
bn_ctx.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
 | 
			
		||||
bn_ctx.o: ../cryptlib.h bn_ctx.c bn_lcl.h
 | 
			
		||||
bn_depr.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
 | 
			
		||||
bn_depr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
 | 
			
		||||
bn_depr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
 | 
			
		||||
bn_depr.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
 | 
			
		||||
bn_depr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
 | 
			
		||||
bn_depr.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
 | 
			
		||||
bn_depr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
 | 
			
		||||
bn_depr.o: ../cryptlib.h bn_depr.c bn_lcl.h
 | 
			
		||||
bn_div.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
 | 
			
		||||
bn_div.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
 | 
			
		||||
bn_div.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
 | 
			
		||||
@@ -236,13 +226,6 @@ bn_gcd.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
 | 
			
		||||
bn_gcd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
 | 
			
		||||
bn_gcd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
 | 
			
		||||
bn_gcd.o: ../cryptlib.h bn_gcd.c bn_lcl.h
 | 
			
		||||
bn_gf2m.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
 | 
			
		||||
bn_gf2m.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
 | 
			
		||||
bn_gf2m.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
 | 
			
		||||
bn_gf2m.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
 | 
			
		||||
bn_gf2m.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
 | 
			
		||||
bn_gf2m.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
 | 
			
		||||
bn_gf2m.o: ../cryptlib.h bn_gf2m.c bn_lcl.h
 | 
			
		||||
bn_kron.o: ../../include/openssl/bn.h ../../include/openssl/e_os2.h
 | 
			
		||||
bn_kron.o: ../../include/openssl/opensslconf.h bn_kron.c bn_lcl.h
 | 
			
		||||
bn_lib.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
 | 
			
		||||
@@ -280,13 +263,6 @@ bn_mul.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
 | 
			
		||||
bn_mul.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
 | 
			
		||||
bn_mul.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
 | 
			
		||||
bn_mul.o: ../cryptlib.h bn_lcl.h bn_mul.c
 | 
			
		||||
bn_nist.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
 | 
			
		||||
bn_nist.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
 | 
			
		||||
bn_nist.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
 | 
			
		||||
bn_nist.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
 | 
			
		||||
bn_nist.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
 | 
			
		||||
bn_nist.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
 | 
			
		||||
bn_nist.o: ../cryptlib.h bn_lcl.h bn_nist.c
 | 
			
		||||
bn_prime.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
 | 
			
		||||
bn_prime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
 | 
			
		||||
bn_prime.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										133
									
								
								crypto/bn/bn.h
									
									
									
									
									
								
							
							
						
						
									
										133
									
								
								crypto/bn/bn.h
									
									
									
									
									
								
							@@ -55,19 +55,6 @@
 | 
			
		||||
 * copied and put under another distribution licence
 | 
			
		||||
 * [including the GNU Public Licence.]
 | 
			
		||||
 */
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 | 
			
		||||
 *
 | 
			
		||||
 * Portions of the attached software ("Contribution") are developed by 
 | 
			
		||||
 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
 | 
			
		||||
 *
 | 
			
		||||
 * The Contribution is licensed pursuant to the Eric Young open source
 | 
			
		||||
 * license provided above.
 | 
			
		||||
 *
 | 
			
		||||
 * The binary polynomial arithmetic software is originally written by 
 | 
			
		||||
 * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef HEADER_BN_H
 | 
			
		||||
#define HEADER_BN_H
 | 
			
		||||
@@ -289,35 +276,6 @@ typedef struct bn_recp_ctx_st
 | 
			
		||||
	int flags;
 | 
			
		||||
	} BN_RECP_CTX;
 | 
			
		||||
 | 
			
		||||
/* Used for slow "generation" functions. */
 | 
			
		||||
typedef struct bn_gencb_st BN_GENCB;
 | 
			
		||||
struct bn_gencb_st
 | 
			
		||||
	{
 | 
			
		||||
	unsigned int ver;	/* To handle binary (in)compatibility */
 | 
			
		||||
	void *arg;		/* callback-specific data */
 | 
			
		||||
	union
 | 
			
		||||
		{
 | 
			
		||||
		/* if(ver==1) - handles old style callbacks */
 | 
			
		||||
		void (*cb_1)(int, int, void *);
 | 
			
		||||
		/* if(ver==2) - new callback style */
 | 
			
		||||
		int (*cb_2)(int, int, BN_GENCB *);
 | 
			
		||||
		} cb;
 | 
			
		||||
	};
 | 
			
		||||
/* Wrapper function to make using BN_GENCB easier,  */
 | 
			
		||||
int BN_GENCB_call(BN_GENCB *cb, int a, int b);
 | 
			
		||||
/* Macro to populate a BN_GENCB structure with an "old"-style callback */
 | 
			
		||||
#define BN_GENCB_set_old(gencb, callback, cb_arg) { \
 | 
			
		||||
		BN_GENCB *tmp_gencb = (gencb); \
 | 
			
		||||
		tmp_gencb->ver = 1; \
 | 
			
		||||
		tmp_gencb->arg = (cb_arg); \
 | 
			
		||||
		tmp_gencb->cb.cb_1 = (callback); }
 | 
			
		||||
/* Macro to populate a BN_GENCB structure with a "new"-style callback */
 | 
			
		||||
#define BN_GENCB_set(gencb, callback, cb_arg) { \
 | 
			
		||||
		BN_GENCB *tmp_gencb = (gencb); \
 | 
			
		||||
		tmp_gencb->ver = 2; \
 | 
			
		||||
		tmp_gencb->arg = (cb_arg); \
 | 
			
		||||
		tmp_gencb->cb.cb_2 = (callback); }
 | 
			
		||||
 | 
			
		||||
#define BN_prime_checks 0 /* default: select number of iterations
 | 
			
		||||
			     based on the size of the number */
 | 
			
		||||
 | 
			
		||||
@@ -351,11 +309,6 @@ int BN_GENCB_call(BN_GENCB *cb, int a, int b);
 | 
			
		||||
 | 
			
		||||
#define BN_one(a)	(BN_set_word((a),1))
 | 
			
		||||
#define BN_zero(a)	(BN_set_word((a),0))
 | 
			
		||||
/* BN_set_sign(BIGNUM *, int) sets the sign of a BIGNUM
 | 
			
		||||
 * (0 for a non-negative value, 1 for negative) */
 | 
			
		||||
#define BN_set_sign(a,b) ((a)->neg = (b))
 | 
			
		||||
/* BN_get_sign(BIGNUM *) returns the sign of the BIGNUM */
 | 
			
		||||
#define BN_get_sign(a)   ((a)->neg)
 | 
			
		||||
 | 
			
		||||
/*#define BN_ascii2bn(a)	BN_hex2bn(a) */
 | 
			
		||||
/*#define BN_bn2ascii(a)	BN_bn2hex(a) */
 | 
			
		||||
@@ -378,8 +331,6 @@ BIGNUM *BN_new(void);
 | 
			
		||||
void	BN_init(BIGNUM *);
 | 
			
		||||
void	BN_clear_free(BIGNUM *a);
 | 
			
		||||
BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
 | 
			
		||||
/* BN_ncopy(): like BN_copy() but copies at most the first n BN_ULONGs */
 | 
			
		||||
BIGNUM *BN_ncopy(BIGNUM *a, const BIGNUM *b, size_t n);
 | 
			
		||||
void	BN_swap(BIGNUM *a, BIGNUM *b);
 | 
			
		||||
BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret);
 | 
			
		||||
int	BN_bn2bin(const BIGNUM *a, unsigned char *to);
 | 
			
		||||
@@ -462,9 +413,6 @@ BIGNUM *BN_mod_inverse(BIGNUM *ret,
 | 
			
		||||
	const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
 | 
			
		||||
BIGNUM *BN_mod_sqrt(BIGNUM *ret,
 | 
			
		||||
	const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
 | 
			
		||||
 | 
			
		||||
/* Deprecated versions */
 | 
			
		||||
#ifndef OPENSSL_NO_DEPRECATED
 | 
			
		||||
BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe,
 | 
			
		||||
	const BIGNUM *add, const BIGNUM *rem,
 | 
			
		||||
	void (*callback)(int,int,void *),void *cb_arg);
 | 
			
		||||
@@ -474,14 +422,6 @@ int	BN_is_prime(const BIGNUM *p,int nchecks,
 | 
			
		||||
int	BN_is_prime_fasttest(const BIGNUM *p,int nchecks,
 | 
			
		||||
	void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg,
 | 
			
		||||
	int do_trial_division);
 | 
			
		||||
#endif /* !defined(OPENSSL_NO_DEPRECATED) */
 | 
			
		||||
 | 
			
		||||
/* Newer versions */
 | 
			
		||||
int	BN_generate_prime_ex(BIGNUM *ret,int bits,int safe, const BIGNUM *add,
 | 
			
		||||
		const BIGNUM *rem, BN_GENCB *cb);
 | 
			
		||||
int	BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb);
 | 
			
		||||
int	BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx,
 | 
			
		||||
		int do_trial_division, BN_GENCB *cb);
 | 
			
		||||
 | 
			
		||||
BN_MONT_CTX *BN_MONT_CTX_new(void );
 | 
			
		||||
void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
 | 
			
		||||
@@ -515,71 +455,6 @@ int	BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
 | 
			
		||||
int	BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
 | 
			
		||||
	BN_RECP_CTX *recp, BN_CTX *ctx);
 | 
			
		||||
 | 
			
		||||
/* Functions for arithmetic over binary polynomials represented by BIGNUMs. 
 | 
			
		||||
 *
 | 
			
		||||
 * The BIGNUM::neg property of BIGNUMs representing binary polynomials is
 | 
			
		||||
 * ignored.
 | 
			
		||||
 *
 | 
			
		||||
 * Note that input arguments are not const so that their bit arrays can
 | 
			
		||||
 * be expanded to the appropriate size if needed.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
int	BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); /*r = a + b*/
 | 
			
		||||
#define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b)
 | 
			
		||||
int	BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); /*r=a mod p*/
 | 
			
		||||
int	BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
 | 
			
		||||
	const BIGNUM *p, BN_CTX *ctx); /* r = (a * b) mod p */
 | 
			
		||||
int	BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
 | 
			
		||||
	BN_CTX *ctx); /* r = (a * a) mod p */
 | 
			
		||||
int	BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p,
 | 
			
		||||
	BN_CTX *ctx); /* r = (1 / b) mod p */
 | 
			
		||||
int	BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
 | 
			
		||||
	const BIGNUM *p, BN_CTX *ctx); /* r = (a / b) mod p */
 | 
			
		||||
int	BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
 | 
			
		||||
	const BIGNUM *p, BN_CTX *ctx); /* r = (a ^ b) mod p */
 | 
			
		||||
int	BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
 | 
			
		||||
	BN_CTX *ctx); /* r = sqrt(a) mod p */
 | 
			
		||||
int	BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
 | 
			
		||||
	BN_CTX *ctx); /* r^2 + r = a mod p */
 | 
			
		||||
#define BN_GF2m_cmp(a, b) BN_ucmp((a), (b))
 | 
			
		||||
/* Some functions allow for representation of the irreducible polynomials
 | 
			
		||||
 * as an unsigned int[], say p.  The irreducible f(t) is then of the form:
 | 
			
		||||
 *     t^p[0] + t^p[1] + ... + t^p[k]
 | 
			
		||||
 * where m = p[0] > p[1] > ... > p[k] = 0.
 | 
			
		||||
 */
 | 
			
		||||
int	BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[]);
 | 
			
		||||
	/* r = a mod p */
 | 
			
		||||
int	BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
 | 
			
		||||
	const unsigned int p[], BN_CTX *ctx); /* r = (a * b) mod p */
 | 
			
		||||
int	BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[],
 | 
			
		||||
	BN_CTX *ctx); /* r = (a * a) mod p */
 | 
			
		||||
int	BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const unsigned int p[],
 | 
			
		||||
	BN_CTX *ctx); /* r = (1 / b) mod p */
 | 
			
		||||
int	BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
 | 
			
		||||
	const unsigned int p[], BN_CTX *ctx); /* r = (a / b) mod p */
 | 
			
		||||
int	BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
 | 
			
		||||
	const unsigned int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */
 | 
			
		||||
int	BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,
 | 
			
		||||
	const unsigned int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */
 | 
			
		||||
int	BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,
 | 
			
		||||
	const unsigned int p[], BN_CTX *ctx); /* r^2 + r = a mod p */
 | 
			
		||||
int	BN_GF2m_poly2arr(const BIGNUM *a, unsigned int p[], int max);
 | 
			
		||||
int	BN_GF2m_arr2poly(const unsigned int p[], BIGNUM *a);
 | 
			
		||||
 | 
			
		||||
/* faster mod functions for the 'NIST primes' 
 | 
			
		||||
 * 0 <= a < p^2 */
 | 
			
		||||
int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
 | 
			
		||||
int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
 | 
			
		||||
int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
 | 
			
		||||
int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
 | 
			
		||||
int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
 | 
			
		||||
 | 
			
		||||
const BIGNUM *BN_get0_nist_prime_192(void);
 | 
			
		||||
const BIGNUM *BN_get0_nist_prime_224(void);
 | 
			
		||||
const BIGNUM *BN_get0_nist_prime_256(void);
 | 
			
		||||
const BIGNUM *BN_get0_nist_prime_384(void);
 | 
			
		||||
const BIGNUM *BN_get0_nist_prime_521(void);
 | 
			
		||||
 | 
			
		||||
/* library internal functions */
 | 
			
		||||
 | 
			
		||||
#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\
 | 
			
		||||
@@ -637,13 +512,6 @@ void ERR_load_BN_strings(void);
 | 
			
		||||
#define BN_F_BN_DIV					 107
 | 
			
		||||
#define BN_F_BN_EXPAND2					 108
 | 
			
		||||
#define BN_F_BN_EXPAND_INTERNAL				 120
 | 
			
		||||
#define BN_F_BN_GF2M_MOD				 126
 | 
			
		||||
#define BN_F_BN_GF2M_MOD_DIV				 123
 | 
			
		||||
#define BN_F_BN_GF2M_MOD_EXP				 127
 | 
			
		||||
#define BN_F_BN_GF2M_MOD_MUL				 124
 | 
			
		||||
#define BN_F_BN_GF2M_MOD_SOLVE_QUAD			 128
 | 
			
		||||
#define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR			 129
 | 
			
		||||
#define BN_F_BN_GF2M_MOD_SQR				 125
 | 
			
		||||
#define BN_F_BN_MOD_EXP2_MONT				 118
 | 
			
		||||
#define BN_F_BN_MOD_EXP_MONT				 109
 | 
			
		||||
#define BN_F_BN_MOD_EXP_MONT_WORD			 117
 | 
			
		||||
@@ -669,7 +537,6 @@ void ERR_load_BN_strings(void);
 | 
			
		||||
#define BN_R_INVALID_LENGTH				 106
 | 
			
		||||
#define BN_R_INVALID_RANGE				 115
 | 
			
		||||
#define BN_R_NOT_A_SQUARE				 111
 | 
			
		||||
#define BN_R_NOT_IMPLEMENTED				 116
 | 
			
		||||
#define BN_R_NOT_INITIALIZED				 107
 | 
			
		||||
#define BN_R_NO_INVERSE					 108
 | 
			
		||||
#define BN_R_P_IS_NOT_PRIME				 112
 | 
			
		||||
 
 | 
			
		||||
@@ -1,108 +0,0 @@
 | 
			
		||||
/* crypto/bn/bn_depr.c */
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *
 | 
			
		||||
 * 1. Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer. 
 | 
			
		||||
 *
 | 
			
		||||
 * 2. Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * 3. All advertising materials mentioning features or use of this
 | 
			
		||||
 *    software must display the following acknowledgment:
 | 
			
		||||
 *    "This product includes software developed by the OpenSSL Project
 | 
			
		||||
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 | 
			
		||||
 *
 | 
			
		||||
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 | 
			
		||||
 *    endorse or promote products derived from this software without
 | 
			
		||||
 *    prior written permission. For written permission, please contact
 | 
			
		||||
 *    openssl-core@openssl.org.
 | 
			
		||||
 *
 | 
			
		||||
 * 5. Products derived from this software may not be called "OpenSSL"
 | 
			
		||||
 *    nor may "OpenSSL" appear in their names without prior written
 | 
			
		||||
 *    permission of the OpenSSL Project.
 | 
			
		||||
 *
 | 
			
		||||
 * 6. Redistributions of any form whatsoever must retain the following
 | 
			
		||||
 *    acknowledgment:
 | 
			
		||||
 *    "This product includes software developed by the OpenSSL Project
 | 
			
		||||
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 | 
			
		||||
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 | 
			
		||||
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
 | 
			
		||||
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 | 
			
		||||
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 | 
			
		||||
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 | 
			
		||||
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 | 
			
		||||
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 | 
			
		||||
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 | 
			
		||||
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 | 
			
		||||
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
 * ====================================================================
 | 
			
		||||
 *
 | 
			
		||||
 * This product includes cryptographic software written by Eric Young
 | 
			
		||||
 * (eay@cryptsoft.com).  This product includes software written by Tim
 | 
			
		||||
 * Hudson (tjh@cryptsoft.com).
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* Support for deprecated functions goes here - static linkage will only slurp
 | 
			
		||||
 * this code if applications are using them directly. */
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
#include "cryptlib.h"
 | 
			
		||||
#include "bn_lcl.h"
 | 
			
		||||
#include <openssl/rand.h>
 | 
			
		||||
 | 
			
		||||
BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
 | 
			
		||||
	const BIGNUM *add, const BIGNUM *rem,
 | 
			
		||||
	void (*callback)(int,int,void *), void *cb_arg)
 | 
			
		||||
	{
 | 
			
		||||
	BN_GENCB cb;
 | 
			
		||||
	BIGNUM *rnd=NULL;
 | 
			
		||||
	int found = 0;
 | 
			
		||||
 | 
			
		||||
	BN_GENCB_set_old(&cb, callback, cb_arg);
 | 
			
		||||
 | 
			
		||||
	if (ret == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		if ((rnd=BN_new()) == NULL) goto err;
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		rnd=ret;
 | 
			
		||||
	if(!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb))
 | 
			
		||||
		goto err;
 | 
			
		||||
 | 
			
		||||
	/* we have a prime :-) */
 | 
			
		||||
	found = 1;
 | 
			
		||||
err:
 | 
			
		||||
	if (!found && (ret == NULL) && (rnd != NULL)) BN_free(rnd);
 | 
			
		||||
	return(found ? rnd : NULL);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int,int,void *),
 | 
			
		||||
	BN_CTX *ctx_passed, void *cb_arg)
 | 
			
		||||
	{
 | 
			
		||||
	BN_GENCB cb;
 | 
			
		||||
	BN_GENCB_set_old(&cb, callback, cb_arg);
 | 
			
		||||
	return BN_is_prime_ex(a, checks, ctx_passed, &cb);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int BN_is_prime_fasttest(const BIGNUM *a, int checks,
 | 
			
		||||
		void (*callback)(int,int,void *),
 | 
			
		||||
		BN_CTX *ctx_passed, void *cb_arg,
 | 
			
		||||
		int do_trial_division)
 | 
			
		||||
	{
 | 
			
		||||
	BN_GENCB cb;
 | 
			
		||||
	BN_GENCB_set_old(&cb, callback, cb_arg);
 | 
			
		||||
	return BN_is_prime_fasttest_ex(a, checks, ctx_passed,
 | 
			
		||||
				do_trial_division, &cb);
 | 
			
		||||
	}
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
/* crypto/bn/bn_err.c */
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright (c) 1999-2002 The OpenSSL Project.  All rights reserved.
 | 
			
		||||
 * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
@@ -61,7 +61,6 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <openssl/err.h>
 | 
			
		||||
#include <openssl/bn.h>
 | 
			
		||||
#include <openssl/opensslconf.h> /* To see if OPENSSL_NO_ERR is defined */
 | 
			
		||||
 | 
			
		||||
/* BEGIN ERROR CODES */
 | 
			
		||||
#ifndef OPENSSL_NO_ERR
 | 
			
		||||
@@ -78,13 +77,6 @@ static ERR_STRING_DATA BN_str_functs[]=
 | 
			
		||||
{ERR_PACK(0,BN_F_BN_DIV,0),	"BN_div"},
 | 
			
		||||
{ERR_PACK(0,BN_F_BN_EXPAND2,0),	"bn_expand2"},
 | 
			
		||||
{ERR_PACK(0,BN_F_BN_EXPAND_INTERNAL,0),	"BN_EXPAND_INTERNAL"},
 | 
			
		||||
{ERR_PACK(0,BN_F_BN_GF2M_MOD,0),	"BN_GF2m_mod"},
 | 
			
		||||
{ERR_PACK(0,BN_F_BN_GF2M_MOD_DIV,0),	"BN_GF2m_mod_div"},
 | 
			
		||||
{ERR_PACK(0,BN_F_BN_GF2M_MOD_EXP,0),	"BN_GF2m_mod_exp"},
 | 
			
		||||
{ERR_PACK(0,BN_F_BN_GF2M_MOD_MUL,0),	"BN_GF2m_mod_mul"},
 | 
			
		||||
{ERR_PACK(0,BN_F_BN_GF2M_MOD_SOLVE_QUAD,0),	"BN_GF2m_mod_solve_quad"},
 | 
			
		||||
{ERR_PACK(0,BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR,0),	"BN_GF2m_mod_solve_quad_arr"},
 | 
			
		||||
{ERR_PACK(0,BN_F_BN_GF2M_MOD_SQR,0),	"BN_GF2m_mod_sqr"},
 | 
			
		||||
{ERR_PACK(0,BN_F_BN_MOD_EXP2_MONT,0),	"BN_mod_exp2_mont"},
 | 
			
		||||
{ERR_PACK(0,BN_F_BN_MOD_EXP_MONT,0),	"BN_mod_exp_mont"},
 | 
			
		||||
{ERR_PACK(0,BN_F_BN_MOD_EXP_MONT_WORD,0),	"BN_mod_exp_mont_word"},
 | 
			
		||||
@@ -113,7 +105,6 @@ static ERR_STRING_DATA BN_str_reasons[]=
 | 
			
		||||
{BN_R_INVALID_LENGTH                     ,"invalid length"},
 | 
			
		||||
{BN_R_INVALID_RANGE                      ,"invalid range"},
 | 
			
		||||
{BN_R_NOT_A_SQUARE                       ,"not a square"},
 | 
			
		||||
{BN_R_NOT_IMPLEMENTED                    ,"not implemented"},
 | 
			
		||||
{BN_R_NOT_INITIALIZED                    ,"not initialized"},
 | 
			
		||||
{BN_R_NO_INVERSE                         ,"no inverse"},
 | 
			
		||||
{BN_R_P_IS_NOT_PRIME                     ,"p is not prime"},
 | 
			
		||||
 
 | 
			
		||||
@@ -1,996 +0,0 @@
 | 
			
		||||
/* crypto/bn/bn_gf2m.c */
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 | 
			
		||||
 *
 | 
			
		||||
 * The Elliptic Curve Public-Key Crypto Library (ECC Code) included
 | 
			
		||||
 * herein is developed by SUN MICROSYSTEMS, INC., and is contributed
 | 
			
		||||
 * to the OpenSSL project.
 | 
			
		||||
 *
 | 
			
		||||
 * The ECC Code is licensed pursuant to the OpenSSL open source
 | 
			
		||||
 * license provided below.
 | 
			
		||||
 *
 | 
			
		||||
 * In addition, Sun covenants to all licensees who provide a reciprocal
 | 
			
		||||
 * covenant with respect to their own patents if any, not to sue under
 | 
			
		||||
 * current and future patent claims necessarily infringed by the making,
 | 
			
		||||
 * using, practicing, selling, offering for sale and/or otherwise
 | 
			
		||||
 * disposing of the ECC Code as delivered hereunder (or portions thereof),
 | 
			
		||||
 * provided that such covenant shall not apply:
 | 
			
		||||
 *  1) for code that a licensee deletes from the ECC Code;
 | 
			
		||||
 *  2) separates from the ECC Code; or
 | 
			
		||||
 *  3) for infringements caused by:
 | 
			
		||||
 *       i) the modification of the ECC Code or
 | 
			
		||||
 *      ii) the combination of the ECC Code with other software or
 | 
			
		||||
 *          devices where such combination causes the infringement.
 | 
			
		||||
 *
 | 
			
		||||
 * The software is originally written by Sheueling Chang Shantz and
 | 
			
		||||
 * Douglas Stebila of Sun Microsystems Laboratories.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* NOTE: This file is licensed pursuant to the OpenSSL license below
 | 
			
		||||
 * and may be modified; but after modifications, the above covenant
 | 
			
		||||
 * may no longer apply!  In such cases, the corresponding paragraph
 | 
			
		||||
 * ["In addition, Sun covenants ... causes the infringement."] and
 | 
			
		||||
 * this note can be edited out; but please keep the Sun copyright
 | 
			
		||||
 * notice and attribution. */
 | 
			
		||||
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *
 | 
			
		||||
 * 1. Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer. 
 | 
			
		||||
 *
 | 
			
		||||
 * 2. Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * 3. All advertising materials mentioning features or use of this
 | 
			
		||||
 *    software must display the following acknowledgment:
 | 
			
		||||
 *    "This product includes software developed by the OpenSSL Project
 | 
			
		||||
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 | 
			
		||||
 *
 | 
			
		||||
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 | 
			
		||||
 *    endorse or promote products derived from this software without
 | 
			
		||||
 *    prior written permission. For written permission, please contact
 | 
			
		||||
 *    openssl-core@openssl.org.
 | 
			
		||||
 *
 | 
			
		||||
 * 5. Products derived from this software may not be called "OpenSSL"
 | 
			
		||||
 *    nor may "OpenSSL" appear in their names without prior written
 | 
			
		||||
 *    permission of the OpenSSL Project.
 | 
			
		||||
 *
 | 
			
		||||
 * 6. Redistributions of any form whatsoever must retain the following
 | 
			
		||||
 *    acknowledgment:
 | 
			
		||||
 *    "This product includes software developed by the OpenSSL Project
 | 
			
		||||
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 | 
			
		||||
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 | 
			
		||||
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
 | 
			
		||||
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 | 
			
		||||
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 | 
			
		||||
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 | 
			
		||||
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 | 
			
		||||
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 | 
			
		||||
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 | 
			
		||||
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 | 
			
		||||
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
 * ====================================================================
 | 
			
		||||
 *
 | 
			
		||||
 * This product includes cryptographic software written by Eric Young
 | 
			
		||||
 * (eay@cryptsoft.com).  This product includes software written by Tim
 | 
			
		||||
 * Hudson (tjh@cryptsoft.com).
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
#include <limits.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "cryptlib.h"
 | 
			
		||||
#include "bn_lcl.h"
 | 
			
		||||
 | 
			
		||||
/* Maximum number of iterations before BN_GF2m_mod_solve_quad_arr should fail. */
 | 
			
		||||
#define MAX_ITERATIONS 50
 | 
			
		||||
 | 
			
		||||
static const BN_ULONG SQR_tb[16] =
 | 
			
		||||
  {     0,     1,     4,     5,    16,    17,    20,    21,
 | 
			
		||||
       64,    65,    68,    69,    80,    81,    84,    85 };
 | 
			
		||||
/* Platform-specific macros to accelerate squaring. */
 | 
			
		||||
#if defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)
 | 
			
		||||
#define SQR1(w) \
 | 
			
		||||
    SQR_tb[(w) >> 60 & 0xF] << 56 | SQR_tb[(w) >> 56 & 0xF] << 48 | \
 | 
			
		||||
    SQR_tb[(w) >> 52 & 0xF] << 40 | SQR_tb[(w) >> 48 & 0xF] << 32 | \
 | 
			
		||||
    SQR_tb[(w) >> 44 & 0xF] << 24 | SQR_tb[(w) >> 40 & 0xF] << 16 | \
 | 
			
		||||
    SQR_tb[(w) >> 36 & 0xF] <<  8 | SQR_tb[(w) >> 32 & 0xF]
 | 
			
		||||
#define SQR0(w) \
 | 
			
		||||
    SQR_tb[(w) >> 28 & 0xF] << 56 | SQR_tb[(w) >> 24 & 0xF] << 48 | \
 | 
			
		||||
    SQR_tb[(w) >> 20 & 0xF] << 40 | SQR_tb[(w) >> 16 & 0xF] << 32 | \
 | 
			
		||||
    SQR_tb[(w) >> 12 & 0xF] << 24 | SQR_tb[(w) >>  8 & 0xF] << 16 | \
 | 
			
		||||
    SQR_tb[(w) >>  4 & 0xF] <<  8 | SQR_tb[(w)       & 0xF]
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef THIRTY_TWO_BIT
 | 
			
		||||
#define SQR1(w) \
 | 
			
		||||
    SQR_tb[(w) >> 28 & 0xF] << 24 | SQR_tb[(w) >> 24 & 0xF] << 16 | \
 | 
			
		||||
    SQR_tb[(w) >> 20 & 0xF] <<  8 | SQR_tb[(w) >> 16 & 0xF]
 | 
			
		||||
#define SQR0(w) \
 | 
			
		||||
    SQR_tb[(w) >> 12 & 0xF] << 24 | SQR_tb[(w) >>  8 & 0xF] << 16 | \
 | 
			
		||||
    SQR_tb[(w) >>  4 & 0xF] <<  8 | SQR_tb[(w)       & 0xF]
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef SIXTEEN_BIT
 | 
			
		||||
#define SQR1(w) \
 | 
			
		||||
    SQR_tb[(w) >> 12 & 0xF] <<  8 | SQR_tb[(w) >>  8 & 0xF]
 | 
			
		||||
#define SQR0(w) \
 | 
			
		||||
    SQR_tb[(w) >>  4 & 0xF] <<  8 | SQR_tb[(w)       & 0xF]
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef EIGHT_BIT
 | 
			
		||||
#define SQR1(w) \
 | 
			
		||||
    SQR_tb[(w) >>  4 & 0xF]
 | 
			
		||||
#define SQR0(w) \
 | 
			
		||||
    SQR_tb[(w)       & 15]
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Product of two polynomials a, b each with degree < BN_BITS2 - 1,
 | 
			
		||||
 * result is a polynomial r with degree < 2 * BN_BITS - 1
 | 
			
		||||
 * The caller MUST ensure that the variables have the right amount
 | 
			
		||||
 * of space allocated.
 | 
			
		||||
 */
 | 
			
		||||
#ifdef EIGHT_BIT
 | 
			
		||||
static void bn_GF2m_mul_1x1(BN_ULONG *r1, BN_ULONG *r0, const BN_ULONG a, const BN_ULONG b)
 | 
			
		||||
	{
 | 
			
		||||
	register BN_ULONG h, l, s;
 | 
			
		||||
	BN_ULONG tab[4], top1b = a >> 7;
 | 
			
		||||
	register BN_ULONG a1, a2;
 | 
			
		||||
 | 
			
		||||
	a1 = a & (0x7F); a2 = a1 << 1;
 | 
			
		||||
 | 
			
		||||
	tab[0] = 0; tab[1] = a1; tab[2] = a2; tab[3] = a1^a2;
 | 
			
		||||
 | 
			
		||||
	s = tab[b      & 0x3]; l  = s;
 | 
			
		||||
	s = tab[b >> 2 & 0x3]; l ^= s << 2; h  = s >> 6;
 | 
			
		||||
	s = tab[b >> 4 & 0x3]; l ^= s << 4; h ^= s >> 4;
 | 
			
		||||
	s = tab[b >> 6      ]; l ^= s << 6; h ^= s >> 2;
 | 
			
		||||
	
 | 
			
		||||
	/* compensate for the top bit of a */
 | 
			
		||||
 | 
			
		||||
	if (top1b & 01) { l ^= b << 7; h ^= b >> 1; } 
 | 
			
		||||
 | 
			
		||||
	*r1 = h; *r0 = l;
 | 
			
		||||
	} 
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef SIXTEEN_BIT
 | 
			
		||||
static void bn_GF2m_mul_1x1(BN_ULONG *r1, BN_ULONG *r0, const BN_ULONG a, const BN_ULONG b)
 | 
			
		||||
	{
 | 
			
		||||
	register BN_ULONG h, l, s;
 | 
			
		||||
	BN_ULONG tab[4], top1b = a >> 15; 
 | 
			
		||||
	register BN_ULONG a1, a2;
 | 
			
		||||
 | 
			
		||||
	a1 = a & (0x7FFF); a2 = a1 << 1;
 | 
			
		||||
 | 
			
		||||
	tab[0] = 0; tab[1] = a1; tab[2] = a2; tab[3] = a1^a2;
 | 
			
		||||
 | 
			
		||||
	s = tab[b      & 0x3]; l  = s;
 | 
			
		||||
	s = tab[b >> 2 & 0x3]; l ^= s <<  2; h  = s >> 14;
 | 
			
		||||
	s = tab[b >> 4 & 0x3]; l ^= s <<  4; h ^= s >> 12;
 | 
			
		||||
	s = tab[b >> 6 & 0x3]; l ^= s <<  6; h ^= s >> 10;
 | 
			
		||||
	s = tab[b >> 8 & 0x3]; l ^= s <<  8; h ^= s >>  8;
 | 
			
		||||
	s = tab[b >>10 & 0x3]; l ^= s << 10; h ^= s >>  6;
 | 
			
		||||
	s = tab[b >>12 & 0x3]; l ^= s << 12; h ^= s >>  4;
 | 
			
		||||
	s = tab[b >>14      ]; l ^= s << 14; h ^= s >>  2;
 | 
			
		||||
 | 
			
		||||
	/* compensate for the top bit of a */
 | 
			
		||||
 | 
			
		||||
	if (top1b & 01) { l ^= b << 15; h ^= b >> 1; } 
 | 
			
		||||
 | 
			
		||||
	*r1 = h; *r0 = l;
 | 
			
		||||
	} 
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef THIRTY_TWO_BIT
 | 
			
		||||
static void bn_GF2m_mul_1x1(BN_ULONG *r1, BN_ULONG *r0, const BN_ULONG a, const BN_ULONG b)
 | 
			
		||||
	{
 | 
			
		||||
	register BN_ULONG h, l, s;
 | 
			
		||||
	BN_ULONG tab[8], top2b = a >> 30; 
 | 
			
		||||
	register BN_ULONG a1, a2, a4;
 | 
			
		||||
 | 
			
		||||
	a1 = a & (0x3FFFFFFF); a2 = a1 << 1; a4 = a2 << 1;
 | 
			
		||||
 | 
			
		||||
	tab[0] =  0; tab[1] = a1;    tab[2] = a2;    tab[3] = a1^a2;
 | 
			
		||||
	tab[4] = a4; tab[5] = a1^a4; tab[6] = a2^a4; tab[7] = a1^a2^a4;
 | 
			
		||||
 | 
			
		||||
	s = tab[b       & 0x7]; l  = s;
 | 
			
		||||
	s = tab[b >>  3 & 0x7]; l ^= s <<  3; h  = s >> 29;
 | 
			
		||||
	s = tab[b >>  6 & 0x7]; l ^= s <<  6; h ^= s >> 26;
 | 
			
		||||
	s = tab[b >>  9 & 0x7]; l ^= s <<  9; h ^= s >> 23;
 | 
			
		||||
	s = tab[b >> 12 & 0x7]; l ^= s << 12; h ^= s >> 20;
 | 
			
		||||
	s = tab[b >> 15 & 0x7]; l ^= s << 15; h ^= s >> 17;
 | 
			
		||||
	s = tab[b >> 18 & 0x7]; l ^= s << 18; h ^= s >> 14;
 | 
			
		||||
	s = tab[b >> 21 & 0x7]; l ^= s << 21; h ^= s >> 11;
 | 
			
		||||
	s = tab[b >> 24 & 0x7]; l ^= s << 24; h ^= s >>  8;
 | 
			
		||||
	s = tab[b >> 27 & 0x7]; l ^= s << 27; h ^= s >>  5;
 | 
			
		||||
	s = tab[b >> 30      ]; l ^= s << 30; h ^= s >>  2;
 | 
			
		||||
 | 
			
		||||
	/* compensate for the top two bits of a */
 | 
			
		||||
 | 
			
		||||
	if (top2b & 01) { l ^= b << 30; h ^= b >> 2; } 
 | 
			
		||||
	if (top2b & 02) { l ^= b << 31; h ^= b >> 1; } 
 | 
			
		||||
 | 
			
		||||
	*r1 = h; *r0 = l;
 | 
			
		||||
	} 
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)
 | 
			
		||||
static void bn_GF2m_mul_1x1(BN_ULONG *r1, BN_ULONG *r0, const BN_ULONG a, const BN_ULONG b)
 | 
			
		||||
	{
 | 
			
		||||
	register BN_ULONG h, l, s;
 | 
			
		||||
	BN_ULONG tab[16], top3b = a >> 61;
 | 
			
		||||
	register BN_ULONG a1, a2, a4, a8;
 | 
			
		||||
 | 
			
		||||
	a1 = a & (0x1FFFFFFFFFFFFFFF); a2 = a1 << 1; a4 = a2 << 1; a8 = a4 << 1;
 | 
			
		||||
 | 
			
		||||
	tab[ 0] = 0;     tab[ 1] = a1;       tab[ 2] = a2;       tab[ 3] = a1^a2;
 | 
			
		||||
	tab[ 4] = a4;    tab[ 5] = a1^a4;    tab[ 6] = a2^a4;    tab[ 7] = a1^a2^a4;
 | 
			
		||||
	tab[ 8] = a8;    tab[ 9] = a1^a8;    tab[10] = a2^a8;    tab[11] = a1^a2^a8;
 | 
			
		||||
	tab[12] = a4^a8; tab[13] = a1^a4^a8; tab[14] = a2^a4^a8; tab[15] = a1^a2^a4^a8;
 | 
			
		||||
 | 
			
		||||
	s = tab[b       & 0xF]; l  = s;
 | 
			
		||||
	s = tab[b >>  4 & 0xF]; l ^= s <<  4; h  = s >> 60;
 | 
			
		||||
	s = tab[b >>  8 & 0xF]; l ^= s <<  8; h ^= s >> 56;
 | 
			
		||||
	s = tab[b >> 12 & 0xF]; l ^= s << 12; h ^= s >> 52;
 | 
			
		||||
	s = tab[b >> 16 & 0xF]; l ^= s << 16; h ^= s >> 48;
 | 
			
		||||
	s = tab[b >> 20 & 0xF]; l ^= s << 20; h ^= s >> 44;
 | 
			
		||||
	s = tab[b >> 24 & 0xF]; l ^= s << 24; h ^= s >> 40;
 | 
			
		||||
	s = tab[b >> 28 & 0xF]; l ^= s << 28; h ^= s >> 36;
 | 
			
		||||
	s = tab[b >> 32 & 0xF]; l ^= s << 32; h ^= s >> 32;
 | 
			
		||||
	s = tab[b >> 36 & 0xF]; l ^= s << 36; h ^= s >> 28;
 | 
			
		||||
	s = tab[b >> 40 & 0xF]; l ^= s << 40; h ^= s >> 24;
 | 
			
		||||
	s = tab[b >> 44 & 0xF]; l ^= s << 44; h ^= s >> 20;
 | 
			
		||||
	s = tab[b >> 48 & 0xF]; l ^= s << 48; h ^= s >> 16;
 | 
			
		||||
	s = tab[b >> 52 & 0xF]; l ^= s << 52; h ^= s >> 12;
 | 
			
		||||
	s = tab[b >> 56 & 0xF]; l ^= s << 56; h ^= s >>  8;
 | 
			
		||||
	s = tab[b >> 60      ]; l ^= s << 60; h ^= s >>  4;
 | 
			
		||||
 | 
			
		||||
	/* compensate for the top three bits of a */
 | 
			
		||||
 | 
			
		||||
	if (top3b & 01) { l ^= b << 61; h ^= b >> 3; } 
 | 
			
		||||
	if (top3b & 02) { l ^= b << 62; h ^= b >> 2; } 
 | 
			
		||||
	if (top3b & 04) { l ^= b << 63; h ^= b >> 1; } 
 | 
			
		||||
 | 
			
		||||
	*r1 = h; *r0 = l;
 | 
			
		||||
	} 
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Product of two polynomials a, b each with degree < 2 * BN_BITS2 - 1,
 | 
			
		||||
 * result is a polynomial r with degree < 4 * BN_BITS2 - 1
 | 
			
		||||
 * The caller MUST ensure that the variables have the right amount
 | 
			
		||||
 * of space allocated.
 | 
			
		||||
 */
 | 
			
		||||
static void bn_GF2m_mul_2x2(BN_ULONG *r, const BN_ULONG a1, const BN_ULONG a0, const BN_ULONG b1, const BN_ULONG b0)
 | 
			
		||||
	{
 | 
			
		||||
	BN_ULONG m1, m0;
 | 
			
		||||
	/* r[3] = h1, r[2] = h0; r[1] = l1; r[0] = l0 */
 | 
			
		||||
	bn_GF2m_mul_1x1(r+3, r+2, a1, b1);
 | 
			
		||||
	bn_GF2m_mul_1x1(r+1, r, a0, b0);
 | 
			
		||||
	bn_GF2m_mul_1x1(&m1, &m0, a0 ^ a1, b0 ^ b1);
 | 
			
		||||
	/* Correction on m1 ^= l1 ^ h1; m0 ^= l0 ^ h0; */
 | 
			
		||||
	r[2] ^= m1 ^ r[1] ^ r[3];  /* h0 ^= m1 ^ l1 ^ h1; */
 | 
			
		||||
	r[1] = r[3] ^ r[2] ^ r[0] ^ m1 ^ m0;  /* l1 ^= l0 ^ h0 ^ m0; */
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Add polynomials a and b and store result in r; r could be a or b, a and b 
 | 
			
		||||
 * could be equal; r is the bitwise XOR of a and b.
 | 
			
		||||
 */
 | 
			
		||||
int	BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
 | 
			
		||||
	{
 | 
			
		||||
	int i;
 | 
			
		||||
	const BIGNUM *at, *bt;
 | 
			
		||||
 | 
			
		||||
	if (a->top < b->top) { at = b; bt = a; }
 | 
			
		||||
	else { at = a; bt = b; }
 | 
			
		||||
 | 
			
		||||
	bn_wexpand(r, at->top);
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < bt->top; i++)
 | 
			
		||||
		{
 | 
			
		||||
		r->d[i] = at->d[i] ^ bt->d[i];
 | 
			
		||||
		}
 | 
			
		||||
	for (; i < at->top; i++)
 | 
			
		||||
		{
 | 
			
		||||
		r->d[i] = at->d[i];
 | 
			
		||||
		}
 | 
			
		||||
	
 | 
			
		||||
	r->top = at->top;
 | 
			
		||||
	bn_fix_top(r);
 | 
			
		||||
	
 | 
			
		||||
	return 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Some functions allow for representation of the irreducible polynomials
 | 
			
		||||
 * as an int[], say p.  The irreducible f(t) is then of the form:
 | 
			
		||||
 *     t^p[0] + t^p[1] + ... + t^p[k]
 | 
			
		||||
 * where m = p[0] > p[1] > ... > p[k] = 0.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Performs modular reduction of a and store result in r.  r could be a. */
 | 
			
		||||
int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[])
 | 
			
		||||
	{
 | 
			
		||||
	int j, k;
 | 
			
		||||
	int n, dN, d0, d1;
 | 
			
		||||
	BN_ULONG zz, *z;
 | 
			
		||||
	
 | 
			
		||||
	/* Since the algorithm does reduction in the r value, if a != r, copy the
 | 
			
		||||
	 * contents of a into r so we can do reduction in r. 
 | 
			
		||||
	 */
 | 
			
		||||
	if (a != r)
 | 
			
		||||
		{
 | 
			
		||||
		if (!bn_wexpand(r, a->top)) return 0;
 | 
			
		||||
		for (j = 0; j < a->top; j++)
 | 
			
		||||
			{
 | 
			
		||||
			r->d[j] = a->d[j];
 | 
			
		||||
			}
 | 
			
		||||
		r->top = a->top;
 | 
			
		||||
		}
 | 
			
		||||
	z = r->d;
 | 
			
		||||
 | 
			
		||||
	/* start reduction */
 | 
			
		||||
	dN = p[0] / BN_BITS2;  
 | 
			
		||||
	for (j = r->top - 1; j > dN;)
 | 
			
		||||
		{
 | 
			
		||||
		zz = z[j];
 | 
			
		||||
		if (z[j] == 0) { j--; continue; }
 | 
			
		||||
		z[j] = 0;
 | 
			
		||||
 | 
			
		||||
		for (k = 1; p[k] > 0; k++)
 | 
			
		||||
			{
 | 
			
		||||
			/* reducing component t^p[k] */
 | 
			
		||||
			n = p[0] - p[k];
 | 
			
		||||
			d0 = n % BN_BITS2;  d1 = BN_BITS2 - d0;
 | 
			
		||||
			n /= BN_BITS2; 
 | 
			
		||||
			z[j-n] ^= (zz>>d0);
 | 
			
		||||
			if (d0) z[j-n-1] ^= (zz<<d1);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		/* reducing component t^0 */
 | 
			
		||||
		n = dN;  
 | 
			
		||||
		d0 = p[0] % BN_BITS2;
 | 
			
		||||
		d1 = BN_BITS2 - d0;
 | 
			
		||||
		z[j-n] ^= (zz >> d0);
 | 
			
		||||
		if (d0) z[j-n-1] ^= (zz << d1);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	/* final round of reduction */
 | 
			
		||||
	while (j == dN)
 | 
			
		||||
		{
 | 
			
		||||
 | 
			
		||||
		d0 = p[0] % BN_BITS2;
 | 
			
		||||
		zz = z[dN] >> d0;
 | 
			
		||||
		if (zz == 0) break;
 | 
			
		||||
		d1 = BN_BITS2 - d0;
 | 
			
		||||
		
 | 
			
		||||
		if (d0) z[dN] = (z[dN] << d1) >> d1; /* clear up the top d1 bits */
 | 
			
		||||
		z[0] ^= zz; /* reduction t^0 component */
 | 
			
		||||
 | 
			
		||||
		for (k = 1; p[k] > 0; k++)
 | 
			
		||||
			{
 | 
			
		||||
			BN_ULONG tmp_ulong;
 | 
			
		||||
 | 
			
		||||
			/* reducing component t^p[k]*/
 | 
			
		||||
			n = p[k] / BN_BITS2;   
 | 
			
		||||
			d0 = p[k] % BN_BITS2;
 | 
			
		||||
			d1 = BN_BITS2 - d0;
 | 
			
		||||
			z[n] ^= (zz << d0);
 | 
			
		||||
			tmp_ulong = zz >> d1;
 | 
			
		||||
                        if (d0 && tmp_ulong)
 | 
			
		||||
                                z[n+1] ^= tmp_ulong;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	bn_fix_top(r);
 | 
			
		||||
	
 | 
			
		||||
	return 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/* Performs modular reduction of a by p and store result in r.  r could be a.
 | 
			
		||||
 *
 | 
			
		||||
 * This function calls down to the BN_GF2m_mod_arr implementation; this wrapper
 | 
			
		||||
 * function is only provided for convenience; for best performance, use the 
 | 
			
		||||
 * BN_GF2m_mod_arr function.
 | 
			
		||||
 */
 | 
			
		||||
int	BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p)
 | 
			
		||||
	{
 | 
			
		||||
	const int max = BN_num_bits(p);
 | 
			
		||||
	unsigned int *arr=NULL, ret = 0;
 | 
			
		||||
	if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err;
 | 
			
		||||
	if (BN_GF2m_poly2arr(p, arr, max) > max)
 | 
			
		||||
		{
 | 
			
		||||
		BNerr(BN_F_BN_GF2M_MOD,BN_R_INVALID_LENGTH);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	ret = BN_GF2m_mod_arr(r, a, arr);
 | 
			
		||||
  err:
 | 
			
		||||
	if (arr) OPENSSL_free(arr);
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Compute the product of two polynomials a and b, reduce modulo p, and store
 | 
			
		||||
 * the result in r.  r could be a or b; a could be b.
 | 
			
		||||
 */
 | 
			
		||||
int	BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const unsigned int p[], BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	int zlen, i, j, k, ret = 0;
 | 
			
		||||
	BIGNUM *s;
 | 
			
		||||
	BN_ULONG x1, x0, y1, y0, zz[4];
 | 
			
		||||
	
 | 
			
		||||
	if (a == b)
 | 
			
		||||
		{
 | 
			
		||||
		return BN_GF2m_mod_sqr_arr(r, a, p, ctx);
 | 
			
		||||
		}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	BN_CTX_start(ctx);
 | 
			
		||||
	if ((s = BN_CTX_get(ctx)) == NULL) goto err;
 | 
			
		||||
	
 | 
			
		||||
	zlen = a->top + b->top + 4;
 | 
			
		||||
	if (!bn_wexpand(s, zlen)) goto err;
 | 
			
		||||
	s->top = zlen;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < zlen; i++) s->d[i] = 0;
 | 
			
		||||
 | 
			
		||||
	for (j = 0; j < b->top; j += 2)
 | 
			
		||||
		{
 | 
			
		||||
		y0 = b->d[j];
 | 
			
		||||
		y1 = ((j+1) == b->top) ? 0 : b->d[j+1];
 | 
			
		||||
		for (i = 0; i < a->top; i += 2)
 | 
			
		||||
			{
 | 
			
		||||
			x0 = a->d[i];
 | 
			
		||||
			x1 = ((i+1) == a->top) ? 0 : a->d[i+1];
 | 
			
		||||
			bn_GF2m_mul_2x2(zz, x1, x0, y1, y0);
 | 
			
		||||
			for (k = 0; k < 4; k++) s->d[i+j+k] ^= zz[k];
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	bn_fix_top(s);
 | 
			
		||||
	BN_GF2m_mod_arr(r, s, p);
 | 
			
		||||
	ret = 1;
 | 
			
		||||
 | 
			
		||||
  err:
 | 
			
		||||
	BN_CTX_end(ctx);
 | 
			
		||||
	return ret;
 | 
			
		||||
	
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/* Compute the product of two polynomials a and b, reduce modulo p, and store
 | 
			
		||||
 * the result in r.  r could be a or b; a could equal b.
 | 
			
		||||
 *
 | 
			
		||||
 * This function calls down to the BN_GF2m_mod_mul_arr implementation; this wrapper
 | 
			
		||||
 * function is only provided for convenience; for best performance, use the 
 | 
			
		||||
 * BN_GF2m_mod_mul_arr function.
 | 
			
		||||
 */
 | 
			
		||||
int	BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	const int max = BN_num_bits(p);
 | 
			
		||||
	unsigned int *arr=NULL, ret = 0;
 | 
			
		||||
	if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err;
 | 
			
		||||
	if (BN_GF2m_poly2arr(p, arr, max) > max)
 | 
			
		||||
		{
 | 
			
		||||
		BNerr(BN_F_BN_GF2M_MOD_MUL,BN_R_INVALID_LENGTH);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	ret = BN_GF2m_mod_mul_arr(r, a, b, arr, ctx);
 | 
			
		||||
  err:
 | 
			
		||||
	if (arr) OPENSSL_free(arr);
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Square a, reduce the result mod p, and store it in a.  r could be a. */
 | 
			
		||||
int	BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[], BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	int i, ret = 0;
 | 
			
		||||
	BIGNUM *s;
 | 
			
		||||
	
 | 
			
		||||
	BN_CTX_start(ctx);
 | 
			
		||||
	if ((s = BN_CTX_get(ctx)) == NULL) return 0;
 | 
			
		||||
	if (!bn_wexpand(s, 2 * a->top)) goto err;
 | 
			
		||||
 | 
			
		||||
	for (i = a->top - 1; i >= 0; i--)
 | 
			
		||||
		{
 | 
			
		||||
		s->d[2*i+1] = SQR1(a->d[i]);
 | 
			
		||||
		s->d[2*i  ] = SQR0(a->d[i]);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	s->top = 2 * a->top;
 | 
			
		||||
	bn_fix_top(s);
 | 
			
		||||
	if (!BN_GF2m_mod_arr(r, s, p)) goto err;
 | 
			
		||||
	ret = 1;
 | 
			
		||||
  err:
 | 
			
		||||
	BN_CTX_end(ctx);
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/* Square a, reduce the result mod p, and store it in a.  r could be a.
 | 
			
		||||
 *
 | 
			
		||||
 * This function calls down to the BN_GF2m_mod_sqr_arr implementation; this wrapper
 | 
			
		||||
 * function is only provided for convenience; for best performance, use the 
 | 
			
		||||
 * BN_GF2m_mod_sqr_arr function.
 | 
			
		||||
 */
 | 
			
		||||
int	BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	const int max = BN_num_bits(p);
 | 
			
		||||
	unsigned int *arr=NULL, ret = 0;
 | 
			
		||||
	if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err;
 | 
			
		||||
	if (BN_GF2m_poly2arr(p, arr, max) > max)
 | 
			
		||||
		{
 | 
			
		||||
		BNerr(BN_F_BN_GF2M_MOD_SQR,BN_R_INVALID_LENGTH);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	ret = BN_GF2m_mod_sqr_arr(r, a, arr, ctx);
 | 
			
		||||
  err:
 | 
			
		||||
	if (arr) OPENSSL_free(arr);
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Invert a, reduce modulo p, and store the result in r. r could be a. 
 | 
			
		||||
 * Uses Modified Almost Inverse Algorithm (Algorithm 10) from
 | 
			
		||||
 *     Hankerson, D., Hernandez, J.L., and Menezes, A.  "Software Implementation
 | 
			
		||||
 *     of Elliptic Curve Cryptography Over Binary Fields".
 | 
			
		||||
 */
 | 
			
		||||
int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	BIGNUM *b, *c, *u, *v, *tmp;
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
 | 
			
		||||
	BN_CTX_start(ctx);
 | 
			
		||||
	
 | 
			
		||||
	b = BN_CTX_get(ctx);
 | 
			
		||||
	c = BN_CTX_get(ctx);
 | 
			
		||||
	u = BN_CTX_get(ctx);
 | 
			
		||||
	v = BN_CTX_get(ctx);
 | 
			
		||||
	if (v == NULL) goto err;
 | 
			
		||||
 | 
			
		||||
	if (!BN_one(b)) goto err;
 | 
			
		||||
	if (!BN_zero(c)) goto err;
 | 
			
		||||
	if (!BN_GF2m_mod(u, a, p)) goto err;
 | 
			
		||||
	if (!BN_copy(v, p)) goto err;
 | 
			
		||||
 | 
			
		||||
	u->neg = 0; /* Need to set u->neg = 0 because BN_is_one(u) checks
 | 
			
		||||
	             * the neg flag of the bignum.
 | 
			
		||||
	             */
 | 
			
		||||
 | 
			
		||||
	if (BN_is_zero(u)) goto err;
 | 
			
		||||
 | 
			
		||||
	while (1)
 | 
			
		||||
		{
 | 
			
		||||
		while (!BN_is_odd(u))
 | 
			
		||||
			{
 | 
			
		||||
			if (!BN_rshift1(u, u)) goto err;
 | 
			
		||||
			if (BN_is_odd(b))
 | 
			
		||||
				{
 | 
			
		||||
				if (!BN_GF2m_add(b, b, p)) goto err;
 | 
			
		||||
				}
 | 
			
		||||
			if (!BN_rshift1(b, b)) goto err;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		if (BN_is_one(u)) break;
 | 
			
		||||
 | 
			
		||||
		if (BN_num_bits(u) < BN_num_bits(v))
 | 
			
		||||
			{
 | 
			
		||||
			tmp = u; u = v; v = tmp;
 | 
			
		||||
			tmp = b; b = c; c = tmp;
 | 
			
		||||
			}
 | 
			
		||||
		
 | 
			
		||||
		if (!BN_GF2m_add(u, u, v)) goto err;
 | 
			
		||||
		if (!BN_GF2m_add(b, b, c)) goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	if (!BN_copy(r, b)) goto err;
 | 
			
		||||
	ret = 1;
 | 
			
		||||
 | 
			
		||||
  err:
 | 
			
		||||
  	BN_CTX_end(ctx);
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/* Invert xx, reduce modulo p, and store the result in r. r could be xx. 
 | 
			
		||||
 *
 | 
			
		||||
 * This function calls down to the BN_GF2m_mod_inv implementation; this wrapper
 | 
			
		||||
 * function is only provided for convenience; for best performance, use the 
 | 
			
		||||
 * BN_GF2m_mod_inv function.
 | 
			
		||||
 */
 | 
			
		||||
int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *xx, const unsigned int p[], BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	BIGNUM *field;
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
 | 
			
		||||
	BN_CTX_start(ctx);
 | 
			
		||||
	if ((field = BN_CTX_get(ctx)) == NULL) goto err;
 | 
			
		||||
	if (!BN_GF2m_arr2poly(p, field)) goto err;
 | 
			
		||||
	
 | 
			
		||||
	ret = BN_GF2m_mod_inv(r, xx, field, ctx);
 | 
			
		||||
 | 
			
		||||
  err:
 | 
			
		||||
	BN_CTX_end(ctx);
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifndef OPENSSL_SUN_GF2M_DIV
 | 
			
		||||
/* Divide y by x, reduce modulo p, and store the result in r. r could be x 
 | 
			
		||||
 * or y, x could equal y.
 | 
			
		||||
 */
 | 
			
		||||
int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x, const BIGNUM *p, BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	BIGNUM *xinv = NULL;
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
	
 | 
			
		||||
	BN_CTX_start(ctx);
 | 
			
		||||
	xinv = BN_CTX_get(ctx);
 | 
			
		||||
	if (xinv == NULL) goto err;
 | 
			
		||||
	
 | 
			
		||||
	if (!BN_GF2m_mod_inv(xinv, x, p, ctx)) goto err;
 | 
			
		||||
	if (!BN_GF2m_mod_mul(r, y, xinv, p, ctx)) goto err;
 | 
			
		||||
	ret = 1;
 | 
			
		||||
 | 
			
		||||
  err:
 | 
			
		||||
	BN_CTX_end(ctx);
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
#else
 | 
			
		||||
/* Divide y by x, reduce modulo p, and store the result in r. r could be x 
 | 
			
		||||
 * or y, x could equal y.
 | 
			
		||||
 * Uses algorithm Modular_Division_GF(2^m) from 
 | 
			
		||||
 *     Chang-Shantz, S.  "From Euclid's GCD to Montgomery Multiplication to 
 | 
			
		||||
 *     the Great Divide".
 | 
			
		||||
 */
 | 
			
		||||
int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x, const BIGNUM *p, BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	BIGNUM *a, *b, *u, *v;
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
 | 
			
		||||
	BN_CTX_start(ctx);
 | 
			
		||||
	
 | 
			
		||||
	a = BN_CTX_get(ctx);
 | 
			
		||||
	b = BN_CTX_get(ctx);
 | 
			
		||||
	u = BN_CTX_get(ctx);
 | 
			
		||||
	v = BN_CTX_get(ctx);
 | 
			
		||||
	if (v == NULL) goto err;
 | 
			
		||||
 | 
			
		||||
	/* reduce x and y mod p */
 | 
			
		||||
	if (!BN_GF2m_mod(u, y, p)) goto err;
 | 
			
		||||
	if (!BN_GF2m_mod(a, x, p)) goto err;
 | 
			
		||||
	if (!BN_copy(b, p)) goto err;
 | 
			
		||||
	if (!BN_zero(v)) goto err;
 | 
			
		||||
	
 | 
			
		||||
	a->neg = 0; /* Need to set a->neg = 0 because BN_is_one(a) checks
 | 
			
		||||
	             * the neg flag of the bignum.
 | 
			
		||||
	             */
 | 
			
		||||
 | 
			
		||||
	while (!BN_is_odd(a))
 | 
			
		||||
		{
 | 
			
		||||
		if (!BN_rshift1(a, a)) goto err;
 | 
			
		||||
		if (BN_is_odd(u)) if (!BN_GF2m_add(u, u, p)) goto err;
 | 
			
		||||
		if (!BN_rshift1(u, u)) goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	do
 | 
			
		||||
		{
 | 
			
		||||
		if (BN_GF2m_cmp(b, a) > 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (!BN_GF2m_add(b, b, a)) goto err;
 | 
			
		||||
			if (!BN_GF2m_add(v, v, u)) goto err;
 | 
			
		||||
			do
 | 
			
		||||
				{
 | 
			
		||||
				if (!BN_rshift1(b, b)) goto err;
 | 
			
		||||
				if (BN_is_odd(v)) if (!BN_GF2m_add(v, v, p)) goto err;
 | 
			
		||||
				if (!BN_rshift1(v, v)) goto err;
 | 
			
		||||
				} while (!BN_is_odd(b));
 | 
			
		||||
			}
 | 
			
		||||
		else if (BN_is_one(a))
 | 
			
		||||
			break;
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			if (!BN_GF2m_add(a, a, b)) goto err;
 | 
			
		||||
			if (!BN_GF2m_add(u, u, v)) goto err;
 | 
			
		||||
			do
 | 
			
		||||
				{
 | 
			
		||||
				if (!BN_rshift1(a, a)) goto err;
 | 
			
		||||
				if (BN_is_odd(u)) if (!BN_GF2m_add(u, u, p)) goto err;
 | 
			
		||||
				if (!BN_rshift1(u, u)) goto err;
 | 
			
		||||
				} while (!BN_is_odd(a));
 | 
			
		||||
			}
 | 
			
		||||
		} while (1);
 | 
			
		||||
 | 
			
		||||
	if (!BN_copy(r, u)) goto err;
 | 
			
		||||
	ret = 1;
 | 
			
		||||
 | 
			
		||||
  err:
 | 
			
		||||
  	BN_CTX_end(ctx);
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Divide yy by xx, reduce modulo p, and store the result in r. r could be xx 
 | 
			
		||||
 * or yy, xx could equal yy.
 | 
			
		||||
 *
 | 
			
		||||
 * This function calls down to the BN_GF2m_mod_div implementation; this wrapper
 | 
			
		||||
 * function is only provided for convenience; for best performance, use the 
 | 
			
		||||
 * BN_GF2m_mod_div function.
 | 
			
		||||
 */
 | 
			
		||||
int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *yy, const BIGNUM *xx, const unsigned int p[], BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	BIGNUM *field;
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
 | 
			
		||||
	BN_CTX_start(ctx);
 | 
			
		||||
	if ((field = BN_CTX_get(ctx)) == NULL) goto err;
 | 
			
		||||
	if (!BN_GF2m_arr2poly(p, field)) goto err;
 | 
			
		||||
	
 | 
			
		||||
	ret = BN_GF2m_mod_div(r, yy, xx, field, ctx);
 | 
			
		||||
 | 
			
		||||
  err:
 | 
			
		||||
	BN_CTX_end(ctx);
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Compute the bth power of a, reduce modulo p, and store
 | 
			
		||||
 * the result in r.  r could be a.
 | 
			
		||||
 * Uses simple square-and-multiply algorithm A.5.1 from IEEE P1363.
 | 
			
		||||
 */
 | 
			
		||||
int	BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const unsigned int p[], BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	int ret = 0, i, n;
 | 
			
		||||
	BIGNUM *u;
 | 
			
		||||
	
 | 
			
		||||
	if (BN_is_zero(b))
 | 
			
		||||
		{
 | 
			
		||||
		return(BN_one(r));
 | 
			
		||||
		}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	BN_CTX_start(ctx);
 | 
			
		||||
	if ((u = BN_CTX_get(ctx)) == NULL) goto err;
 | 
			
		||||
	
 | 
			
		||||
	if (!BN_GF2m_mod_arr(u, a, p)) goto err;
 | 
			
		||||
	
 | 
			
		||||
	n = BN_num_bits(b) - 1;
 | 
			
		||||
	for (i = n - 1; i >= 0; i--)
 | 
			
		||||
		{
 | 
			
		||||
		if (!BN_GF2m_mod_sqr_arr(u, u, p, ctx)) goto err;
 | 
			
		||||
		if (BN_is_bit_set(b, i))
 | 
			
		||||
			{
 | 
			
		||||
			if (!BN_GF2m_mod_mul_arr(u, u, a, p, ctx)) goto err;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	if (!BN_copy(r, u)) goto err;
 | 
			
		||||
 | 
			
		||||
	ret = 1;
 | 
			
		||||
 | 
			
		||||
  err:
 | 
			
		||||
	BN_CTX_end(ctx);
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/* Compute the bth power of a, reduce modulo p, and store
 | 
			
		||||
 * the result in r.  r could be a.
 | 
			
		||||
 *
 | 
			
		||||
 * This function calls down to the BN_GF2m_mod_exp_arr implementation; this wrapper
 | 
			
		||||
 * function is only provided for convenience; for best performance, use the 
 | 
			
		||||
 * BN_GF2m_mod_exp_arr function.
 | 
			
		||||
 */
 | 
			
		||||
int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	const int max = BN_num_bits(p);
 | 
			
		||||
	unsigned int *arr=NULL, ret = 0;
 | 
			
		||||
	if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err;
 | 
			
		||||
	if (BN_GF2m_poly2arr(p, arr, max) > max)
 | 
			
		||||
		{
 | 
			
		||||
		BNerr(BN_F_BN_GF2M_MOD_EXP,BN_R_INVALID_LENGTH);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	ret = BN_GF2m_mod_exp_arr(r, a, b, arr, ctx);
 | 
			
		||||
  err:
 | 
			
		||||
	if (arr) OPENSSL_free(arr);
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/* Compute the square root of a, reduce modulo p, and store
 | 
			
		||||
 * the result in r.  r could be a.
 | 
			
		||||
 * Uses exponentiation as in algorithm A.4.1 from IEEE P1363.
 | 
			
		||||
 */
 | 
			
		||||
int	BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[], BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
	BIGNUM *u;
 | 
			
		||||
	
 | 
			
		||||
	BN_CTX_start(ctx);
 | 
			
		||||
	if ((u = BN_CTX_get(ctx)) == NULL) goto err;
 | 
			
		||||
	
 | 
			
		||||
	if (!BN_zero(u)) goto err;
 | 
			
		||||
	if (!BN_set_bit(u, p[0] - 1)) goto err;
 | 
			
		||||
	ret = BN_GF2m_mod_exp_arr(r, a, u, p, ctx);
 | 
			
		||||
 | 
			
		||||
  err:
 | 
			
		||||
	BN_CTX_end(ctx);
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/* Compute the square root of a, reduce modulo p, and store
 | 
			
		||||
 * the result in r.  r could be a.
 | 
			
		||||
 *
 | 
			
		||||
 * This function calls down to the BN_GF2m_mod_sqrt_arr implementation; this wrapper
 | 
			
		||||
 * function is only provided for convenience; for best performance, use the 
 | 
			
		||||
 * BN_GF2m_mod_sqrt_arr function.
 | 
			
		||||
 */
 | 
			
		||||
int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	const int max = BN_num_bits(p);
 | 
			
		||||
	unsigned int *arr=NULL, ret = 0;
 | 
			
		||||
	if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err;
 | 
			
		||||
	if (BN_GF2m_poly2arr(p, arr, max) > max)
 | 
			
		||||
		{
 | 
			
		||||
		BNerr(BN_F_BN_GF2M_MOD_EXP,BN_R_INVALID_LENGTH);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	ret = BN_GF2m_mod_sqrt_arr(r, a, arr, ctx);
 | 
			
		||||
  err:
 | 
			
		||||
	if (arr) OPENSSL_free(arr);
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/* Find r such that r^2 + r = a mod p.  r could be a. If no r exists returns 0.
 | 
			
		||||
 * Uses algorithms A.4.7 and A.4.6 from IEEE P1363.
 | 
			
		||||
 */
 | 
			
		||||
int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a_, const unsigned int p[], BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	int ret = 0, count = 0;
 | 
			
		||||
	unsigned int j;
 | 
			
		||||
	BIGNUM *a, *z, *rho, *w, *w2, *tmp;
 | 
			
		||||
	
 | 
			
		||||
	BN_CTX_start(ctx);
 | 
			
		||||
	a = BN_CTX_get(ctx);
 | 
			
		||||
	z = BN_CTX_get(ctx);
 | 
			
		||||
	w = BN_CTX_get(ctx);
 | 
			
		||||
	if (w == NULL) goto err;
 | 
			
		||||
 | 
			
		||||
	if (!BN_GF2m_mod_arr(a, a_, p)) goto err;
 | 
			
		||||
	
 | 
			
		||||
	if (BN_is_zero(a))
 | 
			
		||||
		{
 | 
			
		||||
		ret = BN_zero(r);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (p[0] & 0x1) /* m is odd */
 | 
			
		||||
		{
 | 
			
		||||
		/* compute half-trace of a */
 | 
			
		||||
		if (!BN_copy(z, a)) goto err;
 | 
			
		||||
		for (j = 1; j <= (p[0] - 1) / 2; j++)
 | 
			
		||||
			{
 | 
			
		||||
			if (!BN_GF2m_mod_sqr_arr(z, z, p, ctx)) goto err;
 | 
			
		||||
			if (!BN_GF2m_mod_sqr_arr(z, z, p, ctx)) goto err;
 | 
			
		||||
			if (!BN_GF2m_add(z, z, a)) goto err;
 | 
			
		||||
			}
 | 
			
		||||
		
 | 
			
		||||
		}
 | 
			
		||||
	else /* m is even */
 | 
			
		||||
		{
 | 
			
		||||
		rho = BN_CTX_get(ctx);
 | 
			
		||||
		w2 = BN_CTX_get(ctx);
 | 
			
		||||
		tmp = BN_CTX_get(ctx);
 | 
			
		||||
		if (tmp == NULL) goto err;
 | 
			
		||||
		do
 | 
			
		||||
			{
 | 
			
		||||
			if (!BN_rand(rho, p[0], 0, 0)) goto err;
 | 
			
		||||
			if (!BN_GF2m_mod_arr(rho, rho, p)) goto err;
 | 
			
		||||
			if (!BN_zero(z)) goto err;
 | 
			
		||||
			if (!BN_copy(w, rho)) goto err;
 | 
			
		||||
			for (j = 1; j <= p[0] - 1; j++)
 | 
			
		||||
				{
 | 
			
		||||
				if (!BN_GF2m_mod_sqr_arr(z, z, p, ctx)) goto err;
 | 
			
		||||
				if (!BN_GF2m_mod_sqr_arr(w2, w, p, ctx)) goto err;
 | 
			
		||||
				if (!BN_GF2m_mod_mul_arr(tmp, w2, a, p, ctx)) goto err;
 | 
			
		||||
				if (!BN_GF2m_add(z, z, tmp)) goto err;
 | 
			
		||||
				if (!BN_GF2m_add(w, w2, rho)) goto err;
 | 
			
		||||
				}
 | 
			
		||||
			count++;
 | 
			
		||||
			} while (BN_is_zero(w) && (count < MAX_ITERATIONS));
 | 
			
		||||
		if (BN_is_zero(w))
 | 
			
		||||
			{
 | 
			
		||||
			BNerr(BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR,BN_R_TOO_MANY_ITERATIONS);
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	
 | 
			
		||||
	if (!BN_GF2m_mod_sqr_arr(w, z, p, ctx)) goto err;
 | 
			
		||||
	if (!BN_GF2m_add(w, z, w)) goto err;
 | 
			
		||||
	if (BN_GF2m_cmp(w, a)) goto err;
 | 
			
		||||
 | 
			
		||||
	if (!BN_copy(r, z)) goto err;
 | 
			
		||||
 | 
			
		||||
	ret = 1;
 | 
			
		||||
 | 
			
		||||
  err:
 | 
			
		||||
	BN_CTX_end(ctx);
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/* Find r such that r^2 + r = a mod p.  r could be a. If no r exists returns 0.
 | 
			
		||||
 *
 | 
			
		||||
 * This function calls down to the BN_GF2m_mod_solve_quad_arr implementation; this wrapper
 | 
			
		||||
 * function is only provided for convenience; for best performance, use the 
 | 
			
		||||
 * BN_GF2m_mod_solve_quad_arr function.
 | 
			
		||||
 */
 | 
			
		||||
int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	const int max = BN_num_bits(p);
 | 
			
		||||
	unsigned int *arr=NULL, ret = 0;
 | 
			
		||||
	if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err;
 | 
			
		||||
	if (BN_GF2m_poly2arr(p, arr, max) > max)
 | 
			
		||||
		{
 | 
			
		||||
		BNerr(BN_F_BN_GF2M_MOD_SOLVE_QUAD,BN_R_INVALID_LENGTH);
 | 
			
		||||
		goto err;
 | 
			
		||||
		}
 | 
			
		||||
	ret = BN_GF2m_mod_solve_quad_arr(r, a, arr, ctx);
 | 
			
		||||
  err:
 | 
			
		||||
	if (arr) OPENSSL_free(arr);
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/* Convert the bit-string representation of a polynomial a into an array
 | 
			
		||||
 * of integers corresponding to the bits with non-zero coefficient.
 | 
			
		||||
 * Up to max elements of the array will be filled.  Return value is total
 | 
			
		||||
 * number of coefficients that would be extracted if array was large enough.
 | 
			
		||||
 */
 | 
			
		||||
int BN_GF2m_poly2arr(const BIGNUM *a, unsigned int p[], int max)
 | 
			
		||||
	{
 | 
			
		||||
	int i, j, k;
 | 
			
		||||
	BN_ULONG mask;
 | 
			
		||||
 | 
			
		||||
	for (k = 0; k < max; k++) p[k] = 0;
 | 
			
		||||
	k = 0;
 | 
			
		||||
 | 
			
		||||
	for (i = a->top - 1; i >= 0; i--)
 | 
			
		||||
		{
 | 
			
		||||
		mask = BN_TBIT;
 | 
			
		||||
		for (j = BN_BITS2 - 1; j >= 0; j--)
 | 
			
		||||
			{
 | 
			
		||||
			if (a->d[i] & mask) 
 | 
			
		||||
				{
 | 
			
		||||
				if (k < max) p[k] = BN_BITS2 * i + j;
 | 
			
		||||
				k++;
 | 
			
		||||
				}
 | 
			
		||||
			mask >>= 1;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	return k;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/* Convert the coefficient array representation of a polynomial to a 
 | 
			
		||||
 * bit-string.  The array must be terminated by 0.
 | 
			
		||||
 */
 | 
			
		||||
int BN_GF2m_arr2poly(const unsigned int p[], BIGNUM *a)
 | 
			
		||||
	{
 | 
			
		||||
	int i;
 | 
			
		||||
 | 
			
		||||
	BN_zero(a);
 | 
			
		||||
	for (i = 0; p[i] > 0; i++)
 | 
			
		||||
		{
 | 
			
		||||
		BN_set_bit(a, p[i]);
 | 
			
		||||
		}
 | 
			
		||||
	BN_set_bit(a, 0);
 | 
			
		||||
	
 | 
			
		||||
	return 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -254,16 +254,6 @@ struct bignum_ctx
 | 
			
		||||
#define Lw(t)    (((BN_ULONG)(t))&BN_MASK2)
 | 
			
		||||
#define Hw(t)    (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define bn_clear_top2max(a) \
 | 
			
		||||
	{ \
 | 
			
		||||
	int      ind = (a)->dmax - (a)->top; \
 | 
			
		||||
	BN_ULONG *ftl = &(a)->d[(a)->top-1]; \
 | 
			
		||||
	for (; ind != 0; ind--) \
 | 
			
		||||
		*(++ftl) = 0x0; \
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* This is used for internal error checking and is not normally used */
 | 
			
		||||
#ifdef BN_DEBUG
 | 
			
		||||
# include <assert.h>
 | 
			
		||||
@@ -443,20 +433,19 @@ void bn_sqr_comba4(BN_ULONG *r,const BN_ULONG *a);
 | 
			
		||||
int bn_cmp_words(const BN_ULONG *a,const BN_ULONG *b,int n);
 | 
			
		||||
int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b,
 | 
			
		||||
	int cl, int dl);
 | 
			
		||||
#if 0
 | 
			
		||||
/* bn_mul.c rollback <appro> */
 | 
			
		||||
void bn_mul_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
 | 
			
		||||
	int dna,int dnb,BN_ULONG *t);
 | 
			
		||||
void bn_mul_part_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,
 | 
			
		||||
	int n,int tna,int tnb,BN_ULONG *t);
 | 
			
		||||
#endif
 | 
			
		||||
void bn_sqr_recursive(BN_ULONG *r,const BN_ULONG *a, int n2, BN_ULONG *t);
 | 
			
		||||
void bn_mul_low_normal(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, int n);
 | 
			
		||||
void bn_mul_low_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
 | 
			
		||||
	BN_ULONG *t);
 | 
			
		||||
void bn_mul_high(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,BN_ULONG *l,int n2,
 | 
			
		||||
	BN_ULONG *t);
 | 
			
		||||
BN_ULONG bn_add_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
 | 
			
		||||
	int cl, int dl);
 | 
			
		||||
BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
 | 
			
		||||
	int cl, int dl);
 | 
			
		||||
 | 
			
		||||
#ifdef  __cplusplus
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -363,6 +363,17 @@ static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	/* Now need to zero any data between b->top and b->max */
 | 
			
		||||
	/* XXX Why? */
 | 
			
		||||
 | 
			
		||||
	A= &(a[b->top]);
 | 
			
		||||
	for (i=(words - b->top)>>3; i>0; i--,A+=8)
 | 
			
		||||
		{
 | 
			
		||||
		A[0]=0; A[1]=0; A[2]=0; A[3]=0;
 | 
			
		||||
		A[4]=0; A[5]=0; A[6]=0; A[7]=0;
 | 
			
		||||
		}
 | 
			
		||||
	for (i=(words - b->top)&7; i>0; i--,A++)
 | 
			
		||||
		A[0]=0;
 | 
			
		||||
#else
 | 
			
		||||
	memset(A,0,sizeof(BN_ULONG)*(words+1));
 | 
			
		||||
	memcpy(A,b->d,sizeof(b->d[0])*b->top);
 | 
			
		||||
@@ -424,16 +435,12 @@ BIGNUM *bn_dup_expand(const BIGNUM *b, int words)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/* This is an internal function that should not be used in applications.
 | 
			
		||||
 * It ensures that 'b' has enough room for a 'words' word number
 | 
			
		||||
 * and initialises any unused part of b->d with leading zeros.
 | 
			
		||||
 * It ensures that 'b' has enough room for a 'words' word number number.
 | 
			
		||||
 * It is mostly used by the various BIGNUM routines. If there is an error,
 | 
			
		||||
 * NULL is returned. If not, 'b' is returned. */
 | 
			
		||||
 | 
			
		||||
BIGNUM *bn_expand2(BIGNUM *b, int words)
 | 
			
		||||
	{
 | 
			
		||||
	BN_ULONG *A;
 | 
			
		||||
	int i;
 | 
			
		||||
 | 
			
		||||
	if (words > b->dmax)
 | 
			
		||||
		{
 | 
			
		||||
		BN_ULONG *a = bn_expand_internal(b, words);
 | 
			
		||||
@@ -448,21 +455,6 @@ BIGNUM *bn_expand2(BIGNUM *b, int words)
 | 
			
		||||
		else
 | 
			
		||||
			b = NULL;
 | 
			
		||||
		}
 | 
			
		||||
	
 | 
			
		||||
	/* NB: bn_wexpand() calls this only if the BIGNUM really has to grow */
 | 
			
		||||
	if ((b != NULL) && (b->top < b->dmax))
 | 
			
		||||
		{
 | 
			
		||||
		A = &(b->d[b->top]);
 | 
			
		||||
		for (i=(b->dmax - b->top)>>3; i>0; i--,A+=8)
 | 
			
		||||
			{
 | 
			
		||||
			A[0]=0; A[1]=0; A[2]=0; A[3]=0;
 | 
			
		||||
			A[4]=0; A[5]=0; A[6]=0; A[7]=0;
 | 
			
		||||
			}
 | 
			
		||||
		for (i=(b->dmax - b->top)&7; i>0; i--,A++)
 | 
			
		||||
			A[0]=0;
 | 
			
		||||
		assert(A == &(b->d[b->dmax]));
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
	return b;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -522,51 +514,6 @@ BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
 | 
			
		||||
	return(a);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
BIGNUM *BN_ncopy(BIGNUM *a, const BIGNUM *b, size_t n)
 | 
			
		||||
	{
 | 
			
		||||
	int i, min;
 | 
			
		||||
	BN_ULONG *A;
 | 
			
		||||
	const BN_ULONG *B;
 | 
			
		||||
 | 
			
		||||
	bn_check_top(b);
 | 
			
		||||
 | 
			
		||||
	if (a == b)
 | 
			
		||||
		return a;
 | 
			
		||||
 | 
			
		||||
	min = (b->top < (int)n)? b->top: (int)n;
 | 
			
		||||
 | 
			
		||||
	if (!min)
 | 
			
		||||
		{
 | 
			
		||||
		BN_zero(a);
 | 
			
		||||
		return a;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (bn_wexpand(a, min) == NULL)
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	A=a->d;
 | 
			
		||||
	B=b->d;
 | 
			
		||||
	for (i=min>>2; i>0; i--, A+=4, B+=4)
 | 
			
		||||
		{
 | 
			
		||||
		BN_ULONG a0,a1,a2,a3;
 | 
			
		||||
		a0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];
 | 
			
		||||
		A[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;
 | 
			
		||||
		}
 | 
			
		||||
	switch (min&3)
 | 
			
		||||
		{
 | 
			
		||||
		case 3: A[2]=B[2];
 | 
			
		||||
		case 2: A[1]=B[1];
 | 
			
		||||
		case 1: A[0]=B[0];
 | 
			
		||||
		case 0: ;
 | 
			
		||||
		}
 | 
			
		||||
	a->top = min;
 | 
			
		||||
 | 
			
		||||
	a->neg = b->neg;
 | 
			
		||||
	bn_fix_top(a);
 | 
			
		||||
 | 
			
		||||
	return(a);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
void BN_swap(BIGNUM *a, BIGNUM *b)
 | 
			
		||||
	{
 | 
			
		||||
	int flags_old_a, flags_old_b;
 | 
			
		||||
 
 | 
			
		||||
@@ -56,325 +56,10 @@
 | 
			
		||||
 * [including the GNU Public Licence.]
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef BN_DEBUG
 | 
			
		||||
# undef NDEBUG /* avoid conflicting definitions */
 | 
			
		||||
# define NDEBUG
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
#include "cryptlib.h"
 | 
			
		||||
#include "bn_lcl.h"
 | 
			
		||||
 | 
			
		||||
#if defined(OPENSSL_NO_ASM) || !defined(OPENSSL_BN_ASM_PART_WORDS)
 | 
			
		||||
/* Here follows specialised variants of bn_add_words() and
 | 
			
		||||
   bn_sub_words().  They have the property performing operations on
 | 
			
		||||
   arrays of different sizes.  The sizes of those arrays is expressed through
 | 
			
		||||
   cl, which is the common length ( basicall, min(len(a),len(b)) ), and dl,
 | 
			
		||||
   which is the delta between the two lengths, calculated as len(a)-len(b).
 | 
			
		||||
   All lengths are the number of BN_ULONGs...  For the operations that require
 | 
			
		||||
   a result array as parameter, it must have the length cl+abs(dl).
 | 
			
		||||
   These functions should probably end up in bn_asm.c as soon as there are
 | 
			
		||||
   assembler counterparts for the systems that use assembler files.  */
 | 
			
		||||
 | 
			
		||||
BN_ULONG bn_sub_part_words(BN_ULONG *r,
 | 
			
		||||
	const BN_ULONG *a, const BN_ULONG *b,
 | 
			
		||||
	int cl, int dl)
 | 
			
		||||
	{
 | 
			
		||||
	BN_ULONG c, t;
 | 
			
		||||
 | 
			
		||||
	assert(cl >= 0);
 | 
			
		||||
	c = bn_sub_words(r, a, b, cl);
 | 
			
		||||
 | 
			
		||||
	if (dl == 0)
 | 
			
		||||
		return c;
 | 
			
		||||
 | 
			
		||||
	r += cl;
 | 
			
		||||
	a += cl;
 | 
			
		||||
	b += cl;
 | 
			
		||||
 | 
			
		||||
	if (dl < 0)
 | 
			
		||||
		{
 | 
			
		||||
#ifdef BN_COUNT
 | 
			
		||||
		fprintf(stderr, "  bn_sub_part_words %d + %d (dl < 0, c = %d)\n", cl, dl, c);
 | 
			
		||||
#endif
 | 
			
		||||
		for (;;)
 | 
			
		||||
			{
 | 
			
		||||
			t = b[0];
 | 
			
		||||
			r[0] = (0-t-c)&BN_MASK2;
 | 
			
		||||
			if (t != 0) c=1;
 | 
			
		||||
			if (++dl >= 0) break;
 | 
			
		||||
 | 
			
		||||
			t = b[1];
 | 
			
		||||
			r[1] = (0-t-c)&BN_MASK2;
 | 
			
		||||
			if (t != 0) c=1;
 | 
			
		||||
			if (++dl >= 0) break;
 | 
			
		||||
 | 
			
		||||
			t = b[2];
 | 
			
		||||
			r[2] = (0-t-c)&BN_MASK2;
 | 
			
		||||
			if (t != 0) c=1;
 | 
			
		||||
			if (++dl >= 0) break;
 | 
			
		||||
 | 
			
		||||
			t = b[3];
 | 
			
		||||
			r[3] = (0-t-c)&BN_MASK2;
 | 
			
		||||
			if (t != 0) c=1;
 | 
			
		||||
			if (++dl >= 0) break;
 | 
			
		||||
 | 
			
		||||
			b += 4;
 | 
			
		||||
			r += 4;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
		int save_dl = dl;
 | 
			
		||||
#ifdef BN_COUNT
 | 
			
		||||
		fprintf(stderr, "  bn_sub_part_words %d + %d (dl > 0, c = %d)\n", cl, dl, c);
 | 
			
		||||
#endif
 | 
			
		||||
		while(c)
 | 
			
		||||
			{
 | 
			
		||||
			t = a[0];
 | 
			
		||||
			r[0] = (t-c)&BN_MASK2;
 | 
			
		||||
			if (t != 0) c=0;
 | 
			
		||||
			if (--dl <= 0) break;
 | 
			
		||||
 | 
			
		||||
			t = a[1];
 | 
			
		||||
			r[1] = (t-c)&BN_MASK2;
 | 
			
		||||
			if (t != 0) c=0;
 | 
			
		||||
			if (--dl <= 0) break;
 | 
			
		||||
 | 
			
		||||
			t = a[2];
 | 
			
		||||
			r[2] = (t-c)&BN_MASK2;
 | 
			
		||||
			if (t != 0) c=0;
 | 
			
		||||
			if (--dl <= 0) break;
 | 
			
		||||
 | 
			
		||||
			t = a[3];
 | 
			
		||||
			r[3] = (t-c)&BN_MASK2;
 | 
			
		||||
			if (t != 0) c=0;
 | 
			
		||||
			if (--dl <= 0) break;
 | 
			
		||||
 | 
			
		||||
			save_dl = dl;
 | 
			
		||||
			a += 4;
 | 
			
		||||
			r += 4;
 | 
			
		||||
			}
 | 
			
		||||
		if (dl > 0)
 | 
			
		||||
			{
 | 
			
		||||
#ifdef BN_COUNT
 | 
			
		||||
			fprintf(stderr, "  bn_sub_part_words %d + %d (dl > 0, c == 0)\n", cl, dl);
 | 
			
		||||
#endif
 | 
			
		||||
			if (save_dl > dl)
 | 
			
		||||
				{
 | 
			
		||||
				switch (save_dl - dl)
 | 
			
		||||
					{
 | 
			
		||||
				case 1:
 | 
			
		||||
					r[1] = a[1];
 | 
			
		||||
					if (--dl <= 0) break;
 | 
			
		||||
				case 2:
 | 
			
		||||
					r[2] = a[2];
 | 
			
		||||
					if (--dl <= 0) break;
 | 
			
		||||
				case 3:
 | 
			
		||||
					r[3] = a[3];
 | 
			
		||||
					if (--dl <= 0) break;
 | 
			
		||||
					}
 | 
			
		||||
				a += 4;
 | 
			
		||||
				r += 4;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		if (dl > 0)
 | 
			
		||||
			{
 | 
			
		||||
#ifdef BN_COUNT
 | 
			
		||||
			fprintf(stderr, "  bn_sub_part_words %d + %d (dl > 0, copy)\n", cl, dl);
 | 
			
		||||
#endif
 | 
			
		||||
			for(;;)
 | 
			
		||||
				{
 | 
			
		||||
				r[0] = a[0];
 | 
			
		||||
				if (--dl <= 0) break;
 | 
			
		||||
				r[1] = a[1];
 | 
			
		||||
				if (--dl <= 0) break;
 | 
			
		||||
				r[2] = a[2];
 | 
			
		||||
				if (--dl <= 0) break;
 | 
			
		||||
				r[3] = a[3];
 | 
			
		||||
				if (--dl <= 0) break;
 | 
			
		||||
 | 
			
		||||
				a += 4;
 | 
			
		||||
				r += 4;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	return c;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
BN_ULONG bn_add_part_words(BN_ULONG *r,
 | 
			
		||||
	const BN_ULONG *a, const BN_ULONG *b,
 | 
			
		||||
	int cl, int dl)
 | 
			
		||||
	{
 | 
			
		||||
	BN_ULONG c, l, t;
 | 
			
		||||
 | 
			
		||||
	assert(cl >= 0);
 | 
			
		||||
	c = bn_add_words(r, a, b, cl);
 | 
			
		||||
 | 
			
		||||
	if (dl == 0)
 | 
			
		||||
		return c;
 | 
			
		||||
 | 
			
		||||
	r += cl;
 | 
			
		||||
	a += cl;
 | 
			
		||||
	b += cl;
 | 
			
		||||
 | 
			
		||||
	if (dl < 0)
 | 
			
		||||
		{
 | 
			
		||||
		int save_dl = dl;
 | 
			
		||||
#ifdef BN_COUNT
 | 
			
		||||
		fprintf(stderr, "  bn_add_part_words %d + %d (dl < 0, c = %d)\n", cl, dl, c);
 | 
			
		||||
#endif
 | 
			
		||||
		while (c)
 | 
			
		||||
			{
 | 
			
		||||
			l=(c+b[0])&BN_MASK2;
 | 
			
		||||
			c=(l < c);
 | 
			
		||||
			r[0]=l;
 | 
			
		||||
			if (++dl >= 0) break;
 | 
			
		||||
 | 
			
		||||
			l=(c+b[1])&BN_MASK2;
 | 
			
		||||
			c=(l < c);
 | 
			
		||||
			r[1]=l;
 | 
			
		||||
			if (++dl >= 0) break;
 | 
			
		||||
 | 
			
		||||
			l=(c+b[2])&BN_MASK2;
 | 
			
		||||
			c=(l < c);
 | 
			
		||||
			r[2]=l;
 | 
			
		||||
			if (++dl >= 0) break;
 | 
			
		||||
 | 
			
		||||
			l=(c+b[3])&BN_MASK2;
 | 
			
		||||
			c=(l < c);
 | 
			
		||||
			r[3]=l;
 | 
			
		||||
			if (++dl >= 0) break;
 | 
			
		||||
 | 
			
		||||
			save_dl = dl;
 | 
			
		||||
			b+=4;
 | 
			
		||||
			r+=4;
 | 
			
		||||
			}
 | 
			
		||||
		if (dl < 0)
 | 
			
		||||
			{
 | 
			
		||||
#ifdef BN_COUNT
 | 
			
		||||
			fprintf(stderr, "  bn_add_part_words %d + %d (dl < 0, c == 0)\n", cl, dl);
 | 
			
		||||
#endif
 | 
			
		||||
			if (save_dl < dl)
 | 
			
		||||
				{
 | 
			
		||||
				switch (dl - save_dl)
 | 
			
		||||
					{
 | 
			
		||||
				case 1:
 | 
			
		||||
					r[1] = b[1];
 | 
			
		||||
					if (++dl >= 0) break;
 | 
			
		||||
				case 2:
 | 
			
		||||
					r[2] = b[2];
 | 
			
		||||
					if (++dl >= 0) break;
 | 
			
		||||
				case 3:
 | 
			
		||||
					r[3] = b[3];
 | 
			
		||||
					if (++dl >= 0) break;
 | 
			
		||||
					}
 | 
			
		||||
				b += 4;
 | 
			
		||||
				r += 4;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		if (dl < 0)
 | 
			
		||||
			{
 | 
			
		||||
#ifdef BN_COUNT
 | 
			
		||||
			fprintf(stderr, "  bn_add_part_words %d + %d (dl < 0, copy)\n", cl, dl);
 | 
			
		||||
#endif
 | 
			
		||||
			for(;;)
 | 
			
		||||
				{
 | 
			
		||||
				r[0] = b[0];
 | 
			
		||||
				if (++dl >= 0) break;
 | 
			
		||||
				r[1] = b[1];
 | 
			
		||||
				if (++dl >= 0) break;
 | 
			
		||||
				r[2] = b[2];
 | 
			
		||||
				if (++dl >= 0) break;
 | 
			
		||||
				r[3] = b[3];
 | 
			
		||||
				if (++dl >= 0) break;
 | 
			
		||||
 | 
			
		||||
				b += 4;
 | 
			
		||||
				r += 4;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
		int save_dl = dl;
 | 
			
		||||
#ifdef BN_COUNT
 | 
			
		||||
		fprintf(stderr, "  bn_add_part_words %d + %d (dl > 0)\n", cl, dl);
 | 
			
		||||
#endif
 | 
			
		||||
		while (c)
 | 
			
		||||
			{
 | 
			
		||||
			t=(a[0]+c)&BN_MASK2;
 | 
			
		||||
			c=(t < c);
 | 
			
		||||
			r[0]=t;
 | 
			
		||||
			if (--dl <= 0) break;
 | 
			
		||||
 | 
			
		||||
			t=(a[1]+c)&BN_MASK2;
 | 
			
		||||
			c=(t < c);
 | 
			
		||||
			r[1]=t;
 | 
			
		||||
			if (--dl <= 0) break;
 | 
			
		||||
 | 
			
		||||
			t=(a[2]+c)&BN_MASK2;
 | 
			
		||||
			c=(t < c);
 | 
			
		||||
			r[2]=t;
 | 
			
		||||
			if (--dl <= 0) break;
 | 
			
		||||
 | 
			
		||||
			t=(a[3]+c)&BN_MASK2;
 | 
			
		||||
			c=(t < c);
 | 
			
		||||
			r[3]=t;
 | 
			
		||||
			if (--dl <= 0) break;
 | 
			
		||||
 | 
			
		||||
			save_dl = dl;
 | 
			
		||||
			a+=4;
 | 
			
		||||
			r+=4;
 | 
			
		||||
			}
 | 
			
		||||
#ifdef BN_COUNT
 | 
			
		||||
		fprintf(stderr, "  bn_add_part_words %d + %d (dl > 0, c == 0)\n", cl, dl);
 | 
			
		||||
#endif
 | 
			
		||||
		if (dl > 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (save_dl > dl)
 | 
			
		||||
				{
 | 
			
		||||
				switch (save_dl - dl)
 | 
			
		||||
					{
 | 
			
		||||
				case 1:
 | 
			
		||||
					r[1] = a[1];
 | 
			
		||||
					if (--dl <= 0) break;
 | 
			
		||||
				case 2:
 | 
			
		||||
					r[2] = a[2];
 | 
			
		||||
					if (--dl <= 0) break;
 | 
			
		||||
				case 3:
 | 
			
		||||
					r[3] = a[3];
 | 
			
		||||
					if (--dl <= 0) break;
 | 
			
		||||
					}
 | 
			
		||||
				a += 4;
 | 
			
		||||
				r += 4;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		if (dl > 0)
 | 
			
		||||
			{
 | 
			
		||||
#ifdef BN_COUNT
 | 
			
		||||
			fprintf(stderr, "  bn_add_part_words %d + %d (dl > 0, copy)\n", cl, dl);
 | 
			
		||||
#endif
 | 
			
		||||
			for(;;)
 | 
			
		||||
				{
 | 
			
		||||
				r[0] = a[0];
 | 
			
		||||
				if (--dl <= 0) break;
 | 
			
		||||
				r[1] = a[1];
 | 
			
		||||
				if (--dl <= 0) break;
 | 
			
		||||
				r[2] = a[2];
 | 
			
		||||
				if (--dl <= 0) break;
 | 
			
		||||
				r[3] = a[3];
 | 
			
		||||
				if (--dl <= 0) break;
 | 
			
		||||
 | 
			
		||||
				a += 4;
 | 
			
		||||
				r += 4;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	return c;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
#ifdef BN_RECURSION
 | 
			
		||||
/* Karatsuba recursive multiplication algorithm
 | 
			
		||||
 * (cf. Knuth, The Art of Computer Programming, Vol. 2) */
 | 
			
		||||
@@ -390,15 +75,14 @@ BN_ULONG bn_add_part_words(BN_ULONG *r,
 | 
			
		||||
 * a[1]*b[1]
 | 
			
		||||
 */
 | 
			
		||||
void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
 | 
			
		||||
	int dna, int dnb, BN_ULONG *t)
 | 
			
		||||
	     BN_ULONG *t)
 | 
			
		||||
	{
 | 
			
		||||
	int n=n2/2,c1,c2;
 | 
			
		||||
	int tna=n+dna, tnb=n+dnb;
 | 
			
		||||
	unsigned int neg,zero;
 | 
			
		||||
	BN_ULONG ln,lo,*p;
 | 
			
		||||
 | 
			
		||||
# ifdef BN_COUNT
 | 
			
		||||
	fprintf(stderr," bn_mul_recursive %d * %d\n",n2,n2);
 | 
			
		||||
	printf(" bn_mul_recursive %d * %d\n",n2,n2);
 | 
			
		||||
# endif
 | 
			
		||||
# ifdef BN_MUL_COMBA
 | 
			
		||||
#  if 0
 | 
			
		||||
@@ -408,40 +92,34 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
 | 
			
		||||
		return;
 | 
			
		||||
		}
 | 
			
		||||
#  endif
 | 
			
		||||
	/* Only call bn_mul_comba 8 if n2 == 8 and the
 | 
			
		||||
	 * two arrays are complete [steve]
 | 
			
		||||
	 */
 | 
			
		||||
	if (n2 == 8 && dna == 0 && dnb == 0)
 | 
			
		||||
	if (n2 == 8)
 | 
			
		||||
		{
 | 
			
		||||
		bn_mul_comba8(r,a,b);
 | 
			
		||||
		return; 
 | 
			
		||||
		}
 | 
			
		||||
# endif /* BN_MUL_COMBA */
 | 
			
		||||
	/* Else do normal multiply */
 | 
			
		||||
	if (n2 < BN_MUL_RECURSIVE_SIZE_NORMAL)
 | 
			
		||||
		{
 | 
			
		||||
		bn_mul_normal(r,a,n2+dna,b,n2+dnb);
 | 
			
		||||
		if ((dna + dnb) < 0)
 | 
			
		||||
			memset(&r[2*n2 + dna + dnb], 0,
 | 
			
		||||
				sizeof(BN_ULONG) * -(dna + dnb));
 | 
			
		||||
		/* This should not happen */
 | 
			
		||||
		bn_mul_normal(r,a,n2,b,n2);
 | 
			
		||||
		return;
 | 
			
		||||
		}
 | 
			
		||||
	/* r=(a[0]-a[1])*(b[1]-b[0]) */
 | 
			
		||||
	c1=bn_cmp_part_words(a,&(a[n]),tna,n-tna);
 | 
			
		||||
	c2=bn_cmp_part_words(&(b[n]),b,tnb,tnb-n);
 | 
			
		||||
	c1=bn_cmp_words(a,&(a[n]),n);
 | 
			
		||||
	c2=bn_cmp_words(&(b[n]),b,n);
 | 
			
		||||
	zero=neg=0;
 | 
			
		||||
	switch (c1*3+c2)
 | 
			
		||||
		{
 | 
			
		||||
	case -4:
 | 
			
		||||
		bn_sub_part_words(t,      &(a[n]),a,      tna,tna-n); /* - */
 | 
			
		||||
		bn_sub_part_words(&(t[n]),b,      &(b[n]),tnb,n-tnb); /* - */
 | 
			
		||||
		bn_sub_words(t,      &(a[n]),a,      n); /* - */
 | 
			
		||||
		bn_sub_words(&(t[n]),b,      &(b[n]),n); /* - */
 | 
			
		||||
		break;
 | 
			
		||||
	case -3:
 | 
			
		||||
		zero=1;
 | 
			
		||||
		break;
 | 
			
		||||
	case -2:
 | 
			
		||||
		bn_sub_part_words(t,      &(a[n]),a,      tna,tna-n); /* - */
 | 
			
		||||
		bn_sub_part_words(&(t[n]),&(b[n]),b,      tnb,tnb-n); /* + */
 | 
			
		||||
		bn_sub_words(t,      &(a[n]),a,      n); /* - */
 | 
			
		||||
		bn_sub_words(&(t[n]),&(b[n]),b,      n); /* + */
 | 
			
		||||
		neg=1;
 | 
			
		||||
		break;
 | 
			
		||||
	case -1:
 | 
			
		||||
@@ -450,22 +128,21 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
 | 
			
		||||
		zero=1;
 | 
			
		||||
		break;
 | 
			
		||||
	case 2:
 | 
			
		||||
		bn_sub_part_words(t,      a,      &(a[n]),tna,n-tna); /* + */
 | 
			
		||||
		bn_sub_part_words(&(t[n]),b,      &(b[n]),tnb,n-tnb); /* - */
 | 
			
		||||
		bn_sub_words(t,      a,      &(a[n]),n); /* + */
 | 
			
		||||
		bn_sub_words(&(t[n]),b,      &(b[n]),n); /* - */
 | 
			
		||||
		neg=1;
 | 
			
		||||
		break;
 | 
			
		||||
	case 3:
 | 
			
		||||
		zero=1;
 | 
			
		||||
		break;
 | 
			
		||||
	case 4:
 | 
			
		||||
		bn_sub_part_words(t,      a,      &(a[n]),tna,n-tna);
 | 
			
		||||
		bn_sub_part_words(&(t[n]),&(b[n]),b,      tnb,tnb-n);
 | 
			
		||||
		bn_sub_words(t,      a,      &(a[n]),n);
 | 
			
		||||
		bn_sub_words(&(t[n]),&(b[n]),b,      n);
 | 
			
		||||
		break;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
# ifdef BN_MUL_COMBA
 | 
			
		||||
	if (n == 4 && dna == 0 && dnb == 0) /* XXX: bn_mul_comba4 could take
 | 
			
		||||
					       extra args to do this well */
 | 
			
		||||
	if (n == 4)
 | 
			
		||||
		{
 | 
			
		||||
		if (!zero)
 | 
			
		||||
			bn_mul_comba4(&(t[n2]),t,&(t[n]));
 | 
			
		||||
@@ -475,9 +152,7 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
 | 
			
		||||
		bn_mul_comba4(r,a,b);
 | 
			
		||||
		bn_mul_comba4(&(r[n2]),&(a[n]),&(b[n]));
 | 
			
		||||
		}
 | 
			
		||||
	else if (n == 8 && dna == 0 && dnb == 0) /* XXX: bn_mul_comba8 could
 | 
			
		||||
						    take extra args to do this
 | 
			
		||||
						    well */
 | 
			
		||||
	else if (n == 8)
 | 
			
		||||
		{
 | 
			
		||||
		if (!zero)
 | 
			
		||||
			bn_mul_comba8(&(t[n2]),t,&(t[n]));
 | 
			
		||||
@@ -492,11 +167,11 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
 | 
			
		||||
		{
 | 
			
		||||
		p= &(t[n2*2]);
 | 
			
		||||
		if (!zero)
 | 
			
		||||
			bn_mul_recursive(&(t[n2]),t,&(t[n]),n,0,0,p);
 | 
			
		||||
			bn_mul_recursive(&(t[n2]),t,&(t[n]),n,p);
 | 
			
		||||
		else
 | 
			
		||||
			memset(&(t[n2]),0,n2*sizeof(BN_ULONG));
 | 
			
		||||
		bn_mul_recursive(r,a,b,n,0,0,p);
 | 
			
		||||
		bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),n,dna,dnb,p);
 | 
			
		||||
		bn_mul_recursive(r,a,b,n,p);
 | 
			
		||||
		bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),n,p);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	/* t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign
 | 
			
		||||
@@ -545,39 +220,39 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
 | 
			
		||||
 | 
			
		||||
/* n+tn is the word length
 | 
			
		||||
 * t needs to be n*4 is size, as does r */
 | 
			
		||||
void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
 | 
			
		||||
	     int tna, int tnb, BN_ULONG *t)
 | 
			
		||||
void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int tn,
 | 
			
		||||
	     int n, BN_ULONG *t)
 | 
			
		||||
	{
 | 
			
		||||
	int i,j,n2=n*2;
 | 
			
		||||
	int c1,c2,neg,zero;
 | 
			
		||||
	BN_ULONG ln,lo,*p;
 | 
			
		||||
 | 
			
		||||
# ifdef BN_COUNT
 | 
			
		||||
	fprintf(stderr," bn_mul_part_recursive (%d+%d) * (%d+%d)\n",
 | 
			
		||||
		tna, n, tnb, n);
 | 
			
		||||
	printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n);
 | 
			
		||||
# endif
 | 
			
		||||
	if (n < 8)
 | 
			
		||||
		{
 | 
			
		||||
		bn_mul_normal(r,a,n+tna,b,n+tnb);
 | 
			
		||||
		i=tn+n;
 | 
			
		||||
		bn_mul_normal(r,a,i,b,i);
 | 
			
		||||
		return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	/* r=(a[0]-a[1])*(b[1]-b[0]) */
 | 
			
		||||
	c1=bn_cmp_part_words(a,&(a[n]),tna,n-tna);
 | 
			
		||||
	c2=bn_cmp_part_words(&(b[n]),b,tnb,tnb-n);
 | 
			
		||||
	c1=bn_cmp_words(a,&(a[n]),n);
 | 
			
		||||
	c2=bn_cmp_words(&(b[n]),b,n);
 | 
			
		||||
	zero=neg=0;
 | 
			
		||||
	switch (c1*3+c2)
 | 
			
		||||
		{
 | 
			
		||||
	case -4:
 | 
			
		||||
		bn_sub_part_words(t,      &(a[n]),a,      tna,tna-n); /* - */
 | 
			
		||||
		bn_sub_part_words(&(t[n]),b,      &(b[n]),tnb,n-tnb); /* - */
 | 
			
		||||
		bn_sub_words(t,      &(a[n]),a,      n); /* - */
 | 
			
		||||
		bn_sub_words(&(t[n]),b,      &(b[n]),n); /* - */
 | 
			
		||||
		break;
 | 
			
		||||
	case -3:
 | 
			
		||||
		zero=1;
 | 
			
		||||
		/* break; */
 | 
			
		||||
	case -2:
 | 
			
		||||
		bn_sub_part_words(t,      &(a[n]),a,      tna,tna-n); /* - */
 | 
			
		||||
		bn_sub_part_words(&(t[n]),&(b[n]),b,      tnb,tnb-n); /* + */
 | 
			
		||||
		bn_sub_words(t,      &(a[n]),a,      n); /* - */
 | 
			
		||||
		bn_sub_words(&(t[n]),&(b[n]),b,      n); /* + */
 | 
			
		||||
		neg=1;
 | 
			
		||||
		break;
 | 
			
		||||
	case -1:
 | 
			
		||||
@@ -586,16 +261,16 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
 | 
			
		||||
		zero=1;
 | 
			
		||||
		/* break; */
 | 
			
		||||
	case 2:
 | 
			
		||||
		bn_sub_part_words(t,      a,      &(a[n]),tna,n-tna); /* + */
 | 
			
		||||
		bn_sub_part_words(&(t[n]),b,      &(b[n]),tnb,n-tnb); /* - */
 | 
			
		||||
		bn_sub_words(t,      a,      &(a[n]),n); /* + */
 | 
			
		||||
		bn_sub_words(&(t[n]),b,      &(b[n]),n); /* - */
 | 
			
		||||
		neg=1;
 | 
			
		||||
		break;
 | 
			
		||||
	case 3:
 | 
			
		||||
		zero=1;
 | 
			
		||||
		/* break; */
 | 
			
		||||
	case 4:
 | 
			
		||||
		bn_sub_part_words(t,      a,      &(a[n]),tna,n-tna);
 | 
			
		||||
		bn_sub_part_words(&(t[n]),&(b[n]),b,      tnb,tnb-n);
 | 
			
		||||
		bn_sub_words(t,      a,      &(a[n]),n);
 | 
			
		||||
		bn_sub_words(&(t[n]),&(b[n]),b,      n);
 | 
			
		||||
		break;
 | 
			
		||||
		}
 | 
			
		||||
		/* The zero case isn't yet implemented here. The speedup
 | 
			
		||||
@@ -614,59 +289,54 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
 | 
			
		||||
		{
 | 
			
		||||
		bn_mul_comba8(&(t[n2]),t,&(t[n]));
 | 
			
		||||
		bn_mul_comba8(r,a,b);
 | 
			
		||||
		bn_mul_normal(&(r[n2]),&(a[n]),tna,&(b[n]),tnb);
 | 
			
		||||
		memset(&(r[n2+tna+tnb]),0,sizeof(BN_ULONG)*(n2-tna-tnb));
 | 
			
		||||
		bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn);
 | 
			
		||||
		memset(&(r[n2+tn*2]),0,sizeof(BN_ULONG)*(n2-tn*2));
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
		p= &(t[n2*2]);
 | 
			
		||||
		bn_mul_recursive(&(t[n2]),t,&(t[n]),n,0,0,p);
 | 
			
		||||
		bn_mul_recursive(r,a,b,n,0,0,p);
 | 
			
		||||
		bn_mul_recursive(&(t[n2]),t,&(t[n]),n,p);
 | 
			
		||||
		bn_mul_recursive(r,a,b,n,p);
 | 
			
		||||
		i=n/2;
 | 
			
		||||
		/* If there is only a bottom half to the number,
 | 
			
		||||
		 * just do it */
 | 
			
		||||
		if (tna > tnb)
 | 
			
		||||
			j = tna - i;
 | 
			
		||||
		else
 | 
			
		||||
			j = tnb - i;
 | 
			
		||||
		j=tn-i;
 | 
			
		||||
		if (j == 0)
 | 
			
		||||
			{
 | 
			
		||||
			bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),
 | 
			
		||||
				i,tna-i,tnb-i,p);
 | 
			
		||||
			bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),i,p);
 | 
			
		||||
			memset(&(r[n2+i*2]),0,sizeof(BN_ULONG)*(n2-i*2));
 | 
			
		||||
			}
 | 
			
		||||
		else if (j > 0) /* eg, n == 16, i == 8 and tn == 11 */
 | 
			
		||||
				{
 | 
			
		||||
				bn_mul_part_recursive(&(r[n2]),&(a[n]),&(b[n]),
 | 
			
		||||
					i,tna-i,tnb-i,p);
 | 
			
		||||
				memset(&(r[n2+tna+tnb]),0,
 | 
			
		||||
					sizeof(BN_ULONG)*(n2-tna-tnb));
 | 
			
		||||
					j,i,p);
 | 
			
		||||
				memset(&(r[n2+tn*2]),0,
 | 
			
		||||
					sizeof(BN_ULONG)*(n2-tn*2));
 | 
			
		||||
				}
 | 
			
		||||
		else /* (j < 0) eg, n == 16, i == 8 and tn == 5 */
 | 
			
		||||
			{
 | 
			
		||||
			memset(&(r[n2]),0,sizeof(BN_ULONG)*n2);
 | 
			
		||||
			if (tna < BN_MUL_RECURSIVE_SIZE_NORMAL
 | 
			
		||||
				&& tnb < BN_MUL_RECURSIVE_SIZE_NORMAL)
 | 
			
		||||
			if (tn < BN_MUL_RECURSIVE_SIZE_NORMAL)
 | 
			
		||||
				{
 | 
			
		||||
				bn_mul_normal(&(r[n2]),&(a[n]),tna,&(b[n]),tnb);
 | 
			
		||||
				bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn);
 | 
			
		||||
				}
 | 
			
		||||
			else
 | 
			
		||||
				{
 | 
			
		||||
				for (;;)
 | 
			
		||||
					{
 | 
			
		||||
					i/=2;
 | 
			
		||||
					if (i < tna && i < tnb)
 | 
			
		||||
					if (i < tn)
 | 
			
		||||
						{
 | 
			
		||||
						bn_mul_part_recursive(&(r[n2]),
 | 
			
		||||
							&(a[n]),&(b[n]),
 | 
			
		||||
							i,tna-i,tnb-i,p);
 | 
			
		||||
							tn-i,i,p);
 | 
			
		||||
						break;
 | 
			
		||||
						}
 | 
			
		||||
					else if (i <= tna && i <= tnb)
 | 
			
		||||
					else if (i == tn)
 | 
			
		||||
						{
 | 
			
		||||
						bn_mul_recursive(&(r[n2]),
 | 
			
		||||
							&(a[n]),&(b[n]),
 | 
			
		||||
							i,tna-i,tnb-i,p);
 | 
			
		||||
							i,p);
 | 
			
		||||
						break;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
@@ -727,10 +397,10 @@ void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
 | 
			
		||||
	int n=n2/2;
 | 
			
		||||
 | 
			
		||||
# ifdef BN_COUNT
 | 
			
		||||
	fprintf(stderr," bn_mul_low_recursive %d * %d\n",n2,n2);
 | 
			
		||||
	printf(" bn_mul_low_recursive %d * %d\n",n2,n2);
 | 
			
		||||
# endif
 | 
			
		||||
 | 
			
		||||
	bn_mul_recursive(r,a,b,n,0,0,&(t[0]));
 | 
			
		||||
	bn_mul_recursive(r,a,b,n,&(t[0]));
 | 
			
		||||
	if (n >= BN_MUL_LOW_RECURSIVE_SIZE_NORMAL)
 | 
			
		||||
		{
 | 
			
		||||
		bn_mul_low_recursive(&(t[0]),&(a[0]),&(b[n]),n,&(t[n2]));
 | 
			
		||||
@@ -761,7 +431,7 @@ void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
 | 
			
		||||
	BN_ULONG ll,lc,*lp,*mp;
 | 
			
		||||
 | 
			
		||||
# ifdef BN_COUNT
 | 
			
		||||
	fprintf(stderr," bn_mul_high %d * %d\n",n2,n2);
 | 
			
		||||
	printf(" bn_mul_high %d * %d\n",n2,n2);
 | 
			
		||||
# endif
 | 
			
		||||
	n=n2/2;
 | 
			
		||||
 | 
			
		||||
@@ -814,8 +484,8 @@ void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
 | 
			
		||||
	else
 | 
			
		||||
# endif
 | 
			
		||||
		{
 | 
			
		||||
		bn_mul_recursive(&(t[0]),&(r[0]),&(r[n]),n,0,0,&(t[n2]));
 | 
			
		||||
		bn_mul_recursive(r,&(a[n]),&(b[n]),n,0,0,&(t[n2]));
 | 
			
		||||
		bn_mul_recursive(&(t[0]),&(r[0]),&(r[n]),n,&(t[n2]));
 | 
			
		||||
		bn_mul_recursive(r,&(a[n]),&(b[n]),n,&(t[n2]));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	/* s0 == low(al*bl)
 | 
			
		||||
@@ -940,19 +610,19 @@ void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
 | 
			
		||||
 | 
			
		||||
int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	int ret=0;
 | 
			
		||||
	int top,al,bl;
 | 
			
		||||
	BIGNUM *rr;
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
 | 
			
		||||
	int i;
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef BN_RECURSION
 | 
			
		||||
	BIGNUM *t=NULL;
 | 
			
		||||
	int j=0,k;
 | 
			
		||||
	BIGNUM *t;
 | 
			
		||||
	int j,k;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef BN_COUNT
 | 
			
		||||
	fprintf(stderr,"BN_mul %d * %d\n",a->top,b->top);
 | 
			
		||||
	printf("BN_mul %d * %d\n",a->top,b->top);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	bn_check_top(a);
 | 
			
		||||
@@ -1005,55 +675,21 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
 | 
			
		||||
#ifdef BN_RECURSION
 | 
			
		||||
	if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL))
 | 
			
		||||
		{
 | 
			
		||||
		if (i >= -1 && i <= 1)
 | 
			
		||||
		if (i == 1 && !BN_get_flags(b,BN_FLG_STATIC_DATA) && bl<b->dmax)
 | 
			
		||||
			{
 | 
			
		||||
			int sav_j =0;
 | 
			
		||||
			/* Find out the power of two lower or equal
 | 
			
		||||
			   to the longest of the two numbers */
 | 
			
		||||
			if (i >= 0)
 | 
			
		||||
				{
 | 
			
		||||
				j = BN_num_bits_word((BN_ULONG)al);
 | 
			
		||||
				}
 | 
			
		||||
			if (i == -1)
 | 
			
		||||
				{
 | 
			
		||||
				j = BN_num_bits_word((BN_ULONG)bl);
 | 
			
		||||
				}
 | 
			
		||||
			sav_j = j;
 | 
			
		||||
			j = 1<<(j-1);
 | 
			
		||||
			assert(j <= al || j <= bl);
 | 
			
		||||
			k = j+j;
 | 
			
		||||
			t = BN_CTX_get(ctx);
 | 
			
		||||
			if (al > j || bl > j)
 | 
			
		||||
				{
 | 
			
		||||
				bn_wexpand(t,k*4);
 | 
			
		||||
				bn_wexpand(rr,k*4);
 | 
			
		||||
				bn_mul_part_recursive(rr->d,a->d,b->d,
 | 
			
		||||
					j,al-j,bl-j,t->d);
 | 
			
		||||
				}
 | 
			
		||||
			else	/* al <= j || bl <= j */
 | 
			
		||||
				{
 | 
			
		||||
				bn_wexpand(t,k*2);
 | 
			
		||||
				bn_wexpand(rr,k*2);
 | 
			
		||||
				bn_mul_recursive(rr->d,a->d,b->d,
 | 
			
		||||
					j,al-j,bl-j,t->d);
 | 
			
		||||
				}
 | 
			
		||||
			rr->top=top;
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
#if 0
 | 
			
		||||
		if (i == 1 && !BN_get_flags(b,BN_FLG_STATIC_DATA))
 | 
			
		||||
			{
 | 
			
		||||
			BIGNUM *tmp_bn = (BIGNUM *)b;
 | 
			
		||||
			if (bn_wexpand(tmp_bn,al) == NULL) goto err;
 | 
			
		||||
			tmp_bn->d[bl]=0;
 | 
			
		||||
#if 0	/* tribute to const-ification, bl<b->dmax above covers for this */
 | 
			
		||||
			if (bn_wexpand(b,al) == NULL) goto err;
 | 
			
		||||
#endif
 | 
			
		||||
			b->d[bl]=0;
 | 
			
		||||
			bl++;
 | 
			
		||||
			i--;
 | 
			
		||||
			}
 | 
			
		||||
		else if (i == -1 && !BN_get_flags(a,BN_FLG_STATIC_DATA))
 | 
			
		||||
		else if (i == -1 && !BN_get_flags(a,BN_FLG_STATIC_DATA) && al<a->dmax)
 | 
			
		||||
			{
 | 
			
		||||
			BIGNUM *tmp_bn = (BIGNUM *)a;
 | 
			
		||||
			if (bn_wexpand(tmp_bn,bl) == NULL) goto err;
 | 
			
		||||
			tmp_bn->d[al]=0;
 | 
			
		||||
#if 0	/* tribute to const-ification, al<a->dmax above covers for this */
 | 
			
		||||
			if (bn_wexpand(a,bl) == NULL) goto err;
 | 
			
		||||
#endif
 | 
			
		||||
			a->d[al]=0;
 | 
			
		||||
			al++;
 | 
			
		||||
			i++;
 | 
			
		||||
			}
 | 
			
		||||
@@ -1070,18 +706,27 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
 | 
			
		||||
				if (bn_wexpand(t,k*2) == NULL) goto err;
 | 
			
		||||
				if (bn_wexpand(rr,k*2) == NULL) goto err;
 | 
			
		||||
				bn_mul_recursive(rr->d,a->d,b->d,al,t->d);
 | 
			
		||||
				rr->top=top;
 | 
			
		||||
				goto end;
 | 
			
		||||
				}
 | 
			
		||||
#if 0	/* tribute to const-ification, rsa/dsa performance is not affected */
 | 
			
		||||
			else
 | 
			
		||||
				{
 | 
			
		||||
				if (bn_wexpand(a,k) == NULL ) goto err;
 | 
			
		||||
				if (bn_wexpand(b,k) == NULL ) goto err;
 | 
			
		||||
				if (bn_wexpand(t,k*4) == NULL ) goto err;
 | 
			
		||||
				if (bn_wexpand(rr,k*4) == NULL ) goto err;
 | 
			
		||||
				for (i=a->top; i<k; i++)
 | 
			
		||||
					a->d[i]=0;
 | 
			
		||||
				for (i=b->top; i<k; i++)
 | 
			
		||||
					b->d[i]=0;
 | 
			
		||||
				bn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d);
 | 
			
		||||
				}
 | 
			
		||||
			rr->top=top;
 | 
			
		||||
			goto end;
 | 
			
		||||
			}
 | 
			
		||||
#endif
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
#endif /* BN_RECURSION */
 | 
			
		||||
	if (bn_wexpand(rr,top) == NULL) goto err;
 | 
			
		||||
	rr->top=top;
 | 
			
		||||
@@ -1103,7 +748,7 @@ void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
 | 
			
		||||
	BN_ULONG *rr;
 | 
			
		||||
 | 
			
		||||
#ifdef BN_COUNT
 | 
			
		||||
	fprintf(stderr," bn_mul_normal %d * %d\n",na,nb);
 | 
			
		||||
	printf(" bn_mul_normal %d * %d\n",na,nb);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	if (na < nb)
 | 
			
		||||
@@ -1116,12 +761,6 @@ void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
	rr= &(r[na]);
 | 
			
		||||
	if (nb <= 0)
 | 
			
		||||
		{
 | 
			
		||||
		(void)bn_mul_words(r,a,na,0);
 | 
			
		||||
		return;
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
	rr[0]=bn_mul_words(r,a,na,b[0]);
 | 
			
		||||
 | 
			
		||||
	for (;;)
 | 
			
		||||
@@ -1143,7 +782,7 @@ void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
 | 
			
		||||
void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
 | 
			
		||||
	{
 | 
			
		||||
#ifdef BN_COUNT
 | 
			
		||||
	fprintf(stderr," bn_mul_low_normal %d * %d\n",n,n);
 | 
			
		||||
	printf(" bn_mul_low_normal %d * %d\n",n,n);
 | 
			
		||||
#endif
 | 
			
		||||
	bn_mul_words(r,a,n,b[0]);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,843 +0,0 @@
 | 
			
		||||
/* crypto/bn/bn_nist.p */
 | 
			
		||||
/* ====================================================================
 | 
			
		||||
 * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *
 | 
			
		||||
 * 1. Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer. 
 | 
			
		||||
 *
 | 
			
		||||
 * 2. Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * 3. All advertising materials mentioning features or use of this
 | 
			
		||||
 *    software must display the following acknowledgment:
 | 
			
		||||
 *    "This product includes software developed by the OpenSSL Project
 | 
			
		||||
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 | 
			
		||||
 *
 | 
			
		||||
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 | 
			
		||||
 *    endorse or promote products derived from this software without
 | 
			
		||||
 *    prior written permission. For written permission, please contact
 | 
			
		||||
 *    openssl-core@openssl.org.
 | 
			
		||||
 *
 | 
			
		||||
 * 5. Products derived from this software may not be called "OpenSSL"
 | 
			
		||||
 *    nor may "OpenSSL" appear in their names without prior written
 | 
			
		||||
 *    permission of the OpenSSL Project.
 | 
			
		||||
 *
 | 
			
		||||
 * 6. Redistributions of any form whatsoever must retain the following
 | 
			
		||||
 *    acknowledgment:
 | 
			
		||||
 *    "This product includes software developed by the OpenSSL Project
 | 
			
		||||
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 | 
			
		||||
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 | 
			
		||||
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
 | 
			
		||||
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 | 
			
		||||
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 | 
			
		||||
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 | 
			
		||||
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 | 
			
		||||
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 | 
			
		||||
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 | 
			
		||||
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 | 
			
		||||
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
 * ====================================================================
 | 
			
		||||
 *
 | 
			
		||||
 * This product includes cryptographic software written by Eric Young
 | 
			
		||||
 * (eay@cryptsoft.com).  This product includes software written by Tim
 | 
			
		||||
 * Hudson (tjh@cryptsoft.com).
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "bn_lcl.h"
 | 
			
		||||
#include "cryptlib.h"
 | 
			
		||||
 | 
			
		||||
#define BN_NIST_192_TOP	(192+BN_BITS2-1)/BN_BITS2
 | 
			
		||||
#define BN_NIST_224_TOP	(224+BN_BITS2-1)/BN_BITS2
 | 
			
		||||
#define BN_NIST_256_TOP	(256+BN_BITS2-1)/BN_BITS2
 | 
			
		||||
#define BN_NIST_384_TOP	(384+BN_BITS2-1)/BN_BITS2
 | 
			
		||||
#define BN_NIST_521_TOP	(521+BN_BITS2-1)/BN_BITS2
 | 
			
		||||
 | 
			
		||||
#if BN_BITS2 == 64
 | 
			
		||||
const static BN_ULONG _nist_p_192[] = {0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFE,
 | 
			
		||||
	0xFFFFFFFFFFFFFFFF};
 | 
			
		||||
const static BN_ULONG _nist_p_224[] = {0x0000000000000001,0xFFFFFFFF00000000,
 | 
			
		||||
	0xFFFFFFFFFFFFFFFF,0x00000000FFFFFFFF};
 | 
			
		||||
const static BN_ULONG _nist_p_256[] = {0xFFFFFFFFFFFFFFFF,0x00000000FFFFFFFF,
 | 
			
		||||
	0x0000000000000000,0xFFFFFFFF00000001};
 | 
			
		||||
const static BN_ULONG _nist_p_384[] = {0x00000000FFFFFFFF,0xFFFFFFFF00000000,
 | 
			
		||||
	0xFFFFFFFFFFFFFFFE,0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF,
 | 
			
		||||
	0xFFFFFFFFFFFFFFFF};
 | 
			
		||||
const static BN_ULONG _nist_p_521[] = {0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF,
 | 
			
		||||
	0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF,
 | 
			
		||||
	0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF,
 | 
			
		||||
	0x00000000000001FF};
 | 
			
		||||
#elif BN_BITS2 == 32
 | 
			
		||||
const static BN_ULONG _nist_p_192[] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFE,
 | 
			
		||||
	0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
 | 
			
		||||
const static BN_ULONG _nist_p_224[] = {0x00000001,0x00000000,0x00000000,
 | 
			
		||||
	0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
 | 
			
		||||
const static BN_ULONG _nist_p_256[] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
 | 
			
		||||
	0x00000000,0x00000000,0x00000000,0x00000001,0xFFFFFFFF};
 | 
			
		||||
const static BN_ULONG _nist_p_384[] = {0xFFFFFFFF,0x00000000,0x00000000,
 | 
			
		||||
	0xFFFFFFFF,0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
 | 
			
		||||
	0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
 | 
			
		||||
const static BN_ULONG _nist_p_521[] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
 | 
			
		||||
	0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
 | 
			
		||||
	0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
 | 
			
		||||
	0xFFFFFFFF,0x000001FF};
 | 
			
		||||
#elif BN_BITS2 == 16
 | 
			
		||||
const static BN_ULONG _nist_p_192[] = {0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFE,
 | 
			
		||||
	0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF};
 | 
			
		||||
const static BN_ULONG _nist_p_224[] = {0x0001,0x0000,0x0000,0x0000,0x0000,
 | 
			
		||||
	0x0000,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF};
 | 
			
		||||
const static BN_ULONG _nist_p_256[] = {0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
 | 
			
		||||
	0xFFFF,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0001,0x0000,0xFFFF,
 | 
			
		||||
	0xFFFF};
 | 
			
		||||
const static BN_ULONG _nist_p_384[] = {0xFFFF,0xFFFF,0x0000,0x0000,0x0000,
 | 
			
		||||
	0x0000,0xFFFF,0xFFFF,0xFFFE,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
 | 
			
		||||
	0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF};
 | 
			
		||||
const static BN_ULONG _nist_p_521[] = {0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
 | 
			
		||||
	0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
 | 
			
		||||
	0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
 | 
			
		||||
	0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x01FF};
 | 
			
		||||
#elif BN_BITS2 == 8
 | 
			
		||||
const static BN_ULONG _nist_p_192[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 | 
			
		||||
	0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 | 
			
		||||
	0xFF,0xFF};
 | 
			
		||||
const static BN_ULONG _nist_p_224[] = {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 | 
			
		||||
	0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 | 
			
		||||
	0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
 | 
			
		||||
const static BN_ULONG _nist_p_256[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 | 
			
		||||
	0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 | 
			
		||||
	0x00,0x00,0x01,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF};
 | 
			
		||||
const static BN_ULONG _nist_p_384[] = {0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
 | 
			
		||||
	0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,
 | 
			
		||||
	0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 | 
			
		||||
	0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
 | 
			
		||||
const static BN_ULONG _nist_p_521[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 | 
			
		||||
	0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 | 
			
		||||
	0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 | 
			
		||||
	0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 | 
			
		||||
	0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 | 
			
		||||
	0xFF,0x01};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
const BIGNUM *BN_get0_nist_prime_192(void)
 | 
			
		||||
	{
 | 
			
		||||
	static BIGNUM const_nist_192={(BN_ULONG *)_nist_p_192,BN_NIST_192_TOP,
 | 
			
		||||
		BN_NIST_192_TOP, 0, BN_FLG_STATIC_DATA};
 | 
			
		||||
	return &const_nist_192;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
const BIGNUM *BN_get0_nist_prime_224(void)
 | 
			
		||||
	{
 | 
			
		||||
	static BIGNUM const_nist_224={(BN_ULONG *)_nist_p_224,BN_NIST_224_TOP,
 | 
			
		||||
		BN_NIST_224_TOP, 0, BN_FLG_STATIC_DATA};
 | 
			
		||||
	return &const_nist_224;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
const BIGNUM *BN_get0_nist_prime_256(void)
 | 
			
		||||
	{
 | 
			
		||||
	static BIGNUM const_nist_256={(BN_ULONG *)_nist_p_256,BN_NIST_256_TOP,
 | 
			
		||||
		BN_NIST_256_TOP, 0, BN_FLG_STATIC_DATA};
 | 
			
		||||
	return &const_nist_256;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
const BIGNUM *BN_get0_nist_prime_384(void)
 | 
			
		||||
	{
 | 
			
		||||
	static BIGNUM const_nist_384={(BN_ULONG *)_nist_p_384,BN_NIST_384_TOP,
 | 
			
		||||
		BN_NIST_384_TOP, 0, BN_FLG_STATIC_DATA};
 | 
			
		||||
	return &const_nist_384;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
const BIGNUM *BN_get0_nist_prime_521(void)
 | 
			
		||||
	{
 | 
			
		||||
	static BIGNUM const_nist_521={(BN_ULONG *)_nist_p_521,BN_NIST_521_TOP,
 | 
			
		||||
		BN_NIST_521_TOP, 0, BN_FLG_STATIC_DATA};
 | 
			
		||||
	return &const_nist_521;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/* some misc internal functions */
 | 
			
		||||
static BN_ULONG _256_data[BN_NIST_256_TOP*6];
 | 
			
		||||
static int _is_set_256_data = 0;
 | 
			
		||||
static void _init_256_data(void);
 | 
			
		||||
 | 
			
		||||
static BN_ULONG _384_data[BN_NIST_384_TOP*8];
 | 
			
		||||
static int _is_set_384_data = 0;
 | 
			
		||||
static void _init_384_data(void);
 | 
			
		||||
 | 
			
		||||
#define BN_NIST_ADD_ONE(a)	while (!(++(*(a)))) ++(a);
 | 
			
		||||
#define __buf_0			(BN_ULONG)0
 | 
			
		||||
#define __buf_0_1		(BN_ULONG)0
 | 
			
		||||
#define __buf_0_2		(BN_ULONG)0
 | 
			
		||||
#if BN_BITS2 == 64
 | 
			
		||||
#define BN_64_BIT_BUF(n)	BN_ULONG __buf_##n = (BN_ULONG)0;
 | 
			
		||||
#define BN_CP_64_TO_BUF(n)	__buf_##n = (a)[(n)];
 | 
			
		||||
#define BN_CP_64_FROM_BUF(a,n)	*(a)++ = __buf_##n;
 | 
			
		||||
#define BN_CASE_64_BIT(n,a)	case (n): __buf_##n = (a)[(n)];
 | 
			
		||||
#if	UINT_MAX == 4294967295UL
 | 
			
		||||
#define	nist32	unsigned int
 | 
			
		||||
#define BN_32_BIT_BUF(n)	nist32 __buf_##n = (nist32)0;
 | 
			
		||||
#define BN_CP_32_TO_BUF(n)	__buf_##n = ((nist32 *)(a))[(n)];
 | 
			
		||||
#define BN_CP_32_FROM_BUF(a,n)	*((nist32)(a))++ = __buf_##n;
 | 
			
		||||
#define BN_CASE_32_BIT(n,a)	case (n): __buf_##n = ((nist32)(a))[(n)];
 | 
			
		||||
#elif	ULONG_MAX == 4294967295UL
 | 
			
		||||
#define	nist32	unsigned long
 | 
			
		||||
#define BN_32_BIT_BUF(n)	nist32 __buf_##n = (nist32)0;
 | 
			
		||||
#define BN_CP_32_TO_BUF(n)	__buf_##n = ((nist32 *)(a))[(n)];
 | 
			
		||||
#define BN_CP_32_FROM_BUF(a,n)	*((nist32)(a))++ = __buf_##n;
 | 
			
		||||
#define BN_CASE_32_BIT(n,a)	case (n): __buf_##n = ((nist32)(a))[(n)];
 | 
			
		||||
#else
 | 
			
		||||
#define	NO_32_BIT_TYPE
 | 
			
		||||
#endif
 | 
			
		||||
#elif BN_BITS2 == 32
 | 
			
		||||
#define BN_64_BIT_BUF(n)	BN_ULONG __buf_##n##_1 = (BN_ULONG)0;\
 | 
			
		||||
				BN_ULONG __buf_##n##_2 = (BN_ULONG)0;
 | 
			
		||||
#define BN_CP_64_TO_BUF(n)	__buf_##n##_2 = (a)[2*(n)+1];\
 | 
			
		||||
				__buf_##n##_1 = (a)[2*(n)];
 | 
			
		||||
#define BN_CP_64_FROM_BUF(a,n)	*(a)++ = __buf_##n##_1;\
 | 
			
		||||
				*(a)++ = __buf_##n##_2;
 | 
			
		||||
#define BN_CASE_64_BIT(n,a)	case 2*(n)+1: __buf_##n##_2 = (a)[2*(n)+1];\
 | 
			
		||||
				case 2*(n):   __buf_##n##_1 = (a)[2*(n)];
 | 
			
		||||
				
 | 
			
		||||
#define BN_32_BIT_BUF(n)	BN_ULONG __buf_##n = (BN_ULONG)0;
 | 
			
		||||
#define BN_CP_32_TO_BUF(n)	__buf_##n = (a)[(n)];
 | 
			
		||||
#define BN_CP_32_FROM_BUF(a,n)	*(a)++ = __buf_##n;
 | 
			
		||||
#define BN_CASE_32_BIT(n,a)	case (n): __buf_##n = (a)[(n)];
 | 
			
		||||
#elif BN_BITS2 == 16
 | 
			
		||||
#define __buf_0_3		(BN_ULONG)0
 | 
			
		||||
#define __buf_0_4		(BN_ULONG)0
 | 
			
		||||
#define BN_64_BIT_BUF(n)	BN_ULONG __buf_##n##_1 = (BN_ULONG)0;\
 | 
			
		||||
				BN_ULONG __buf_##n##_2 = (BN_ULONG)0;\
 | 
			
		||||
				BN_ULONG __buf_##n##_3 = (BN_ULONG)0;\
 | 
			
		||||
				BN_ULONG __buf_##n##_4 = (BN_ULONG)0;
 | 
			
		||||
#define BN_CP_64_TO_BUF(n)	__buf_##n##_4 = (a)[4*(n)+3];\
 | 
			
		||||
				__buf_##n##_3 = (a)[4*(n)+2];\
 | 
			
		||||
				__buf_##n##_2 = (a)[4*(n)+1];\
 | 
			
		||||
				__buf_##n##_1 = (a)[4*(n)];
 | 
			
		||||
#define BN_CP_64_FROM_BUF(a,n)	*(a)++ = __buf_##n##_1;\
 | 
			
		||||
				*(a)++ = __buf_##n##_2;\
 | 
			
		||||
				*(a)++ = __buf_##n##_3;\
 | 
			
		||||
				*(a)++ = __buf_##n##_4;
 | 
			
		||||
#define BN_CASE_64_BIT(n,a)	case 4*(n)+3: __buf_##n##_4 = (a)[4*(n)+3];\
 | 
			
		||||
				case 4*(n)+2: __buf_##n##_3 = (a)[4*(n)+2];\
 | 
			
		||||
				case 4*(n)+1: __buf_##n##_2 = (a)[4*(n)+1];\
 | 
			
		||||
				case 4*(n):   __buf_##n##_1 = (a)[4*(n)];
 | 
			
		||||
#define BN_32_BIT_BUF(n)	BN_ULONG __buf_##n##_1 = (BN_ULONG)0;\
 | 
			
		||||
				BN_ULONG __buf_##n##_2 = (BN_ULONG)0;
 | 
			
		||||
#define BN_CP_32_TO_BUF(n)	__buf_##n##_1 = (a)[2*(n)];\
 | 
			
		||||
				__buf_##n##_2 = (a)[2*(n)+1];
 | 
			
		||||
#define BN_CP_32_FROM_BUF(a,n)	*(a)++ = __buf_##n##_1;\
 | 
			
		||||
				*(a)++ = __buf_##n##_2;
 | 
			
		||||
#define BN_CASE_32_BIT(n,a)	case 2*(n)+1: __buf_##n##_2 = (a)[2*(n)+1];\
 | 
			
		||||
				case 2*(n):   __buf_##n##_1 = (a)[2*(n)];
 | 
			
		||||
#elif BN_BITS2 == 8
 | 
			
		||||
#define __buf_0_3		(BN_ULONG)0
 | 
			
		||||
#define __buf_0_4		(BN_ULONG)0
 | 
			
		||||
#define __buf_0_5		(BN_ULONG)0
 | 
			
		||||
#define __buf_0_6		(BN_ULONG)0
 | 
			
		||||
#define __buf_0_7		(BN_ULONG)0
 | 
			
		||||
#define __buf_0_8		(BN_ULONG)0
 | 
			
		||||
#define BN_64_BIT_BUF(n)	BN_ULONG __buf_##n##_1 = (BN_ULONG)0;\
 | 
			
		||||
				BN_ULONG __buf_##n##_2 = (BN_ULONG)0;\
 | 
			
		||||
				BN_ULONG __buf_##n##_3 = (BN_ULONG)0;\
 | 
			
		||||
				BN_ULONG __buf_##n##_4 = (BN_ULONG)0;\
 | 
			
		||||
				BN_ULONG __buf_##n##_5 = (BN_ULONG)0;\
 | 
			
		||||
				BN_ULONG __buf_##n##_6 = (BN_ULONG)0;\
 | 
			
		||||
				BN_ULONG __buf_##n##_7 = (BN_ULONG)0;\
 | 
			
		||||
				BN_ULONG __buf_##n##_8 = (BN_ULONG)0;
 | 
			
		||||
#define BN_CP_64_TO_BUF(n)	__buf_##n##_8 = (a)[8*(n)+7];\
 | 
			
		||||
				__buf_##n##_7 = (a)[8*(n)+6];\
 | 
			
		||||
				__buf_##n##_6 = (a)[8*(n)+5];\
 | 
			
		||||
				__buf_##n##_5 = (a)[8*(n)+4];\
 | 
			
		||||
				__buf_##n##_4 = (a)[8*(n)+3];\
 | 
			
		||||
				__buf_##n##_3 = (a)[8*(n)+2];\
 | 
			
		||||
				__buf_##n##_2 = (a)[8*(n)+1];\
 | 
			
		||||
				__buf_##n##_1 = (a)[8*(n)];
 | 
			
		||||
#define BN_CP_64_FROM_BUF(a,n)	*(a)++ = __buf_##n##_1;\
 | 
			
		||||
				*(a)++ = __buf_##n##_2;\
 | 
			
		||||
				*(a)++ = __buf_##n##_3;\
 | 
			
		||||
				*(a)++ = __buf_##n##_4;\
 | 
			
		||||
				*(a)++ = __buf_##n##_5;\
 | 
			
		||||
				*(a)++ = __buf_##n##_6;\
 | 
			
		||||
				*(a)++ = __buf_##n##_7;\
 | 
			
		||||
				*(a)++ = __buf_##n##_8;
 | 
			
		||||
#define BN_CASE_64_BIT(n,a)	case 8*(n)+7: __buf_##n##_8 = (a)[8*(n)+7];\
 | 
			
		||||
				case 8*(n)+6: __buf_##n##_7 = (a)[8*(n)+6];\
 | 
			
		||||
				case 8*(n)+5: __buf_##n##_6 = (a)[8*(n)+5];\
 | 
			
		||||
				case 8*(n)+4: __buf_##n##_5 = (a)[8*(n)+4];\
 | 
			
		||||
				case 8*(n)+3: __buf_##n##_4 = (a)[8*(n)+3];\
 | 
			
		||||
				case 8*(n)+2: __buf_##n##_3 = (a)[8*(n)+2];\
 | 
			
		||||
				case 8*(n)+1: __buf_##n##_2 = (a)[8*(n)+1];\
 | 
			
		||||
				case 8*(n):   __buf_##n##_1 = (a)[8*(n)];
 | 
			
		||||
#define BN_32_BIT_BUF(n)	BN_ULONG __buf_##n##_1 = (BN_ULONG)0;\
 | 
			
		||||
				BN_ULONG __buf_##n##_2 = (BN_ULONG)0;\
 | 
			
		||||
				BN_ULONG __buf_##n##_3 = (BN_ULONG)0;\
 | 
			
		||||
				BN_ULONG __buf_##n##_4 = (BN_ULONG)0;
 | 
			
		||||
#define BN_CP_32_TO_BUF(n)	__buf_##n##_1 = (a)[4*(n)];\
 | 
			
		||||
				__buf_##n##_2 = (a)[4*(n)+1];\
 | 
			
		||||
				__buf_##n##_3 = (a)[4*(n)+2];\
 | 
			
		||||
				__buf_##n##_4 = (a)[4*(n)+3];
 | 
			
		||||
#define BN_CP_32_FROM_BUF(a,n)	*(a)++ = __buf_##n##_1;\
 | 
			
		||||
				*(a)++ = __buf_##n##_2;\
 | 
			
		||||
				*(a)++ = __buf_##n##_3;\
 | 
			
		||||
				*(a)++ = __buf_##n##_4;
 | 
			
		||||
#define BN_CASE_32_BIT(n,a)	case 4*(n)+3: __buf_##n##_4 = (a)[4*(n)+3];\
 | 
			
		||||
				case 4*(n)+2: __buf_##n##_3 = (a)[4*(n)+2];\
 | 
			
		||||
				case 4*(n)+1: __buf_##n##_2 = (a)[4*(n)+1];\
 | 
			
		||||
				case 4*(n):   __buf_##n##_1 = (a)[4*(n)];
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define BN_192_SET(d,a1,a2,a3) \
 | 
			
		||||
	{\
 | 
			
		||||
	register BN_ULONG *td = (d);\
 | 
			
		||||
	BN_CP_64_FROM_BUF(td,a3); BN_CP_64_FROM_BUF(td,a2);\
 | 
			
		||||
	BN_CP_64_FROM_BUF(td,a1);\
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
 | 
			
		||||
	BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
	int      top;
 | 
			
		||||
	BN_ULONG carry = 0;
 | 
			
		||||
	register BN_ULONG *r_d, *a_d;
 | 
			
		||||
	BN_ULONG t_d[BN_NIST_192_TOP];
 | 
			
		||||
	BN_64_BIT_BUF(3)  BN_64_BIT_BUF(4)
 | 
			
		||||
	BN_64_BIT_BUF(5)
 | 
			
		||||
 | 
			
		||||
	top = BN_ucmp(field, a);
 | 
			
		||||
	if (top == 0)
 | 
			
		||||
		return BN_zero(r);
 | 
			
		||||
	else if (top > 0)
 | 
			
		||||
		return (r == a)? 1 : (BN_copy(r ,a) != NULL);
 | 
			
		||||
 | 
			
		||||
	if (r != a)
 | 
			
		||||
		if (!BN_ncopy(r, a, BN_NIST_192_TOP))
 | 
			
		||||
			return 0;
 | 
			
		||||
 | 
			
		||||
	r_d = r->d;
 | 
			
		||||
	a_d = a->d;
 | 
			
		||||
	top = a->top-1;
 | 
			
		||||
 | 
			
		||||
	switch (top)
 | 
			
		||||
		{
 | 
			
		||||
		BN_CASE_64_BIT(5, a_d)
 | 
			
		||||
		BN_CASE_64_BIT(4, a_d)
 | 
			
		||||
		BN_CASE_64_BIT(3, a_d)
 | 
			
		||||
			break;
 | 
			
		||||
		default: /* a->top == field->top */
 | 
			
		||||
			return BN_usub(r, a, field);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	BN_192_SET(t_d,0,3,3)
 | 
			
		||||
	if (bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP))
 | 
			
		||||
		++carry;
 | 
			
		||||
 | 
			
		||||
	BN_192_SET(t_d,4,4,0)
 | 
			
		||||
	if (bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP))
 | 
			
		||||
		++carry;
 | 
			
		||||
 | 
			
		||||
	BN_192_SET(t_d,5,5,5)
 | 
			
		||||
	if (bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP))
 | 
			
		||||
		++carry;
 | 
			
		||||
 | 
			
		||||
	while (carry)
 | 
			
		||||
		{
 | 
			
		||||
		if (bn_sub_words(r_d, r_d, _nist_p_192, BN_NIST_192_TOP))
 | 
			
		||||
			--carry; 
 | 
			
		||||
		}
 | 
			
		||||
	r->top = BN_NIST_192_TOP;
 | 
			
		||||
 | 
			
		||||
#if 1
 | 
			
		||||
	bn_clear_top2max(r);
 | 
			
		||||
#endif
 | 
			
		||||
	bn_fix_top(r);
 | 
			
		||||
 | 
			
		||||
	if (BN_ucmp(r, field) >= 0)
 | 
			
		||||
		{
 | 
			
		||||
		bn_sub_words(r_d, r_d, _nist_p_192, BN_NIST_192_TOP);
 | 
			
		||||
		bn_fix_top(r);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	return 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
#define BN_224_SET(d,a1,a2,a3,a4,a5,a6,a7) \
 | 
			
		||||
	{\
 | 
			
		||||
	register BN_ULONG *td = (d);\
 | 
			
		||||
	BN_CP_32_FROM_BUF(td,a7); BN_CP_32_FROM_BUF(td,a6);\
 | 
			
		||||
	BN_CP_32_FROM_BUF(td,a5); BN_CP_32_FROM_BUF(td,a4);\
 | 
			
		||||
	BN_CP_32_FROM_BUF(td,a3); BN_CP_32_FROM_BUF(td,a2);\
 | 
			
		||||
	BN_CP_32_FROM_BUF(td,a1);\
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
 | 
			
		||||
	BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
#ifndef NO_32_BIT_TYPE
 | 
			
		||||
	int	tmp_int;
 | 
			
		||||
	int	carry = 0;
 | 
			
		||||
	BN_ULONG *r_d, *a_d;
 | 
			
		||||
	BN_ULONG t_d[BN_NIST_224_TOP];
 | 
			
		||||
	BN_32_BIT_BUF(7)  BN_32_BIT_BUF(8)
 | 
			
		||||
	BN_32_BIT_BUF(9)  BN_32_BIT_BUF(10)
 | 
			
		||||
	BN_32_BIT_BUF(11) BN_32_BIT_BUF(12)
 | 
			
		||||
	BN_32_BIT_BUF(13)
 | 
			
		||||
 | 
			
		||||
	tmp_int = BN_ucmp(field, a);
 | 
			
		||||
	if (tmp_int == 0)
 | 
			
		||||
		return BN_zero(r);
 | 
			
		||||
	else if (tmp_int > 0)
 | 
			
		||||
		return (r == a)? 1 : (BN_copy(r ,a) != NULL);
 | 
			
		||||
 | 
			
		||||
	if (r != a)
 | 
			
		||||
		if (!BN_ncopy(r, a, BN_NIST_224_TOP))
 | 
			
		||||
			return 0;
 | 
			
		||||
 | 
			
		||||
	r_d = r->d;
 | 
			
		||||
	a_d = a->d;
 | 
			
		||||
 | 
			
		||||
	tmp_int = a->top-1;
 | 
			
		||||
 | 
			
		||||
	switch (tmp_int)
 | 
			
		||||
		{
 | 
			
		||||
		BN_CASE_32_BIT(13, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(12, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(11, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(10, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(9,  a_d)
 | 
			
		||||
		BN_CASE_32_BIT(8,  a_d)
 | 
			
		||||
		BN_CASE_32_BIT(7,  a_d)
 | 
			
		||||
			break;
 | 
			
		||||
		default: /* a->top == field->top */
 | 
			
		||||
			return BN_usub(r, a, field);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	BN_224_SET(t_d,10,9,8,7,0,0,0)
 | 
			
		||||
	if (bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP))
 | 
			
		||||
		++carry;
 | 
			
		||||
	BN_224_SET(t_d,0,13,12,11,0,0,0)
 | 
			
		||||
	if (bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP))
 | 
			
		||||
		++carry;
 | 
			
		||||
	BN_224_SET(t_d,13,12,11,10,9,8,7)
 | 
			
		||||
	if (bn_sub_words(r_d, r_d, t_d, BN_NIST_224_TOP))
 | 
			
		||||
		--carry;
 | 
			
		||||
	BN_224_SET(t_d,0,0,0,0,13,12,11)
 | 
			
		||||
	if (bn_sub_words(r_d, r_d, t_d, BN_NIST_224_TOP))
 | 
			
		||||
		--carry;
 | 
			
		||||
 | 
			
		||||
	if (carry > 0)
 | 
			
		||||
		while (carry)
 | 
			
		||||
			{
 | 
			
		||||
			if (bn_sub_words(r_d,r_d,_nist_p_224,BN_NIST_224_TOP))
 | 
			
		||||
				--carry;
 | 
			
		||||
			}
 | 
			
		||||
	else if (carry < 0)
 | 
			
		||||
		while (carry)
 | 
			
		||||
			{
 | 
			
		||||
			if (bn_add_words(r_d,r_d,_nist_p_224,BN_NIST_224_TOP))
 | 
			
		||||
				++carry;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
	r->top = BN_NIST_224_TOP;
 | 
			
		||||
#if 1
 | 
			
		||||
	bn_clear_top2max(r);
 | 
			
		||||
#endif
 | 
			
		||||
	bn_fix_top(r);
 | 
			
		||||
 | 
			
		||||
	if (BN_ucmp(r, field) >= 0)
 | 
			
		||||
		{
 | 
			
		||||
		bn_sub_words(r_d, r_d, _nist_p_224, BN_NIST_224_TOP);
 | 
			
		||||
		bn_fix_top(r);
 | 
			
		||||
		}
 | 
			
		||||
	return 1;
 | 
			
		||||
#else
 | 
			
		||||
	return 0;
 | 
			
		||||
#endif
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static void _init_256_data(void)
 | 
			
		||||
	{
 | 
			
		||||
	int	i;
 | 
			
		||||
	BN_ULONG *tmp1 = _256_data;
 | 
			
		||||
	const BN_ULONG *tmp2 = tmp1;
 | 
			
		||||
 | 
			
		||||
	memcpy(tmp1, _nist_p_256, BN_NIST_256_TOP * sizeof(BN_ULONG));
 | 
			
		||||
	tmp1 += BN_NIST_256_TOP;
 | 
			
		||||
 | 
			
		||||
	for (i=0; i<5; i++)
 | 
			
		||||
		{
 | 
			
		||||
		bn_add_words(tmp1, _nist_p_256, tmp2, BN_NIST_256_TOP);
 | 
			
		||||
		tmp2  = tmp1;
 | 
			
		||||
		tmp1 += BN_NIST_256_TOP;
 | 
			
		||||
		}
 | 
			
		||||
	_is_set_256_data = 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
#define BN_256_SET(d,a1,a2,a3,a4,a5,a6,a7,a8) \
 | 
			
		||||
	{\
 | 
			
		||||
	register BN_ULONG *td = (d);\
 | 
			
		||||
	BN_CP_32_FROM_BUF(td,a8); BN_CP_32_FROM_BUF(td,a7);\
 | 
			
		||||
	BN_CP_32_FROM_BUF(td,a6); BN_CP_32_FROM_BUF(td,a5);\
 | 
			
		||||
	BN_CP_32_FROM_BUF(td,a4); BN_CP_32_FROM_BUF(td,a3);\
 | 
			
		||||
	BN_CP_32_FROM_BUF(td,a2); BN_CP_32_FROM_BUF(td,a1);\
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
 | 
			
		||||
	BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
#ifndef NO_32_BIT_TYPE
 | 
			
		||||
	int	tmp_int;
 | 
			
		||||
	int	carry = 0;
 | 
			
		||||
	register BN_ULONG *a_d, *r_d;
 | 
			
		||||
	BN_ULONG t_d[BN_NIST_256_TOP];
 | 
			
		||||
	BN_ULONG t_d2[BN_NIST_256_TOP];
 | 
			
		||||
	BN_32_BIT_BUF(8)  BN_32_BIT_BUF(9)
 | 
			
		||||
	BN_32_BIT_BUF(10) BN_32_BIT_BUF(11)
 | 
			
		||||
	BN_32_BIT_BUF(12) BN_32_BIT_BUF(13)
 | 
			
		||||
	BN_32_BIT_BUF(14) BN_32_BIT_BUF(15)
 | 
			
		||||
 | 
			
		||||
	if (!_is_set_256_data)
 | 
			
		||||
		{
 | 
			
		||||
		CRYPTO_w_lock(CRYPTO_LOCK_BN);
 | 
			
		||||
		
 | 
			
		||||
		if (!_is_set_256_data)
 | 
			
		||||
			_init_256_data();
 | 
			
		||||
		
 | 
			
		||||
		CRYPTO_w_unlock(CRYPTO_LOCK_BN);
 | 
			
		||||
		}
 | 
			
		||||
	
 | 
			
		||||
	tmp_int = BN_ucmp(field, a);
 | 
			
		||||
	if (tmp_int == 0)
 | 
			
		||||
		return BN_zero(r);
 | 
			
		||||
	else if (tmp_int > 0)
 | 
			
		||||
		return (r == a)? 1 : (BN_copy(r ,a) != NULL);
 | 
			
		||||
 | 
			
		||||
	if (r != a)
 | 
			
		||||
		if (!BN_ncopy(r, a, BN_NIST_256_TOP))
 | 
			
		||||
			return 0;
 | 
			
		||||
 | 
			
		||||
	tmp_int = a->top-1;
 | 
			
		||||
 | 
			
		||||
	a_d = a->d;
 | 
			
		||||
	r_d = r->d;
 | 
			
		||||
	switch (tmp_int)
 | 
			
		||||
		{
 | 
			
		||||
		BN_CASE_32_BIT(15, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(14, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(13, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(12, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(11, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(10, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(9,  a_d)
 | 
			
		||||
		BN_CASE_32_BIT(8,  a_d)
 | 
			
		||||
			break;
 | 
			
		||||
		default: /* a->top == field->top */
 | 
			
		||||
			return BN_usub(r, a, field);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	/*S1*/
 | 
			
		||||
	BN_256_SET(t_d,15,14,13,12,11,0,0,0)
 | 
			
		||||
	/*S2*/
 | 
			
		||||
	BN_256_SET(t_d2,0,15,14,13,12,0,0,0)
 | 
			
		||||
	if (bn_add_words(t_d, t_d, t_d2, BN_NIST_256_TOP))
 | 
			
		||||
		carry = 2;
 | 
			
		||||
	/* left shift */
 | 
			
		||||
		{
 | 
			
		||||
		register BN_ULONG *ap,t,c;
 | 
			
		||||
		ap = t_d;
 | 
			
		||||
		c=0;
 | 
			
		||||
		for (tmp_int=BN_NIST_256_TOP; tmp_int != 0; --tmp_int)
 | 
			
		||||
			{
 | 
			
		||||
			t= *ap;
 | 
			
		||||
			*(ap++)=((t<<1)|c)&BN_MASK2;
 | 
			
		||||
			c=(t & BN_TBIT)?1:0;
 | 
			
		||||
			}
 | 
			
		||||
		if (c)
 | 
			
		||||
			++carry;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP))
 | 
			
		||||
		++carry;
 | 
			
		||||
	/*S3*/
 | 
			
		||||
	BN_256_SET(t_d,15,14,0,0,0,10,9,8)
 | 
			
		||||
	if (bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP))
 | 
			
		||||
		++carry;
 | 
			
		||||
	/*S4*/
 | 
			
		||||
	BN_256_SET(t_d,8,13,15,14,13,11,10,9)
 | 
			
		||||
	if (bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP))
 | 
			
		||||
		++carry;
 | 
			
		||||
	/*D1*/
 | 
			
		||||
	BN_256_SET(t_d,10,8,0,0,0,13,12,11)
 | 
			
		||||
	if (bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP))
 | 
			
		||||
		--carry;
 | 
			
		||||
	/*D2*/
 | 
			
		||||
	BN_256_SET(t_d,11,9,0,0,15,14,13,12)
 | 
			
		||||
	if (bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP))
 | 
			
		||||
		--carry;
 | 
			
		||||
	/*D3*/
 | 
			
		||||
	BN_256_SET(t_d,12,0,10,9,8,15,14,13)
 | 
			
		||||
	if (bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP))
 | 
			
		||||
		--carry;
 | 
			
		||||
	/*D4*/
 | 
			
		||||
	BN_256_SET(t_d,13,0,11,10,9,0,15,14)
 | 
			
		||||
	if (bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP))
 | 
			
		||||
		--carry;
 | 
			
		||||
	
 | 
			
		||||
	if (carry)
 | 
			
		||||
		{
 | 
			
		||||
		if (carry > 0)
 | 
			
		||||
			bn_sub_words(r_d, r_d, _256_data + BN_NIST_256_TOP *
 | 
			
		||||
				--carry, BN_NIST_256_TOP);
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			carry = -carry;
 | 
			
		||||
			bn_add_words(r_d, r_d, _256_data + BN_NIST_256_TOP *
 | 
			
		||||
				--carry, BN_NIST_256_TOP);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	r->top = BN_NIST_256_TOP;
 | 
			
		||||
#if 1
 | 
			
		||||
	bn_clear_top2max(r);
 | 
			
		||||
#endif
 | 
			
		||||
	bn_fix_top(r);
 | 
			
		||||
 | 
			
		||||
	if (BN_ucmp(r, field) >= 0)
 | 
			
		||||
		{
 | 
			
		||||
		bn_sub_words(r_d, r_d, _nist_p_256, BN_NIST_256_TOP);
 | 
			
		||||
		bn_fix_top(r);
 | 
			
		||||
		}
 | 
			
		||||
	return 1;
 | 
			
		||||
#else
 | 
			
		||||
	return 0;
 | 
			
		||||
#endif
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
static void _init_384_data(void)
 | 
			
		||||
	{
 | 
			
		||||
	int	i;
 | 
			
		||||
	BN_ULONG *tmp1 = _384_data;
 | 
			
		||||
	const BN_ULONG *tmp2 = tmp1;
 | 
			
		||||
 | 
			
		||||
	memcpy(tmp1, _nist_p_384, BN_NIST_384_TOP * sizeof(BN_ULONG));
 | 
			
		||||
	tmp1 += BN_NIST_384_TOP;
 | 
			
		||||
 | 
			
		||||
	for (i=0; i<7; i++)
 | 
			
		||||
		{
 | 
			
		||||
		bn_add_words(tmp1, _nist_p_384, tmp2, BN_NIST_384_TOP);
 | 
			
		||||
		tmp2  = tmp1;
 | 
			
		||||
		tmp1 += BN_NIST_384_TOP;
 | 
			
		||||
		}
 | 
			
		||||
	_is_set_384_data = 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
#define BN_384_SET(d,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \
 | 
			
		||||
	{\
 | 
			
		||||
	register BN_ULONG *td = (d);\
 | 
			
		||||
	BN_CP_32_FROM_BUF(td,a12); BN_CP_32_FROM_BUF(td,a11);\
 | 
			
		||||
	BN_CP_32_FROM_BUF(td,a10); BN_CP_32_FROM_BUF(td,a9);\
 | 
			
		||||
	BN_CP_32_FROM_BUF(td,a8);  BN_CP_32_FROM_BUF(td,a7);\
 | 
			
		||||
	BN_CP_32_FROM_BUF(td,a6);  BN_CP_32_FROM_BUF(td,a5);\
 | 
			
		||||
	BN_CP_32_FROM_BUF(td,a4);  BN_CP_32_FROM_BUF(td,a3);\
 | 
			
		||||
	BN_CP_32_FROM_BUF(td,a2);  BN_CP_32_FROM_BUF(td,a1);\
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
 | 
			
		||||
	BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
#ifndef NO_32_BIT_TYPE
 | 
			
		||||
	int	tmp_int;
 | 
			
		||||
	int	carry = 0;
 | 
			
		||||
	register BN_ULONG *r_d, *a_d;
 | 
			
		||||
	BN_ULONG t_d[BN_NIST_384_TOP];
 | 
			
		||||
	BN_32_BIT_BUF(12) BN_32_BIT_BUF(13)
 | 
			
		||||
	BN_32_BIT_BUF(14) BN_32_BIT_BUF(15)
 | 
			
		||||
	BN_32_BIT_BUF(16) BN_32_BIT_BUF(17)
 | 
			
		||||
	BN_32_BIT_BUF(18) BN_32_BIT_BUF(19)
 | 
			
		||||
	BN_32_BIT_BUF(20) BN_32_BIT_BUF(21)
 | 
			
		||||
	BN_32_BIT_BUF(22) BN_32_BIT_BUF(23)
 | 
			
		||||
 | 
			
		||||
	if (!_is_set_384_data)
 | 
			
		||||
		{
 | 
			
		||||
		CRYPTO_w_lock(CRYPTO_LOCK_BN);
 | 
			
		||||
		
 | 
			
		||||
		if (!_is_set_384_data)
 | 
			
		||||
			_init_384_data();
 | 
			
		||||
 | 
			
		||||
		CRYPTO_w_unlock(CRYPTO_LOCK_BN);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	tmp_int = BN_ucmp(field, a);
 | 
			
		||||
	if (tmp_int == 0)
 | 
			
		||||
		return BN_zero(r);
 | 
			
		||||
	else if (tmp_int > 0)
 | 
			
		||||
		return (r == a)? 1 : (BN_copy(r ,a) != NULL);
 | 
			
		||||
 | 
			
		||||
	if (r != a)
 | 
			
		||||
		if (!BN_ncopy(r, a, BN_NIST_384_TOP))
 | 
			
		||||
			return 0;
 | 
			
		||||
 | 
			
		||||
	r_d = r->d;
 | 
			
		||||
	a_d = a->d;
 | 
			
		||||
	tmp_int = a->top-1;
 | 
			
		||||
 | 
			
		||||
	switch (tmp_int)
 | 
			
		||||
		{
 | 
			
		||||
		BN_CASE_32_BIT(23, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(22, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(21, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(20, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(19, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(18, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(17, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(16, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(15, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(14, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(13, a_d)
 | 
			
		||||
		BN_CASE_32_BIT(12, a_d)
 | 
			
		||||
			break;
 | 
			
		||||
		default: /* a->top == field->top */
 | 
			
		||||
			return BN_usub(r, a, field);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	/*S1*/
 | 
			
		||||
	BN_256_SET(t_d,0,0,0,0,0,23,22,21)
 | 
			
		||||
		/* left shift */
 | 
			
		||||
		{
 | 
			
		||||
		register BN_ULONG *ap,t,c;
 | 
			
		||||
		ap = t_d;
 | 
			
		||||
		c=0;
 | 
			
		||||
		for (tmp_int=BN_NIST_256_TOP; tmp_int != 0; --tmp_int)
 | 
			
		||||
			{
 | 
			
		||||
			t= *ap;
 | 
			
		||||
			*(ap++)=((t<<1)|c)&BN_MASK2;
 | 
			
		||||
			c=(t & BN_TBIT)?1:0;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	if (bn_add_words(r_d+(128/BN_BITS2), r_d+(128/BN_BITS2), 
 | 
			
		||||
		t_d, BN_NIST_256_TOP))
 | 
			
		||||
		++carry;
 | 
			
		||||
	/*S2*/
 | 
			
		||||
	BN_384_SET(t_d,23,22,21,20,19,18,17,16,15,14,13,12)
 | 
			
		||||
	if (bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP))
 | 
			
		||||
		++carry;
 | 
			
		||||
	/*S3*/
 | 
			
		||||
	BN_384_SET(t_d,20,19,18,17,16,15,14,13,12,23,22,21)
 | 
			
		||||
	if (bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP))
 | 
			
		||||
		++carry;
 | 
			
		||||
	/*S4*/
 | 
			
		||||
	BN_384_SET(t_d,19,18,17,16,15,14,13,12,20,0,23,0)
 | 
			
		||||
	if (bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP))
 | 
			
		||||
		++carry;
 | 
			
		||||
	/*S5*/
 | 
			
		||||
	BN_256_SET(t_d,0,0,0,0,23,22,21,20)
 | 
			
		||||
	if (bn_add_words(r_d+(128/BN_BITS2), r_d+(128/BN_BITS2), 
 | 
			
		||||
		t_d, BN_NIST_256_TOP))
 | 
			
		||||
		++carry;
 | 
			
		||||
	/*S6*/
 | 
			
		||||
	BN_384_SET(t_d,0,0,0,0,0,0,23,22,21,0,0,20)
 | 
			
		||||
	if (bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP))
 | 
			
		||||
		++carry;
 | 
			
		||||
	/*D1*/
 | 
			
		||||
	BN_384_SET(t_d,22,21,20,19,18,17,16,15,14,13,12,23)
 | 
			
		||||
	if (bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP))
 | 
			
		||||
		--carry;
 | 
			
		||||
	/*D2*/
 | 
			
		||||
	BN_384_SET(t_d,0,0,0,0,0,0,0,23,22,21,20,0)
 | 
			
		||||
	if (bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP))
 | 
			
		||||
		--carry;
 | 
			
		||||
	/*D3*/
 | 
			
		||||
	BN_384_SET(t_d,0,0,0,0,0,0,0,23,23,0,0,0)
 | 
			
		||||
	if (bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP))
 | 
			
		||||
		--carry;
 | 
			
		||||
	
 | 
			
		||||
	if (carry)
 | 
			
		||||
		{
 | 
			
		||||
		if (carry > 0)
 | 
			
		||||
			bn_sub_words(r_d, r_d, _384_data + BN_NIST_384_TOP *
 | 
			
		||||
				--carry, BN_NIST_384_TOP);
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			carry = -carry;
 | 
			
		||||
			bn_add_words(r_d, r_d, _384_data + BN_NIST_384_TOP *
 | 
			
		||||
				--carry, BN_NIST_384_TOP);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	r->top = BN_NIST_384_TOP;
 | 
			
		||||
#if 1
 | 
			
		||||
	bn_clear_top2max(r);
 | 
			
		||||
#endif
 | 
			
		||||
	bn_fix_top(r);
 | 
			
		||||
 | 
			
		||||
	if (BN_ucmp(r, field) >= 0)
 | 
			
		||||
		{
 | 
			
		||||
		bn_sub_words(r_d, r_d, _nist_p_384, BN_NIST_384_TOP);
 | 
			
		||||
		bn_fix_top(r);
 | 
			
		||||
		}
 | 
			
		||||
	return 1;
 | 
			
		||||
#else
 | 
			
		||||
	return 0;
 | 
			
		||||
#endif
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
 | 
			
		||||
	BN_CTX *ctx)
 | 
			
		||||
	{
 | 
			
		||||
#if BN_BITS2 == 64
 | 
			
		||||
#define BN_NIST_521_TOP_MASK	(BN_ULONG)0x1FF
 | 
			
		||||
#elif BN_BITS2 == 32
 | 
			
		||||
#define BN_NIST_521_TOP_MASK	(BN_ULONG)0x1FF
 | 
			
		||||
#elif BN_BITS2 == 16
 | 
			
		||||
#define BN_NIST_521_TOP_MASK	(BN_ULONG)0x1FF
 | 
			
		||||
#elif BN_BITS2 == 8
 | 
			
		||||
#define BN_NIST_521_TOP_MASK	(BN_ULONG)0x1
 | 
			
		||||
#endif
 | 
			
		||||
	int	top, ret = 0;
 | 
			
		||||
	BN_ULONG *r_d;
 | 
			
		||||
	BIGNUM	*tmp;
 | 
			
		||||
 | 
			
		||||
	/* check whether a reduction is necessary */
 | 
			
		||||
	top = a->top;
 | 
			
		||||
	if (top < BN_NIST_521_TOP  || ( top == BN_NIST_521_TOP &&
 | 
			
		||||
           (!(a->d[BN_NIST_521_TOP-1] & ~(BN_NIST_521_TOP_MASK)))))
 | 
			
		||||
		return (r == a)? 1 : (BN_copy(r ,a) != NULL);
 | 
			
		||||
 | 
			
		||||
	BN_CTX_start(ctx);
 | 
			
		||||
	tmp = BN_CTX_get(ctx);
 | 
			
		||||
	if (!tmp)
 | 
			
		||||
		goto err;
 | 
			
		||||
 | 
			
		||||
	if (!BN_ncopy(tmp, a, BN_NIST_521_TOP))
 | 
			
		||||
		return 0;
 | 
			
		||||
	if (!BN_rshift(r, a, 521))
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	if (tmp->top == BN_NIST_521_TOP)
 | 
			
		||||
		tmp->d[BN_NIST_521_TOP-1]  &= BN_NIST_521_TOP_MASK;
 | 
			
		||||
 | 
			
		||||
	if (!BN_uadd(r, tmp, r))
 | 
			
		||||
		return 0;
 | 
			
		||||
	top = r->top;
 | 
			
		||||
	r_d = r->d;
 | 
			
		||||
	if (top == BN_NIST_521_TOP  && 
 | 
			
		||||
           (r_d[BN_NIST_521_TOP-1] & ~(BN_NIST_521_TOP_MASK)))
 | 
			
		||||
		{
 | 
			
		||||
		BN_NIST_ADD_ONE(r_d)
 | 
			
		||||
		r_d[BN_NIST_521_TOP-1] &= BN_NIST_521_TOP_MASK; 
 | 
			
		||||
		}
 | 
			
		||||
	bn_fix_top(r);
 | 
			
		||||
 | 
			
		||||
	ret = 1;
 | 
			
		||||
err:
 | 
			
		||||
	BN_CTX_end(ctx);
 | 
			
		||||
	
 | 
			
		||||
	return ret;
 | 
			
		||||
	}
 | 
			
		||||
@@ -115,11 +115,6 @@
 | 
			
		||||
#include "bn_lcl.h"
 | 
			
		||||
#include <openssl/rand.h>
 | 
			
		||||
 | 
			
		||||
/* NB: these functions have been "upgraded", the deprecated versions (which are
 | 
			
		||||
 * compatibility wrappers using these functions) are in bn_depr.c.
 | 
			
		||||
 * - Geoff
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* The quick sieve algorithm approach to weeding out primes is
 | 
			
		||||
 * Philip Zimmermann's, as implemented in PGP.  I have had a read of
 | 
			
		||||
 * his comments and implemented my own version.
 | 
			
		||||
@@ -134,31 +129,11 @@ static int probable_prime_dh(BIGNUM *rnd, int bits,
 | 
			
		||||
static int probable_prime_dh_safe(BIGNUM *rnd, int bits,
 | 
			
		||||
	const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx);
 | 
			
		||||
 | 
			
		||||
int BN_GENCB_call(BN_GENCB *cb, int a, int b)
 | 
			
		||||
	{
 | 
			
		||||
	/* No callback means continue */
 | 
			
		||||
	if(!cb) return 1;
 | 
			
		||||
	switch(cb->ver)
 | 
			
		||||
		{
 | 
			
		||||
	case 1:
 | 
			
		||||
		/* Deprecated-style callbacks */
 | 
			
		||||
		if(!cb->cb.cb_1)
 | 
			
		||||
			return 1;
 | 
			
		||||
		cb->cb.cb_1(a, b, cb->arg);
 | 
			
		||||
		return 1;
 | 
			
		||||
	case 2:
 | 
			
		||||
		/* New-style callbacks */
 | 
			
		||||
		return cb->cb.cb_2(a, b, cb);
 | 
			
		||||
	default:
 | 
			
		||||
		break;
 | 
			
		||||
		}
 | 
			
		||||
	/* Unrecognised callback type */
 | 
			
		||||
	return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
 | 
			
		||||
	const BIGNUM *add, const BIGNUM *rem, BN_GENCB *cb)
 | 
			
		||||
BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
 | 
			
		||||
	const BIGNUM *add, const BIGNUM *rem,
 | 
			
		||||
	void (*callback)(int,int,void *), void *cb_arg)
 | 
			
		||||
	{
 | 
			
		||||
	BIGNUM *rnd=NULL;
 | 
			
		||||
	BIGNUM t;
 | 
			
		||||
	int found=0;
 | 
			
		||||
	int i,j,c1=0;
 | 
			
		||||
@@ -168,33 +143,37 @@ int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
 | 
			
		||||
	BN_init(&t);
 | 
			
		||||
	ctx=BN_CTX_new();
 | 
			
		||||
	if (ctx == NULL) goto err;
 | 
			
		||||
	if (ret == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		if ((rnd=BN_new()) == NULL) goto err;
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		rnd=ret;
 | 
			
		||||
loop: 
 | 
			
		||||
	/* make a random number and set the top and bottom bits */
 | 
			
		||||
	if (add == NULL)
 | 
			
		||||
		{
 | 
			
		||||
		if (!probable_prime(ret,bits)) goto err;
 | 
			
		||||
		if (!probable_prime(rnd,bits)) goto err;
 | 
			
		||||
		}
 | 
			
		||||
	else
 | 
			
		||||
		{
 | 
			
		||||
		if (safe)
 | 
			
		||||
			{
 | 
			
		||||
			if (!probable_prime_dh_safe(ret,bits,add,rem,ctx))
 | 
			
		||||
			if (!probable_prime_dh_safe(rnd,bits,add,rem,ctx))
 | 
			
		||||
				 goto err;
 | 
			
		||||
			}
 | 
			
		||||
		else
 | 
			
		||||
			{
 | 
			
		||||
			if (!probable_prime_dh(ret,bits,add,rem,ctx))
 | 
			
		||||
			if (!probable_prime_dh(rnd,bits,add,rem,ctx))
 | 
			
		||||
				goto err;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	/* if (BN_mod_word(ret,(BN_ULONG)3) == 1) goto loop; */
 | 
			
		||||
	if(!BN_GENCB_call(cb, 0, c1++))
 | 
			
		||||
		/* aborted */
 | 
			
		||||
		goto err;
 | 
			
		||||
	/* if (BN_mod_word(rnd,(BN_ULONG)3) == 1) goto loop; */
 | 
			
		||||
	if (callback != NULL) callback(0,c1++,cb_arg);
 | 
			
		||||
 | 
			
		||||
	if (!safe)
 | 
			
		||||
		{
 | 
			
		||||
		i=BN_is_prime_fasttest_ex(ret,checks,ctx,0,cb);
 | 
			
		||||
		i=BN_is_prime_fasttest(rnd,checks,callback,ctx,cb_arg,0);
 | 
			
		||||
		if (i == -1) goto err;
 | 
			
		||||
		if (i == 0) goto loop;
 | 
			
		||||
		}
 | 
			
		||||
@@ -204,38 +183,41 @@ loop:
 | 
			
		||||
		 * check that (p-1)/2 is prime.
 | 
			
		||||
		 * Since a prime is odd, We just
 | 
			
		||||
		 * need to divide by 2 */
 | 
			
		||||
		if (!BN_rshift1(&t,ret)) goto err;
 | 
			
		||||
		if (!BN_rshift1(&t,rnd)) goto err;
 | 
			
		||||
 | 
			
		||||
		for (i=0; i<checks; i++)
 | 
			
		||||
			{
 | 
			
		||||
			j=BN_is_prime_fasttest_ex(ret,1,ctx,0,cb);
 | 
			
		||||
			j=BN_is_prime_fasttest(rnd,1,callback,ctx,cb_arg,0);
 | 
			
		||||
			if (j == -1) goto err;
 | 
			
		||||
			if (j == 0) goto loop;
 | 
			
		||||
 | 
			
		||||
			j=BN_is_prime_fasttest_ex(&t,1,ctx,0,cb);
 | 
			
		||||
			j=BN_is_prime_fasttest(&t,1,callback,ctx,cb_arg,0);
 | 
			
		||||
			if (j == -1) goto err;
 | 
			
		||||
			if (j == 0) goto loop;
 | 
			
		||||
 | 
			
		||||
			if(!BN_GENCB_call(cb, 2, c1-1))
 | 
			
		||||
				goto err;
 | 
			
		||||
			if (callback != NULL) callback(2,c1-1,cb_arg);
 | 
			
		||||
			/* We have a safe prime test pass */
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	/* we have a prime :-) */
 | 
			
		||||
	found = 1;
 | 
			
		||||
err:
 | 
			
		||||
	if (!found && (ret == NULL) && (rnd != NULL)) BN_free(rnd);
 | 
			
		||||
	BN_free(&t);
 | 
			
		||||
	if (ctx != NULL) BN_CTX_free(ctx);
 | 
			
		||||
	return found;
 | 
			
		||||
	return(found ? rnd : NULL);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int BN_is_prime_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, BN_GENCB *cb)
 | 
			
		||||
int BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int,int,void *),
 | 
			
		||||
	BN_CTX *ctx_passed, void *cb_arg)
 | 
			
		||||
	{
 | 
			
		||||
	return BN_is_prime_fasttest_ex(a, checks, ctx_passed, 0, cb);
 | 
			
		||||
	return BN_is_prime_fasttest(a, checks, callback, ctx_passed, cb_arg, 0);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed,
 | 
			
		||||
		int do_trial_division, BN_GENCB *cb)
 | 
			
		||||
int BN_is_prime_fasttest(const BIGNUM *a, int checks,
 | 
			
		||||
		void (*callback)(int,int,void *),
 | 
			
		||||
		BN_CTX *ctx_passed, void *cb_arg,
 | 
			
		||||
		int do_trial_division)
 | 
			
		||||
	{
 | 
			
		||||
	int i, j, ret = -1;
 | 
			
		||||
	int k;
 | 
			
		||||
@@ -258,8 +240,7 @@ int BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed,
 | 
			
		||||
		for (i = 1; i < NUMPRIMES; i++)
 | 
			
		||||
			if (BN_mod_word(a, primes[i]) == 0) 
 | 
			
		||||
				return 0;
 | 
			
		||||
		if(!BN_GENCB_call(cb, 1, -1))
 | 
			
		||||
			goto err;
 | 
			
		||||
		if (callback != NULL) callback(1, -1, cb_arg);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	if (ctx_passed != NULL)
 | 
			
		||||
@@ -325,8 +306,7 @@ int BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed,
 | 
			
		||||
			ret=0;
 | 
			
		||||
			goto err;
 | 
			
		||||
			}
 | 
			
		||||
		if(!BN_GENCB_call(cb, 1, i))
 | 
			
		||||
			goto err;
 | 
			
		||||
		if (callback != NULL) callback(1,i,cb_arg);
 | 
			
		||||
		}
 | 
			
		||||
	ret=1;
 | 
			
		||||
err:
 | 
			
		||||
 
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user