Showing
20 changed files
with
611 additions
and
34 deletions
CMakeLists.txt
0 → 100644
1 | -test : clean test.o | ||
2 | - ./test/bin/test.o > report.xml | ||
3 | -test.o : | ||
4 | - gcc test/src/test.c -L/usr/local/opt/openssl/lib -o test/bin/test.o -lcmocka -lssl -lcrypto | ||
5 | -pull : | ||
6 | - cd lib; \ | ||
7 | - git clone https://github.com/openssl/openssl.git; \ | ||
8 | - ./config --prefix= | ||
9 | - | ||
10 | - | ||
11 | -clean : | ||
12 | - rm -f ~/test/bin/test.o report.xml | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +# CMAKE generated file: DO NOT EDIT! | ||
2 | +# Generated by "Unix Makefiles" Generator, CMake Version 3.12 | ||
3 | + | ||
4 | +# Default target executed when no arguments are given to make. | ||
5 | +default_target: all | ||
6 | + | ||
7 | +.PHONY : default_target | ||
8 | + | ||
9 | +# Allow only one "make -f Makefile2" at a time, but pass parallelism. | ||
10 | +.NOTPARALLEL: | ||
11 | + | ||
12 | + | ||
13 | +#============================================================================= | ||
14 | +# Special targets provided by cmake. | ||
15 | + | ||
16 | +# Disable implicit rules so canonical targets will work. | ||
17 | +.SUFFIXES: | ||
18 | + | ||
19 | + | ||
20 | +# Remove some rules from gmake that .SUFFIXES does not remove. | ||
21 | +SUFFIXES = | ||
22 | + | ||
23 | +.SUFFIXES: .hpux_make_needs_suffix_list | ||
24 | + | ||
25 | + | ||
26 | +# Suppress display of executed commands. | ||
27 | +$(VERBOSE).SILENT: | ||
28 | + | ||
29 | + | ||
30 | +# A target that is always out of date. | ||
31 | +cmake_force: | ||
32 | + | ||
33 | +.PHONY : cmake_force | ||
34 | + | ||
35 | +#============================================================================= | ||
36 | +# Set environment variables for the build. | ||
37 | + | ||
38 | +# The shell in which to execute make rules. | ||
39 | +SHELL = /bin/sh | ||
40 | + | ||
41 | +# The CMake executable. | ||
42 | +CMAKE_COMMAND = /Applications/CMake.app/Contents/bin/cmake | ||
43 | + | ||
44 | +# The command to remove a file. | ||
45 | +RM = /Applications/CMake.app/Contents/bin/cmake -E remove -f | ||
46 | + | ||
47 | +# Escaping for special characters. | ||
48 | +EQUALS = = | ||
49 | + | ||
50 | +# The top-level source directory on which CMake was run. | ||
51 | +CMAKE_SOURCE_DIR = /Users/ganghyeontae/crypto-optimization | ||
52 | + | ||
53 | +# The top-level build directory on which CMake was run. | ||
54 | +CMAKE_BINARY_DIR = /Users/ganghyeontae/crypto-optimization | ||
55 | + | ||
56 | +#============================================================================= | ||
57 | +# Targets provided globally by CMake. | ||
58 | + | ||
59 | +# Special rule for the target rebuild_cache | ||
60 | +rebuild_cache: | ||
61 | + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." | ||
62 | + /Applications/CMake.app/Contents/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) | ||
63 | +.PHONY : rebuild_cache | ||
64 | + | ||
65 | +# Special rule for the target rebuild_cache | ||
66 | +rebuild_cache/fast: rebuild_cache | ||
67 | + | ||
68 | +.PHONY : rebuild_cache/fast | ||
69 | + | ||
70 | +# Special rule for the target edit_cache | ||
71 | +edit_cache: | ||
72 | + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..." | ||
73 | + /Applications/CMake.app/Contents/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) | ||
74 | +.PHONY : edit_cache | ||
75 | + | ||
76 | +# Special rule for the target edit_cache | ||
77 | +edit_cache/fast: edit_cache | ||
78 | + | ||
79 | +.PHONY : edit_cache/fast | ||
80 | + | ||
81 | +# The main all target | ||
82 | +all: cmake_check_build_system | ||
83 | + $(CMAKE_COMMAND) -E cmake_progress_start /Users/ganghyeontae/crypto-optimization/CMakeFiles /Users/ganghyeontae/crypto-optimization/CMakeFiles/progress.marks | ||
84 | + $(MAKE) -f CMakeFiles/Makefile2 all | ||
85 | + $(CMAKE_COMMAND) -E cmake_progress_start /Users/ganghyeontae/crypto-optimization/CMakeFiles 0 | ||
86 | +.PHONY : all | ||
87 | + | ||
88 | +# The main clean target | ||
89 | +clean: | ||
90 | + $(MAKE) -f CMakeFiles/Makefile2 clean | ||
91 | +.PHONY : clean | ||
92 | + | ||
93 | +# The main clean target | ||
94 | +clean/fast: clean | ||
95 | + | ||
96 | +.PHONY : clean/fast | ||
97 | + | ||
98 | +# Prepare targets for installation. | ||
99 | +preinstall: all | ||
100 | + $(MAKE) -f CMakeFiles/Makefile2 preinstall | ||
101 | +.PHONY : preinstall | ||
102 | + | ||
103 | +# Prepare targets for installation. | ||
104 | +preinstall/fast: | ||
105 | + $(MAKE) -f CMakeFiles/Makefile2 preinstall | ||
106 | +.PHONY : preinstall/fast | ||
107 | + | ||
108 | +# clear depends | ||
109 | +depend: | ||
110 | + $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 | ||
111 | +.PHONY : depend | ||
112 | + | ||
113 | +#============================================================================= | ||
114 | +# Target rules for targets named MAIN | ||
115 | + | ||
116 | +# Build rule for target. | ||
117 | +MAIN: cmake_check_build_system | ||
118 | + $(MAKE) -f CMakeFiles/Makefile2 MAIN | ||
119 | +.PHONY : MAIN | ||
120 | + | ||
121 | +# fast build rule for target. | ||
122 | +MAIN/fast: | ||
123 | + $(MAKE) -f src/CMakeFiles/MAIN.dir/build.make src/CMakeFiles/MAIN.dir/build | ||
124 | +.PHONY : MAIN/fast | ||
125 | + | ||
126 | +# Help Target | ||
127 | +help: | ||
128 | + @echo "The following are some of the valid targets for this Makefile:" | ||
129 | + @echo "... all (the default if no target is provided)" | ||
130 | + @echo "... clean" | ||
131 | + @echo "... depend" | ||
132 | + @echo "... rebuild_cache" | ||
133 | + @echo "... edit_cache" | ||
134 | + @echo "... MAIN" | ||
135 | +.PHONY : help | ||
136 | + | ||
137 | + | ||
138 | + | ||
139 | +#============================================================================= | ||
140 | +# Special targets to cleanup operation of make. | ||
141 | + | ||
142 | +# Special rule to run CMake to check the build system integrity. | ||
143 | +# No rule that depends on this can have commands that come from listfiles | ||
144 | +# because they might be regenerated. | ||
145 | +cmake_check_build_system: | ||
146 | + $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 | ||
147 | +.PHONY : cmake_check_build_system | ||
148 | + | ... | ... |
buildex.sh
0 → 100644
buildlibs.sh
0 → 100755
1 | +CORE_PATH=${PWD} | ||
2 | +echo ${CORE_PATH} | ||
3 | + | ||
4 | +cd ${CORE_PATH}/src/original | ||
5 | +./Configure linux-generic32 no-shared no-threads no-engine no-hw no-asm no-ssl2 no-ssl3 -DL_ENDIAN --prefix=/Users/ganghyeontae/Downloads --openssldir=/Users/ganghyeontae/Downloads | ||
6 | +make depend | ||
7 | +make install CC=$CC RANLIB=$RANLIB LD=$LD MAKEDEPPROG=$CC PROCESSOR=ARM | ||
8 | + | ||
9 | +cd ${CORE_PATH}/src/optimized | ||
10 | +./Configure linux-generic32 no-shared no-threads no-engine no-hw no-asm no-ssl2 no-ssl3 -DL_ENDIAN --prefix=/Users/ganghyeontae/Downloads --openssldir=/Users/ganghyeontae/Downloads | ||
11 | +make depend | ||
12 | +make install CC=$CC RANLIB=$RANLIB LD=$LD MAKEDEPPROG=$CC PROCESSOR=ARM | ||
13 | + |
configdata.pm
0 → 100755
This diff could not be displayed because it is too large.
crypto/include/internal/bn_conf.h
0 → 100644
1 | +/* WARNING: do not edit! */ | ||
2 | +/* Generated by Makefile from src/original/crypto/include/internal/bn_conf.h.in */ | ||
3 | +/* | ||
4 | + * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. | ||
5 | + * | ||
6 | + * Licensed under the OpenSSL license (the "License"). You may not use | ||
7 | + * this file except in compliance with the License. You can obtain a copy | ||
8 | + * in the file LICENSE in the source distribution or at | ||
9 | + * https://www.openssl.org/source/license.html | ||
10 | + */ | ||
11 | + | ||
12 | +#ifndef HEADER_BN_CONF_H | ||
13 | +# define HEADER_BN_CONF_H | ||
14 | + | ||
15 | +/* | ||
16 | + * The contents of this file are not used in the UEFI build, as | ||
17 | + * both 32-bit and 64-bit builds are supported from a single run | ||
18 | + * of the Configure script. | ||
19 | + */ | ||
20 | + | ||
21 | +/* Should we define BN_DIV2W here? */ | ||
22 | + | ||
23 | +/* Only one for the following should be defined */ | ||
24 | +#undef SIXTY_FOUR_BIT_LONG | ||
25 | +#undef SIXTY_FOUR_BIT | ||
26 | +#define THIRTY_TWO_BIT | ||
27 | + | ||
28 | +#endif |
crypto/include/internal/dso_conf.h
0 → 100644
1 | +/* WARNING: do not edit! */ | ||
2 | +/* Generated by Makefile from src/original/crypto/include/internal/dso_conf.h.in */ | ||
3 | +/* | ||
4 | + * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. | ||
5 | + * | ||
6 | + * Licensed under the OpenSSL license (the "License"). You may not use | ||
7 | + * this file except in compliance with the License. You can obtain a copy | ||
8 | + * in the file LICENSE in the source distribution or at | ||
9 | + * https://www.openssl.org/source/license.html | ||
10 | + */ | ||
11 | + | ||
12 | +#ifndef HEADER_DSO_CONF_H | ||
13 | +# define HEADER_DSO_CONF_H | ||
14 | + | ||
15 | +# define DSO_DLFCN | ||
16 | +# define HAVE_DLFCN_H | ||
17 | +# define DSO_EXTENSION ".so" | ||
18 | + | ||
19 | +#endif |
crypto_optimization.cbp
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<CodeBlocks_project_file> | ||
3 | + <FileVersion major="1" minor="6"/> | ||
4 | + <Project> | ||
5 | + <Option title="crypto_optimization"/> | ||
6 | + <Option makefile_is_custom="1"/> | ||
7 | + <Option compiler="gcc"/> | ||
8 | + <Option virtualFolders="CMake Files\;CMake Files\src\;"/> | ||
9 | + <Build> | ||
10 | + <Target title="all"> | ||
11 | + <Option working_dir="/Users/ganghyeontae/crypto-optimization"/> | ||
12 | + <Option type="4"/> | ||
13 | + <MakeCommands> | ||
14 | + <Build command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/Makefile" VERBOSE=1 all"/> | ||
15 | + <CompileFile command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/Makefile" VERBOSE=1 "$file""/> | ||
16 | + <Clean command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/Makefile" VERBOSE=1 clean"/> | ||
17 | + <DistClean command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/Makefile" VERBOSE=1 clean"/> | ||
18 | + </MakeCommands> | ||
19 | + </Target> | ||
20 | + <Target title="rebuild_cache"> | ||
21 | + <Option working_dir="/Users/ganghyeontae/crypto-optimization"/> | ||
22 | + <Option type="4"/> | ||
23 | + <MakeCommands> | ||
24 | + <Build command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/Makefile" VERBOSE=1 rebuild_cache"/> | ||
25 | + <CompileFile command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/Makefile" VERBOSE=1 "$file""/> | ||
26 | + <Clean command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/Makefile" VERBOSE=1 clean"/> | ||
27 | + <DistClean command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/Makefile" VERBOSE=1 clean"/> | ||
28 | + </MakeCommands> | ||
29 | + </Target> | ||
30 | + <Target title="edit_cache"> | ||
31 | + <Option working_dir="/Users/ganghyeontae/crypto-optimization"/> | ||
32 | + <Option type="4"/> | ||
33 | + <MakeCommands> | ||
34 | + <Build command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/Makefile" VERBOSE=1 edit_cache"/> | ||
35 | + <CompileFile command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/Makefile" VERBOSE=1 "$file""/> | ||
36 | + <Clean command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/Makefile" VERBOSE=1 clean"/> | ||
37 | + <DistClean command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/Makefile" VERBOSE=1 clean"/> | ||
38 | + </MakeCommands> | ||
39 | + </Target> | ||
40 | + <Target title="MAIN"> | ||
41 | + <Option output="/Users/ganghyeontae/crypto-optimization/src/MAIN" prefix_auto="0" extension_auto="0"/> | ||
42 | + <Option working_dir="/Users/ganghyeontae/crypto-optimization/src"/> | ||
43 | + <Option object_output="./"/> | ||
44 | + <Option type="1"/> | ||
45 | + <Option compiler="gcc"/> | ||
46 | + <Compiler> | ||
47 | + <Add directory="/Users/ganghyeontae/crypto-optimization/include"/> | ||
48 | + </Compiler> | ||
49 | + <MakeCommands> | ||
50 | + <Build command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/src/Makefile" VERBOSE=1 MAIN"/> | ||
51 | + <CompileFile command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/src/Makefile" VERBOSE=1 "$file""/> | ||
52 | + <Clean command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/src/Makefile" VERBOSE=1 clean"/> | ||
53 | + <DistClean command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/src/Makefile" VERBOSE=1 clean"/> | ||
54 | + </MakeCommands> | ||
55 | + </Target> | ||
56 | + <Target title="MAIN/fast"> | ||
57 | + <Option output="/Users/ganghyeontae/crypto-optimization/src/MAIN" prefix_auto="0" extension_auto="0"/> | ||
58 | + <Option working_dir="/Users/ganghyeontae/crypto-optimization/src"/> | ||
59 | + <Option object_output="./"/> | ||
60 | + <Option type="1"/> | ||
61 | + <Option compiler="gcc"/> | ||
62 | + <Compiler> | ||
63 | + <Add directory="/Users/ganghyeontae/crypto-optimization/include"/> | ||
64 | + </Compiler> | ||
65 | + <MakeCommands> | ||
66 | + <Build command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/src/Makefile" VERBOSE=1 MAIN/fast"/> | ||
67 | + <CompileFile command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/src/Makefile" VERBOSE=1 "$file""/> | ||
68 | + <Clean command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/src/Makefile" VERBOSE=1 clean"/> | ||
69 | + <DistClean command="/usr/bin/make -f "/Users/ganghyeontae/crypto-optimization/src/Makefile" VERBOSE=1 clean"/> | ||
70 | + </MakeCommands> | ||
71 | + </Target> | ||
72 | + </Build> | ||
73 | + <Unit filename="/Users/ganghyeontae/crypto-optimization/src/main.c"> | ||
74 | + <Option target="MAIN"/> | ||
75 | + </Unit> | ||
76 | + <Unit filename="/Users/ganghyeontae/crypto-optimization/CMakeLists.txt"> | ||
77 | + <Option virtualFolder="CMake Files\"/> | ||
78 | + </Unit> | ||
79 | + <Unit filename="/Users/ganghyeontae/crypto-optimization/src/CMakeLists.txt"> | ||
80 | + <Option virtualFolder="CMake Files\src\"/> | ||
81 | + </Unit> | ||
82 | + </Project> | ||
83 | +</CodeBlocks_project_file> |
dockcross
0 → 100755
1 | +#!/bin/bash | ||
2 | + | ||
3 | +DEFAULT_DOCKCROSS_IMAGE=thewtex/cross-compiler-linux-armv6 | ||
4 | + | ||
5 | +#------------------------------------------------------------------------------ | ||
6 | +# Helpers | ||
7 | +# | ||
8 | +err() { | ||
9 | + echo -e >&2 ERROR: $@\\n | ||
10 | +} | ||
11 | + | ||
12 | +die() { | ||
13 | + err $@ | ||
14 | + exit 1 | ||
15 | +} | ||
16 | + | ||
17 | +has() { | ||
18 | + # eg. has command update | ||
19 | + local kind=$1 | ||
20 | + local name=$2 | ||
21 | + | ||
22 | + type -t $kind:$name | grep -q function | ||
23 | +} | ||
24 | + | ||
25 | +#------------------------------------------------------------------------------ | ||
26 | +# Command handlers | ||
27 | +# | ||
28 | +command:update-image() { | ||
29 | + docker pull $FINAL_IMAGE | ||
30 | +} | ||
31 | + | ||
32 | +help:update-image() { | ||
33 | + echo Pull the latest $FINAL_IMAGE . | ||
34 | +} | ||
35 | + | ||
36 | +command:update-script() { | ||
37 | + if cmp -s <( docker run $FINAL_IMAGE ) $0; then | ||
38 | + echo $0 is up to date | ||
39 | + else | ||
40 | + echo -n Updating $0 '... ' | ||
41 | + docker run $FINAL_IMAGE > $0 && echo ok | ||
42 | + fi | ||
43 | +} | ||
44 | + | ||
45 | +help:update-image() { | ||
46 | + echo Update $0 from $FINAL_IMAGE . | ||
47 | +} | ||
48 | + | ||
49 | +command:update() { | ||
50 | + command:update-image | ||
51 | + command:update-script | ||
52 | +} | ||
53 | + | ||
54 | +help:update() { | ||
55 | + echo Pull the latest $FINAL_IMAGE, and then update $0 from that. | ||
56 | +} | ||
57 | + | ||
58 | +command:help() { | ||
59 | + if [[ $# != 0 ]]; then | ||
60 | + if ! has command $1; then | ||
61 | + err \"$1\" is not an dockcross command | ||
62 | + command:help | ||
63 | + elif ! has help $1; then | ||
64 | + err No help found for \"$1\" | ||
65 | + else | ||
66 | + help:$1 | ||
67 | + fi | ||
68 | + else | ||
69 | + cat >&2 <<ENDHELP | ||
70 | +Usage: dockcross [options] [--] command [args] | ||
71 | + | ||
72 | +By default, run the given *command* in an dockcross Docker container. | ||
73 | + | ||
74 | +The *options* can be one of: | ||
75 | + | ||
76 | + --args|-a Extra args to the *docker run* command | ||
77 | + --image|-i Docker cross-compiler image to use | ||
78 | + --config|-c Bash script to source before running this script | ||
79 | + | ||
80 | + | ||
81 | +Additionally, there are special update commands: | ||
82 | + | ||
83 | + update-image | ||
84 | + update-script | ||
85 | + update | ||
86 | + | ||
87 | +For update command help use: $0 help <command> | ||
88 | +ENDHELP | ||
89 | + exit 1 | ||
90 | + fi | ||
91 | +} | ||
92 | + | ||
93 | +#------------------------------------------------------------------------------ | ||
94 | +# Option processing | ||
95 | +# | ||
96 | +while [[ $# != 0 ]]; do | ||
97 | + case $1 in | ||
98 | + | ||
99 | + --) | ||
100 | + break | ||
101 | + ;; | ||
102 | + | ||
103 | + --args|-a) | ||
104 | + ARG_ARGS="$2" | ||
105 | + shift 2 | ||
106 | + ;; | ||
107 | + | ||
108 | + --config|-c) | ||
109 | + ARG_CONFIG="$2" | ||
110 | + shift 2 | ||
111 | + ;; | ||
112 | + | ||
113 | + --image|-i) | ||
114 | + ARG_IMAGE="$2" | ||
115 | + shift 2 | ||
116 | + ;; | ||
117 | + | ||
118 | + -*) | ||
119 | + err Unknown option \"$1\" | ||
120 | + command:help | ||
121 | + exit | ||
122 | + ;; | ||
123 | + | ||
124 | + *) | ||
125 | + break | ||
126 | + ;; | ||
127 | + | ||
128 | + esac | ||
129 | +done | ||
130 | + | ||
131 | +# The precedence for options is: | ||
132 | +# 1. command-line arguments | ||
133 | +# 2. environment variables | ||
134 | +# 3. defaults | ||
135 | + | ||
136 | +# Source the config file if it exists | ||
137 | +DEFAULT_DOCKCROSS_CONFIG=~/.dockcross | ||
138 | +FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}} | ||
139 | + | ||
140 | +[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG" | ||
141 | + | ||
142 | +# Set the docker image | ||
143 | +FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}} | ||
144 | + | ||
145 | +# Set the docker run extra args (if any) | ||
146 | +FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}} | ||
147 | + | ||
148 | +# If we are not running via boot2docker | ||
149 | +if [ -z $DOCKER_HOST ]; then | ||
150 | + USER_IDS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g ) -e BUILDER_USER=$( id -un ) -e BUILDER_GROUP=$( id -gn )" | ||
151 | +fi | ||
152 | + | ||
153 | +#------------------------------------------------------------------------------ | ||
154 | +# Now, finally, run the command in a container | ||
155 | +# | ||
156 | +docker run -i -t --rm \ | ||
157 | + -v $PWD:/build \ | ||
158 | + $USER_IDS \ | ||
159 | + $FINAL_ARGS \ | ||
160 | + $FINAL_IMAGE "$@" | ||
161 | + | ||
162 | +################################################################################ | ||
163 | +# | ||
164 | +# This image is not intended to be run manually. | ||
165 | +# | ||
166 | +# To create a dockcross helper script for the | ||
167 | +# thewtex/cross-compiler-linux-armv7 image, run: | ||
168 | +# | ||
169 | +# docker run --rm thewtex/cross-compiler-linux-armv7 > dockcross-linux-armv7 | ||
170 | +# chmod +x dockcross-linux-armv7 | ||
171 | +# | ||
172 | +# You may then wish to move the dockcross script to your PATH. | ||
173 | +# | ||
174 | +################################################################################ |
docs/3주.pptx
0 → 100644
No preview for this file type
docs/중간보고서.암호라이브러리최적화.강현태.hwp
0 → 100644
No preview for this file type
1 | /* | 1 | /* |
2 | * WARNING: do not edit! | 2 | * WARNING: do not edit! |
3 | - * Generated by Makefile from include/openssl/opensslconf.h.in | 3 | + * Generated by Makefile from src/original/include/openssl/opensslconf.h.in |
4 | * | 4 | * |
5 | * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. | 5 | * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. |
6 | * | 6 | * |
... | @@ -24,12 +24,6 @@ extern "C" { | ... | @@ -24,12 +24,6 @@ extern "C" { |
24 | * OpenSSL was configured with the following options: | 24 | * OpenSSL was configured with the following options: |
25 | */ | 25 | */ |
26 | 26 | ||
27 | -#ifndef OPENSSL_SYS_MACOSX | ||
28 | -# define OPENSSL_SYS_MACOSX 1 | ||
29 | -#endif | ||
30 | -#ifndef OPENSSL_NO_COMP | ||
31 | -# define OPENSSL_NO_COMP | ||
32 | -#endif | ||
33 | #ifndef OPENSSL_NO_MD2 | 27 | #ifndef OPENSSL_NO_MD2 |
34 | # define OPENSSL_NO_MD2 | 28 | # define OPENSSL_NO_MD2 |
35 | #endif | 29 | #endif |
... | @@ -54,6 +48,9 @@ extern "C" { | ... | @@ -54,6 +48,9 @@ extern "C" { |
54 | #ifndef OPENSSL_NO_DEVCRYPTOENG | 48 | #ifndef OPENSSL_NO_DEVCRYPTOENG |
55 | # define OPENSSL_NO_DEVCRYPTOENG | 49 | # define OPENSSL_NO_DEVCRYPTOENG |
56 | #endif | 50 | #endif |
51 | +#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 | ||
52 | +# define OPENSSL_NO_EC_NISTP_64_GCC_128 | ||
53 | +#endif | ||
57 | #ifndef OPENSSL_NO_EGD | 54 | #ifndef OPENSSL_NO_EGD |
58 | # define OPENSSL_NO_EGD | 55 | # define OPENSSL_NO_EGD |
59 | #endif | 56 | #endif |
... | @@ -93,11 +90,8 @@ extern "C" { | ... | @@ -93,11 +90,8 @@ extern "C" { |
93 | #ifndef OPENSSL_NO_WEAK_SSL_CIPHERS | 90 | #ifndef OPENSSL_NO_WEAK_SSL_CIPHERS |
94 | # define OPENSSL_NO_WEAK_SSL_CIPHERS | 91 | # define OPENSSL_NO_WEAK_SSL_CIPHERS |
95 | #endif | 92 | #endif |
96 | -#ifndef OPENSSL_NO_STATIC_ENGINE | 93 | +#ifndef OPENSSL_NO_DYNAMIC_ENGINE |
97 | -# define OPENSSL_NO_STATIC_ENGINE | 94 | +# define OPENSSL_NO_DYNAMIC_ENGINE |
98 | -#endif | ||
99 | -#ifndef OPENSSL_NO_AFALGENG | ||
100 | -# define OPENSSL_NO_AFALGENG | ||
101 | #endif | 95 | #endif |
102 | 96 | ||
103 | 97 | ||
... | @@ -184,14 +178,14 @@ extern "C" { | ... | @@ -184,14 +178,14 @@ extern "C" { |
184 | * The following are cipher-specific, but are part of the public API. | 178 | * The following are cipher-specific, but are part of the public API. |
185 | */ | 179 | */ |
186 | #if !defined(OPENSSL_SYS_UEFI) | 180 | #if !defined(OPENSSL_SYS_UEFI) |
187 | -# undef BN_LLONG | 181 | +# define BN_LLONG |
188 | /* Only one for the following should be defined */ | 182 | /* Only one for the following should be defined */ |
189 | -# define SIXTY_FOUR_BIT_LONG | 183 | +# undef SIXTY_FOUR_BIT_LONG |
190 | # undef SIXTY_FOUR_BIT | 184 | # undef SIXTY_FOUR_BIT |
191 | -# undef THIRTY_TWO_BIT | 185 | +# define THIRTY_TWO_BIT |
192 | #endif | 186 | #endif |
193 | 187 | ||
194 | -#define RC4_INT unsigned int | 188 | +#define RC4_INT unsigned char |
195 | 189 | ||
196 | #ifdef __cplusplus | 190 | #ifdef __cplusplus |
197 | } | 191 | } | ... | ... |
src/CMakeLists.txt
0 → 100644
src/main.c
0 → 100644
1 | +// | ||
2 | +// Created by 강현태 on 06/10/2018. | ||
3 | +// | ||
4 | + | ||
5 | +#include <stdarg.h> | ||
6 | +#include <stddef.h> | ||
7 | +#include <setjmp.h> | ||
8 | +#include <string.h> | ||
9 | + | ||
10 | +#include <stdio.h> | ||
11 | +#include <openssl/rsa.h> | ||
12 | + | ||
13 | +#define ASCII_START 32 | ||
14 | +#define ASCII_END 126 | ||
15 | + | ||
16 | +char* generateRandomString(int size) { | ||
17 | + int i; | ||
18 | + char *res = (char*)malloc(size + 1); | ||
19 | + for(i = 0; i < size; i++) { | ||
20 | + res[i] = (char) (rand()%(ASCII_END-ASCII_START))+ASCII_START; | ||
21 | + } | ||
22 | + res[i] = '\0'; | ||
23 | + return res; | ||
24 | +} | ||
25 | + | ||
26 | +static void rsa_normal_test(){ | ||
27 | + int i; | ||
28 | + int bits = 2048; //key size | ||
29 | + int buflen = 1024; //buffer suze | ||
30 | + unsigned char *plaintext, *ciphertext, *randomstring; | ||
31 | + int same; | ||
32 | + BIGNUM *bn = BN_new(); | ||
33 | + BN_set_word(bn, RSA_F4); | ||
34 | + | ||
35 | + | ||
36 | + //1. rsa구조체 생성 | ||
37 | + RSA *rsa = RSA_new(); | ||
38 | + | ||
39 | + //2. key pair(private,public) 생성 | ||
40 | + RSA_generate_key_ex(rsa, bits, bn, NULL); | ||
41 | + | ||
42 | + //3. 본인의 public key로 암호화. | ||
43 | + randomstring=plaintext=(unsigned char*)generateRandomString(buflen); | ||
44 | + RSA_public_encrypt(buflen, plaintext, ciphertext, rsa,RSA_PKCS1_OAEP_PADDING); | ||
45 | + | ||
46 | + //4. 본인의 private key로 복호화. | ||
47 | + RSA_private_decrypt(buflen, ciphertext, plaintext, rsa,RSA_PKCS1_OAEP_PADDING); | ||
48 | + | ||
49 | + //5. 원 평문과 일치하는지 확인 | ||
50 | + same = 1; | ||
51 | + for(i=0;i<buflen;i++){ | ||
52 | + if(plaintext[i]!=randomstring[i]){ | ||
53 | + same=0; | ||
54 | + break; | ||
55 | + } | ||
56 | + } | ||
57 | + printf("%s \n",(same==1)?"통과":"다름"); | ||
58 | + | ||
59 | +} | ||
60 | + | ||
61 | +int main(void){ | ||
62 | + srand(time(NULL)); | ||
63 | + rsa_normal_test(); | ||
64 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -161,6 +161,7 @@ int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, | ... | @@ -161,6 +161,7 @@ int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, |
161 | int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | 161 | int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
162 | const BIGNUM *m, BN_CTX *ctx) | 162 | const BIGNUM *m, BN_CTX *ctx) |
163 | { | 163 | { |
164 | + printf("[INFO] BN mod exp recp 호출"); | ||
164 | int i, j, bits, ret = 0, wstart, wend, window, wvalue; | 165 | int i, j, bits, ret = 0, wstart, wend, window, wvalue; |
165 | int start = 1; | 166 | int start = 1; |
166 | BIGNUM *aa; | 167 | BIGNUM *aa; |
... | @@ -296,6 +297,7 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | ... | @@ -296,6 +297,7 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
296 | int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, | 297 | int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, |
297 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) | 298 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) |
298 | { | 299 | { |
300 | + printf("[INFO] BN mod exp mont 호출\n"); | ||
299 | int i, j, bits, ret = 0, wstart, wend, window, wvalue; | 301 | int i, j, bits, ret = 0, wstart, wend, window, wvalue; |
300 | int start = 1; | 302 | int start = 1; |
301 | BIGNUM *d, *r; | 303 | BIGNUM *d, *r; |
... | @@ -593,6 +595,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, | ... | @@ -593,6 +595,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, |
593 | const BIGNUM *m, BN_CTX *ctx, | 595 | const BIGNUM *m, BN_CTX *ctx, |
594 | BN_MONT_CTX *in_mont) | 596 | BN_MONT_CTX *in_mont) |
595 | { | 597 | { |
598 | + printf("[INFO] BN mod exp mont consttime 호출\n"); | ||
596 | int i, bits, ret = 0, window, wvalue, wmask, window0; | 599 | int i, bits, ret = 0, window, wvalue, wmask, window0; |
597 | int top; | 600 | int top; |
598 | BN_MONT_CTX *mont = NULL; | 601 | BN_MONT_CTX *mont = NULL; |
... | @@ -1127,6 +1130,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, | ... | @@ -1127,6 +1130,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, |
1127 | int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, | 1130 | int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, |
1128 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) | 1131 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) |
1129 | { | 1132 | { |
1133 | + printf("[INFO] BN mod exp mont word 호출\n"); | ||
1130 | BN_MONT_CTX *mont = NULL; | 1134 | BN_MONT_CTX *mont = NULL; |
1131 | int b, bits, ret = 0; | 1135 | int b, bits, ret = 0; |
1132 | int r_is_one; | 1136 | int r_is_one; |
... | @@ -1275,6 +1279,7 @@ int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, | ... | @@ -1275,6 +1279,7 @@ int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, |
1275 | int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | 1279 | int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
1276 | const BIGNUM *m, BN_CTX *ctx) | 1280 | const BIGNUM *m, BN_CTX *ctx) |
1277 | { | 1281 | { |
1282 | + printf("[INFO] BN mod exp simple 호출\n"); | ||
1278 | int i, j, bits, ret = 0, wstart, wend, window, wvalue; | 1283 | int i, j, bits, ret = 0, wstart, wend, window, wvalue; |
1279 | int start = 1; | 1284 | int start = 1; |
1280 | BIGNUM *d; | 1285 | BIGNUM *d; | ... | ... |
... | @@ -17,6 +17,7 @@ int BN_mod_exp2_mont(BIGNUM *rr, const BIGNUM *a1, const BIGNUM *p1, | ... | @@ -17,6 +17,7 @@ int BN_mod_exp2_mont(BIGNUM *rr, const BIGNUM *a1, const BIGNUM *p1, |
17 | const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m, | 17 | const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m, |
18 | BN_CTX *ctx, BN_MONT_CTX *in_mont) | 18 | BN_CTX *ctx, BN_MONT_CTX *in_mont) |
19 | { | 19 | { |
20 | + printf("[INFO] BN mod exp2 mot called!! \n"); | ||
20 | int i, j, bits, b, bits1, bits2, ret = | 21 | int i, j, bits, b, bits1, bits2, ret = |
21 | 0, wpos1, wpos2, window1, window2, wvalue1, wvalue2; | 22 | 0, wpos1, wpos2, window1, window2, wvalue1, wvalue2; |
22 | int r_is_one = 1; | 23 | int r_is_one = 1; | ... | ... |
... | @@ -12,6 +12,7 @@ | ... | @@ -12,6 +12,7 @@ |
12 | 12 | ||
13 | int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx) | 13 | int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx) |
14 | { | 14 | { |
15 | + printf("[INFO] BN nnmod called!! \n"); | ||
15 | /* | 16 | /* |
16 | * like BN_mod, but returns non-negative remainder (i.e., 0 <= r < |d| | 17 | * like BN_mod, but returns non-negative remainder (i.e., 0 <= r < |d| |
17 | * always holds) | 18 | * always holds) |
... | @@ -28,6 +29,7 @@ int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx) | ... | @@ -28,6 +29,7 @@ int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx) |
28 | int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, | 29 | int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, |
29 | BN_CTX *ctx) | 30 | BN_CTX *ctx) |
30 | { | 31 | { |
32 | + printf("[INFO] BN mod add called!! \n"); | ||
31 | if (!BN_add(r, a, b)) | 33 | if (!BN_add(r, a, b)) |
32 | return 0; | 34 | return 0; |
33 | return BN_nnmod(r, r, m, ctx); | 35 | return BN_nnmod(r, r, m, ctx); |
... | @@ -48,6 +50,7 @@ int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, | ... | @@ -48,6 +50,7 @@ int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, |
48 | int bn_mod_add_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, | 50 | int bn_mod_add_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
49 | const BIGNUM *m) | 51 | const BIGNUM *m) |
50 | { | 52 | { |
53 | + printf("[INFO] BN mod add fixed top called!! \n"); | ||
51 | size_t i, ai, bi, mtop = m->top; | 54 | size_t i, ai, bi, mtop = m->top; |
52 | BN_ULONG storage[1024 / BN_BITS2]; | 55 | BN_ULONG storage[1024 / BN_BITS2]; |
53 | BN_ULONG carry, temp, mask, *rp, *tp = storage; | 56 | BN_ULONG carry, temp, mask, *rp, *tp = storage; |
... | @@ -95,6 +98,7 @@ int bn_mod_add_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, | ... | @@ -95,6 +98,7 @@ int bn_mod_add_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
95 | int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, | 98 | int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
96 | const BIGNUM *m) | 99 | const BIGNUM *m) |
97 | { | 100 | { |
101 | + printf("[INFO] BN mod add quick called!! \n"); | ||
98 | int ret = bn_mod_add_fixed_top(r, a, b, m); | 102 | int ret = bn_mod_add_fixed_top(r, a, b, m); |
99 | 103 | ||
100 | if (ret) | 104 | if (ret) |
... | @@ -106,6 +110,7 @@ int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, | ... | @@ -106,6 +110,7 @@ int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
106 | int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, | 110 | int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, |
107 | BN_CTX *ctx) | 111 | BN_CTX *ctx) |
108 | { | 112 | { |
113 | + printf("[INFO] BN mod sub called!! \n"); | ||
109 | if (!BN_sub(r, a, b)) | 114 | if (!BN_sub(r, a, b)) |
110 | return 0; | 115 | return 0; |
111 | return BN_nnmod(r, r, m, ctx); | 116 | return BN_nnmod(r, r, m, ctx); |
... | @@ -128,6 +133,7 @@ int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, | ... | @@ -128,6 +133,7 @@ int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, |
128 | int bn_mod_sub_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, | 133 | int bn_mod_sub_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
129 | const BIGNUM *m) | 134 | const BIGNUM *m) |
130 | { | 135 | { |
136 | + printf("[INFO] BN mod sub fixed top called!! \n"); | ||
131 | size_t i, ai, bi, mtop = m->top; | 137 | size_t i, ai, bi, mtop = m->top; |
132 | BN_ULONG borrow, carry, ta, tb, mask, *rp; | 138 | BN_ULONG borrow, carry, ta, tb, mask, *rp; |
133 | const BN_ULONG *ap, *bp; | 139 | const BN_ULONG *ap, *bp; |
... | @@ -182,6 +188,7 @@ int bn_mod_sub_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, | ... | @@ -182,6 +188,7 @@ int bn_mod_sub_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
182 | int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, | 188 | int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
183 | const BIGNUM *m) | 189 | const BIGNUM *m) |
184 | { | 190 | { |
191 | + printf("[INFO] BN mod sub quick called!! \n"); | ||
185 | if (!BN_sub(r, a, b)) | 192 | if (!BN_sub(r, a, b)) |
186 | return 0; | 193 | return 0; |
187 | if (r->neg) | 194 | if (r->neg) |
... | @@ -193,6 +200,7 @@ int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, | ... | @@ -193,6 +200,7 @@ int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
193 | int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, | 200 | int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, |
194 | BN_CTX *ctx) | 201 | BN_CTX *ctx) |
195 | { | 202 | { |
203 | + printf("[INFO] BN mod mul called!! \n"); | ||
196 | BIGNUM *t; | 204 | BIGNUM *t; |
197 | int ret = 0; | 205 | int ret = 0; |
198 | 206 | ||
... | @@ -221,6 +229,7 @@ int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, | ... | @@ -221,6 +229,7 @@ int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, |
221 | 229 | ||
222 | int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx) | 230 | int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx) |
223 | { | 231 | { |
232 | + printf("[INFO] BN mod sqr called!! \n"); | ||
224 | if (!BN_sqr(r, a, ctx)) | 233 | if (!BN_sqr(r, a, ctx)) |
225 | return 0; | 234 | return 0; |
226 | /* r->neg == 0, thus we don't need BN_nnmod */ | 235 | /* r->neg == 0, thus we don't need BN_nnmod */ | ... | ... |
... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
10 | #include "internal/cryptlib.h" | 10 | #include "internal/cryptlib.h" |
11 | #include "internal/bn_int.h" | 11 | #include "internal/bn_int.h" |
12 | #include "rsa_locl.h" | 12 | #include "rsa_locl.h" |
13 | +#include <stdio.h> | ||
13 | 14 | ||
14 | static int rsa_ossl_public_encrypt(int flen, const unsigned char *from, | 15 | static int rsa_ossl_public_encrypt(int flen, const unsigned char *from, |
15 | unsigned char *to, RSA *rsa, int padding); | 16 | unsigned char *to, RSA *rsa, int padding); |
... | @@ -67,22 +68,25 @@ const RSA_METHOD *RSA_null_method(void) | ... | @@ -67,22 +68,25 @@ const RSA_METHOD *RSA_null_method(void) |
67 | static int rsa_ossl_public_encrypt(int flen, const unsigned char *from, | 68 | static int rsa_ossl_public_encrypt(int flen, const unsigned char *from, |
68 | unsigned char *to, RSA *rsa, int padding) | 69 | unsigned char *to, RSA *rsa, int padding) |
69 | { | 70 | { |
71 | + printf("[INFO] default public encrypt called!! \n"); | ||
70 | BIGNUM *f, *ret; | 72 | BIGNUM *f, *ret; |
71 | - int i, num = 0, r = -1; | 73 | + int i,tmp, num = 0, r = -1; |
72 | unsigned char *buf = NULL; | 74 | unsigned char *buf = NULL; |
73 | BN_CTX *ctx = NULL; | 75 | BN_CTX *ctx = NULL; |
74 | 76 | ||
75 | if (BN_num_bits(rsa->n) > OPENSSL_RSA_MAX_MODULUS_BITS) { | 77 | if (BN_num_bits(rsa->n) > OPENSSL_RSA_MAX_MODULUS_BITS) { |
78 | + //만들어진 rsa->n의 비트값이 최댓값보다 더 크다면, 에러! | ||
76 | RSAerr(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT, RSA_R_MODULUS_TOO_LARGE); | 79 | RSAerr(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT, RSA_R_MODULUS_TOO_LARGE); |
77 | return -1; | 80 | return -1; |
78 | } | 81 | } |
79 | 82 | ||
80 | if (BN_ucmp(rsa->n, rsa->e) <= 0) { | 83 | if (BN_ucmp(rsa->n, rsa->e) <= 0) { |
84 | + //n과 e를 절댓값비교후 0보다 같거나 작다면, 에러! | ||
81 | RSAerr(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT, RSA_R_BAD_E_VALUE); | 85 | RSAerr(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT, RSA_R_BAD_E_VALUE); |
82 | return -1; | 86 | return -1; |
83 | } | 87 | } |
84 | 88 | ||
85 | - /* for large moduli, enforce exponent limit */ | 89 | + /* 큰 moduli에 대해, exponent 한계값을 강제함 */ |
86 | if (BN_num_bits(rsa->n) > OPENSSL_RSA_SMALL_MODULUS_BITS) { | 90 | if (BN_num_bits(rsa->n) > OPENSSL_RSA_SMALL_MODULUS_BITS) { |
87 | if (BN_num_bits(rsa->e) > OPENSSL_RSA_MAX_PUBEXP_BITS) { | 91 | if (BN_num_bits(rsa->e) > OPENSSL_RSA_MAX_PUBEXP_BITS) { |
88 | RSAerr(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT, RSA_R_BAD_E_VALUE); | 92 | RSAerr(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT, RSA_R_BAD_E_VALUE); |
... | @@ -90,18 +94,27 @@ static int rsa_ossl_public_encrypt(int flen, const unsigned char *from, | ... | @@ -90,18 +94,27 @@ static int rsa_ossl_public_encrypt(int flen, const unsigned char *from, |
90 | } | 94 | } |
91 | } | 95 | } |
92 | 96 | ||
97 | + // 컨텍스트 생성. | ||
93 | if ((ctx = BN_CTX_new()) == NULL) | 98 | if ((ctx = BN_CTX_new()) == NULL) |
94 | goto err; | 99 | goto err; |
95 | BN_CTX_start(ctx); | 100 | BN_CTX_start(ctx); |
96 | f = BN_CTX_get(ctx); | 101 | f = BN_CTX_get(ctx); |
97 | ret = BN_CTX_get(ctx); | 102 | ret = BN_CTX_get(ctx); |
98 | num = BN_num_bytes(rsa->n); | 103 | num = BN_num_bytes(rsa->n); |
104 | + //num 은 rsa->n의 바이트수 | ||
99 | buf = OPENSSL_malloc(num); | 105 | buf = OPENSSL_malloc(num); |
106 | + //buf는 num만큼 동적할당. | ||
100 | if (ret == NULL || buf == NULL) { | 107 | if (ret == NULL || buf == NULL) { |
101 | RSAerr(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT, ERR_R_MALLOC_FAILURE); | 108 | RSAerr(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT, ERR_R_MALLOC_FAILURE); |
102 | goto err; | 109 | goto err; |
103 | } | 110 | } |
104 | 111 | ||
112 | + //암호화 최소단위가 있을경우 패딩! | ||
113 | + printf("[INFO] before padding buffer : "); | ||
114 | + for(tmp=0;tmp<num;tmp++){ | ||
115 | + printf("%x ",buf[tmp]); | ||
116 | + } | ||
117 | + printf("\n"); | ||
105 | switch (padding) { | 118 | switch (padding) { |
106 | case RSA_PKCS1_PADDING: | 119 | case RSA_PKCS1_PADDING: |
107 | i = RSA_padding_add_PKCS1_type_2(buf, num, from, flen); | 120 | i = RSA_padding_add_PKCS1_type_2(buf, num, from, flen); |
... | @@ -119,10 +132,17 @@ static int rsa_ossl_public_encrypt(int flen, const unsigned char *from, | ... | @@ -119,10 +132,17 @@ static int rsa_ossl_public_encrypt(int flen, const unsigned char *from, |
119 | RSAerr(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT, RSA_R_UNKNOWN_PADDING_TYPE); | 132 | RSAerr(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT, RSA_R_UNKNOWN_PADDING_TYPE); |
120 | goto err; | 133 | goto err; |
121 | } | 134 | } |
135 | + printf("[INFO] after padding buffer : "); | ||
136 | + for(tmp=0;tmp<num;tmp++){ | ||
137 | + printf("%x ",buf[tmp]); | ||
138 | + } | ||
139 | + printf("\n"); | ||
140 | + | ||
122 | if (i <= 0) | 141 | if (i <= 0) |
123 | goto err; | 142 | goto err; |
124 | 143 | ||
125 | - if (BN_bin2bn(buf, num, f) == NULL) | 144 | + if (BN_bin2bn(buf, num, f) == NULL) //원본, 사이즈, 저장될 bignum |
145 | + //buf를 2진수 -> bignum으로 바꾼 결과(f에 저장)가 NULL이면, 에러! | ||
126 | goto err; | 146 | goto err; |
127 | 147 | ||
128 | if (BN_ucmp(f, rsa->n) >= 0) { | 148 | if (BN_ucmp(f, rsa->n) >= 0) { |
... | @@ -136,16 +156,20 @@ static int rsa_ossl_public_encrypt(int flen, const unsigned char *from, | ... | @@ -136,16 +156,20 @@ static int rsa_ossl_public_encrypt(int flen, const unsigned char *from, |
136 | if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_n, rsa->lock, | 156 | if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_n, rsa->lock, |
137 | rsa->n, ctx)) | 157 | rsa->n, ctx)) |
138 | goto err; | 158 | goto err; |
139 | - | 159 | + // ret = f^e % n을 계산함. (암호화) |
140 | if (!rsa->meth->bn_mod_exp(ret, f, rsa->e, rsa->n, ctx, | 160 | if (!rsa->meth->bn_mod_exp(ret, f, rsa->e, rsa->n, ctx, |
141 | rsa->_method_mod_n)) | 161 | rsa->_method_mod_n)) |
142 | goto err; | 162 | goto err; |
143 | 163 | ||
144 | /* | 164 | /* |
145 | - * BN_bn2binpad puts in leading 0 bytes if the number is less than | 165 | + * BN_bn2binpad는 바이트 0으로 채운다. 숫자가 modulus의 길이보다 작다면 |
146 | - * the length of the modulus. | ||
147 | */ | 166 | */ |
148 | r = BN_bn2binpad(ret, to, num); | 167 | r = BN_bn2binpad(ret, to, num); |
168 | + printf("[INFO] after mod exp : "); | ||
169 | + for(tmp=0;tmp<r;tmp++){ | ||
170 | + printf("%x ",to[tmp]); | ||
171 | + } | ||
172 | + printf("\n"); | ||
149 | err: | 173 | err: |
150 | if (ctx != NULL) | 174 | if (ctx != NULL) |
151 | BN_CTX_end(ctx); | 175 | BN_CTX_end(ctx); |
... | @@ -591,6 +615,7 @@ static int rsa_ossl_public_decrypt(int flen, const unsigned char *from, | ... | @@ -591,6 +615,7 @@ static int rsa_ossl_public_decrypt(int flen, const unsigned char *from, |
591 | 615 | ||
592 | static int rsa_ossl_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) | 616 | static int rsa_ossl_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) |
593 | { | 617 | { |
618 | + printf("[INFO] ossl mod exp called!"); | ||
594 | BIGNUM *r1, *m1, *vrfy, *r2, *m[RSA_MAX_PRIME_NUM - 2]; | 619 | BIGNUM *r1, *m1, *vrfy, *r2, *m[RSA_MAX_PRIME_NUM - 2]; |
595 | int ret = 0, i, ex_primes = 0, smooth = 0; | 620 | int ret = 0, i, ex_primes = 0, smooth = 0; |
596 | RSA_PRIME_INFO *pinfo; | 621 | RSA_PRIME_INFO *pinfo; | ... | ... |
src/timer.h
0 → 100644
중간보고서.암호라이브러리최적화.강현태.hwp
0 → 100644
No preview for this file type
-
Please register or login to post a comment