달력

5

« 2024/5 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

'Xcode 3.2.5'에 해당되는 글 1

  1. 2011.01.12 iOS 에서 Openssl 사용하기 (SEED 알고리즘 포함) 2
반응형
설치 시스템 환경
xCode 3.2.5 / iOS 4.2 SDK
openssl-1.0.0c

1. openssl 다운로드
http://www.openssl.org 에서 다운로드
(2011.1.12 현재 openssl-1.0.0c  버전이 최신버전)
사용자의 위치에 압축풀기
ex) /Users/사용자이름/AppDev/openssl-1.0.0c

인스톨 위치 결정
ex)
cd /Users/사용자이름/AppDev/
mkdir openssl
cd openssl
mkdir openssl_i386 openssl_armv6 openssl_armv7


2. 소스코드 수정
Filename : openssl-1.0.0c/crypto/ui/ui_openssl.c 
수정할 부분 : static volatile sig_atomic_t intr_signal;
수정후 내용 : static volatile int intr_signal;

tip. 소스의 수정은 vi 에디터 등으로 할 수 있다. ":"를 눌러 커맨드 모드에서 
"/static volatile " 와 같이 치면 해당 부분을 바로 찾아준다.


3. makefile 수정
1) build 디렉토리를 다음과 같이 만든다.
mkdir openssl_temp

2) Config 파일을 구성한다.
./Configure BSD-generic32 enable-seed --openssldir=/Users/사용자명/AppDev/openssl-1.0.0c/openssl_temp



4. i386 (시뮬레이터)용 openssl 빌드
1) Makefile 을 수정한다.
수정전 내용 : CC = gcc
수정후 내용 : CC= /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386

수정전 내용 : CFLAG= -DOPENSSL_THREADS -pthread -D_THREAD_SAFE -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DTERMIOS -O3 -fomit-frame-pointer -Wall
수정후 내용 : CFLAG= -DOPENSSL_THREADS -pthread -D_THREAD_SAFE -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DTERMIOS -O3 -fomit-frame-pointer -Wall -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk

2) build 수행
make
make install

3) Build 확인
ls -l openssl_test/lib
drwxr-xr-x  2 사용자명  staff       68  1 12 16:05 engines
-rw-r--r--  1 사용자명  staff  2584744  1 12 16:05 libcrypto.a
-rw-r--r--  1 사용자명  staff   454896  1 12 16:05 libssl.a
drwxr-xr-x  5 사용자명  staff      170  1 12 16:05 pkgconfig

4) Build 버전 이동
mv openssl_test/ ../openssl/openssl_i386



5. arm6 (아이폰/아이패드)용 openssl 빌드
1) Makefile 을 수정한다.
수정전 내용 : CC= /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386
수정후 내용 : CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv6

수정후 내용 : CFLAG= -DOPENSSL_THREADS -pthread -D_THREAD_SAFE -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DTERMIOS -O3 -fomit-frame-pointer -Wall -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk
수정후 내용 : CFLAG= -DOPENSSL_THREADS -pthread -D_THREAD_SAFE -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DTERMIOS -O3 -fomit-frame-pointer -Wall -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk

2) build 수행
make clean
make
make install

3) Build 확인
ls -l openssl_temp/lib
drwxr-xr-x  2 사용자명  staff       68  1 12 16:20 engines
-rw-r--r--  1 사용자명  staff  2999344  1 12 16:20 libcrypto.a
-rw-r--r--  1 사용자명  staff   497936  1 12 16:20 libssl.a
drwxr-xr-x  5 사용자명  staff      170  1 12 16:20 pkgconfig

4) Build 버전 이동
mv openssl_temp/ ../openssl/openssl-armv6



6. arm7 (아이폰/아이패드)용 openssl 빌드
1) Makefile 을 수정한다.
수정전 내용 : CC= /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386
수정후 내용 : CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv7

수정후 내용 : CFLAG= -DOPENSSL_THREADS -pthread -D_THREAD_SAFE -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DTERMIOS -O3 -fomit-frame-pointer -Wall -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk
수정후 내용 : CFLAG= -DOPENSSL_THREADS -pthread -D_THREAD_SAFE -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DTERMIOS -O3 -fomit-frame-pointer -Wall -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk

2) build 수행
make clean
make
make install

3) Build 확인
ls -l openssl_temp/lib
drwxr-xr-x  2 사용자명  staff       68  1 12 16:35 engines
-rw-r--r--  1 사용자명  staff  2666440  1 12 16:35 libcrypto.a
-rw-r--r--  1 사용자명  staff   425368  1 12 16:35 libssl.a
drwxr-xr-x  5 사용자명  staff      170  1 12 16:35 pkgconfig

4) Build 버전 이동
mv openssl_temp/ ../openssl/openssl-armv7

7. Univerals (통합버전) 만들기
1) include 파일 복사
cd /Users/사용자명/AppDev/openssl-1.0.0c
cp -RL include ../openssl/include

tip. -R 옵션은 디렉토리 복사이고, -L 옵션은 심볼릭링크 파일인 경우, 원본을 찾아서 이를 복사하는 옵션이다. 해당 include의 파일들을 보면 알겠지만, 모두 심볼릭 링크 파일로 되어있다.

2) lib 파일 통합
cd /Users/사용자명/AppDev/openssl 
lipo -create openssl_i386/lib/libssl.a openssl_armv6/lib/libssl.a openssl_armv7/lib/libssl.a -output libssl.a
lipo -create openssl_i386/lib/libcrypto.a openssl_armv6/lib/libcrypto.a openssl_armv7/lib/libcrypto.a -output libcrypto.a

tip. 이후 배포할때 include 디렉토리와 libssl.a 및 libcrypto.a 파일을 함께 배포하면 된다.

8. xCode 에서 실행하기
1) include 폴더 프로젝트 디렉토리로 복사
2) libcrypto.a libssl.a 프로젝트 디렉토리로 복사

3) libcrypto.a libssl.a 파일 xCode Framework 폴더에 추가


4) Targets -> 프로젝트 Info 에서 Header Include 다음과 같이 추가

5) 다음과 같이 헤더파일 추가 후 코드 작성

#include <openssl/md5.h>

#include <openssl/sha.h>

#include <openssl/seed.h>


반응형
:
Posted by 째시기