SlideShare une entreprise Scribd logo
1  sur  5
Télécharger pour lire hors ligne
2014/2/23

Cocoa

#27 QuickLook

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_OpenSSL-msyk/index.html

1/5
2014/2/23

Cocoa

#27 QuickLook

$ ech o 'MacBook Air' | open s s l bf -e -k apple2 -ou t tes t.en c
$ h exdu m p -C tes t.en c
00000000 53 61 6c 74 65 64 5f 5f 09 40 94 44 e3 d9 23 71 |Salted__.@.D??#q|
00000010 9d e9 86 7f 3b 62 e1 80 09 5e 2f a4 b4 8d 7e 7e |.?..;b?..^/??.~~|
00000020
$ ech o 'MacBook Air' | open s s l bf -k apple2 -ou t tes t2 .en c
$ h exdu m p -C tes t2 .en c
00000000 53 61 6c 74 65 64 5f 5f b2 04 99 d5 48 5e 28 b7 |Salted__?..?H^(?|
00000010 2e 42 9c 15 83 25 6a 39 e5 1b f7 a6 2c 85 c9 a5 |.B...%j9?.??,.ɥ|
00000020
$ open s s l bf -d -k apple2 -in tes t.en c
MacBook Air

$ open s s l bf -P -k apple2
salt=17731E3E93896C77
key=3C27DE1D1DD84C0FA67B6A49E423DF4A
iv =B7FBF5536765B277
$ ech o 'MacBook Air' | open s s l bf -e -K 3 C2 7 DE1 D1 DD8 4 C0 FA6 7 B6 A4 9 E4 2 3 DF4 A -iv B7 FBF5 5 3 6 7 6 5 B2 7 7 -ou t tes t3 .en c
$ h exdu m p -C tes t3 .en c
00000000 25 d0 54 e1 59 fa 67 11 13 16 32 7a c8 87 b6 8b |%?T?Y?g...2z?.?.|
00000010
$ ech o 'MacBook Air' | open s s l bf -e -K 3 C2 7 DE1 D1 DD8 4 C0 FA6 7 B6 A4 9 E4 2 3 DF4 A -iv B7 FBF5 5 3 6 7 6 5 B2 7 7 -ou t tes t4 .en c
$ h exdu m p -C tes t4 .en c
00000000 25 d0 54 e1 59 fa 67 11 13 16 32 7a c8 87 b6 8b |%?T?Y?g...2z?.?.|
00000010
$ open s s l bf -in tes t3 .en c -d -K 3 C2 7 DE1 D1 DD8 4 C0 FA6 7 B6 A4 9 E4 2 3 DF4 A -iv B7 FBF5 5 3 6 7 6 5 B2 7 7
MacBook Air

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_OpenSSL-msyk/index.html

2/5
2014/2/23

Cocoa

#27 QuickLook

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_OpenSSL-msyk/index.html

3/5
2014/2/23

Cocoa

#27 QuickLook

#import "AppController.h"
@implementation AppController
- (void)awakeFromNib
{
NSString *rPath = [[NSBundle mainBundle] resourcePath];
NSString *encFile = [rPath stringByAppendingPathComponent:@"data.enc"];
/*
$ openssl bf -P -k apple2
salt=17731E3E93896C77
key=3C27DE1D1DD84C0FA67B6A49E423DF4A
iv =B7FBF5536765B277
*/
NSData* encData = [NSData dataWithContentsOfFile: encFile];
NSString* originalString = [[NSString alloc]initWithData: encData encoding: NSASCIIStringEncoding];
[originalText insertText: originalString];
int plainlen, tmplen;
unsigned char iv[8] = {0xB7, 0xFB, 0xF5, 0x53, 0x67, 0x65, 0xB2, 0x77};
unsigned char key[16] = {0x3C, 0x27, 0xDE, 0x1D, 0x1D, 0xD8, 0x4C, 0x0F,
0xA6, 0x7B, 0x6A, 0x49, 0xE4, 0x23, 0xDF, 0x4A};
unsigned char* inData;
unsigned char* outData;
inData = (unsigned char*)[encData bytes];
int inDataLen = [encData length];
outData = malloc(inDataLen + 8);
EVP_CIPHER_CTX ctx;
EVP_CIPHER_CTX_init( &ctx );
EVP_DecryptInit( &ctx, EVP_bf_cbc(), key ,iv );
int resultUpdate = EVP_DecryptUpdate( &ctx, outData, &plainlen, inData, inDataLen);
int resultFinal = EVP_DecryptFinal( &ctx, outData + plainlen, &tmplen);
EVP_CIPHER_CTX_cleanup(&ctx);
if ( ( resultFinal != 1 ) || ( resultUpdate != 1 ) )
{
[decriptedText insertText: @"Decription was not succeed." ];
} else {
outData[ plainlen + tmplen ] = 0;
NSString* decriptedString = [NSString stringWithUTF8String: (char*)outData];
[decriptedText insertText: decriptedString ];
}
free(outData);
}

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_OpenSSL-msyk/index.html

4/5
2014/2/23

Cocoa

#27 QuickLook

@end

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_OpenSSL-msyk/index.html

5/5

Contenu connexe

Similaire à Cocoa勉強会#28-OpenSSLで暗号化したファイルを復号する

Cis1-193-Rowe-Erin-exam 2 b(handson-lab)
Cis1-193-Rowe-Erin-exam 2 b(handson-lab)Cis1-193-Rowe-Erin-exam 2 b(handson-lab)
Cis1-193-Rowe-Erin-exam 2 b(handson-lab)
erowe3
 
Topic 3 Green Design Links
Topic 3  Green  Design  LinksTopic 3  Green  Design  Links
Topic 3 Green Design Links
Jutka Czirok
 
Stefan Marsiske - What would hackers use? part1
Stefan Marsiske - What would hackers use? part1Stefan Marsiske - What would hackers use? part1
Stefan Marsiske - What would hackers use? part1
ecommerce poland expo
 
BlackBerry 10 Core Native Camera API
BlackBerry 10 Core Native Camera APIBlackBerry 10 Core Native Camera API
BlackBerry 10 Core Native Camera API
Steven Beeckman
 
SnälllaDebugSnällla.exeSnälllaDebugSnällla.ilkSnäl.docx
SnälllaDebugSnällla.exeSnälllaDebugSnällla.ilkSnäl.docxSnälllaDebugSnällla.exeSnälllaDebugSnällla.ilkSnäl.docx
SnälllaDebugSnällla.exeSnälllaDebugSnällla.ilkSnäl.docx
jensgosney
 
Open Access publikācijas (2010. gada oktobris)
Open Access publikācijas (2010. gada oktobris)Open Access publikācijas (2010. gada oktobris)
Open Access publikācijas (2010. gada oktobris)
Bibliotēku portāls
 
Tenha um domínio do regedit do windows
Tenha um domínio do regedit do windowsTenha um domínio do regedit do windows
Tenha um domínio do regedit do windows
Carlos Catanejo
 

Similaire à Cocoa勉強会#28-OpenSSLで暗号化したファイルを復号する (20)

Cocoa勉強会#27-QuickLookプラグインの作り方
Cocoa勉強会#27-QuickLookプラグインの作り方Cocoa勉強会#27-QuickLookプラグインの作り方
Cocoa勉強会#27-QuickLookプラグインの作り方
 
E portfolio design
E portfolio designE portfolio design
E portfolio design
 
E portfolio design
E portfolio designE portfolio design
E portfolio design
 
Cities: Input / Output, Thursday Night Lectures
Cities: Input / Output, Thursday Night LecturesCities: Input / Output, Thursday Night Lectures
Cities: Input / Output, Thursday Night Lectures
 
Buggi (2).pdf
Buggi (2).pdfBuggi (2).pdf
Buggi (2).pdf
 
How Endpoint Mobility Kills Bare Metal Restore (infographic)
How Endpoint Mobility Kills Bare Metal Restore (infographic)How Endpoint Mobility Kills Bare Metal Restore (infographic)
How Endpoint Mobility Kills Bare Metal Restore (infographic)
 
Cis1-193-Rowe-Erin-exam 2 b(handson-lab)
Cis1-193-Rowe-Erin-exam 2 b(handson-lab)Cis1-193-Rowe-Erin-exam 2 b(handson-lab)
Cis1-193-Rowe-Erin-exam 2 b(handson-lab)
 
Piwik elasticsearch kibana at OSC Tokyo 2016 Spring
Piwik elasticsearch kibana at OSC Tokyo 2016 SpringPiwik elasticsearch kibana at OSC Tokyo 2016 Spring
Piwik elasticsearch kibana at OSC Tokyo 2016 Spring
 
Cocoa勉強会#23-カスタムシートとModality
Cocoa勉強会#23-カスタムシートとModalityCocoa勉強会#23-カスタムシートとModality
Cocoa勉強会#23-カスタムシートとModality
 
Topic 3 Green Design Links
Topic 3  Green  Design  LinksTopic 3  Green  Design  Links
Topic 3 Green Design Links
 
hotfile june 16 2012
hotfile june 16 2012hotfile june 16 2012
hotfile june 16 2012
 
Stefan Marsiske - What would hackers use? part1
Stefan Marsiske - What would hackers use? part1Stefan Marsiske - What would hackers use? part1
Stefan Marsiske - What would hackers use? part1
 
CLI Wizardry - A Friendly Intro To sed/awk/grep
CLI Wizardry - A Friendly Intro To sed/awk/grepCLI Wizardry - A Friendly Intro To sed/awk/grep
CLI Wizardry - A Friendly Intro To sed/awk/grep
 
DEF CON 27 - workshop - JOSH REYNOLDS - from ek to dek slides
DEF CON 27 - workshop - JOSH REYNOLDS - from ek to dek slidesDEF CON 27 - workshop - JOSH REYNOLDS - from ek to dek slides
DEF CON 27 - workshop - JOSH REYNOLDS - from ek to dek slides
 
Functional Reactive Programming on Android
Functional Reactive Programming on AndroidFunctional Reactive Programming on Android
Functional Reactive Programming on Android
 
Introducing Intelligence Into Your Malware Analysis
Introducing Intelligence Into Your Malware AnalysisIntroducing Intelligence Into Your Malware Analysis
Introducing Intelligence Into Your Malware Analysis
 
BlackBerry 10 Core Native Camera API
BlackBerry 10 Core Native Camera APIBlackBerry 10 Core Native Camera API
BlackBerry 10 Core Native Camera API
 
SnälllaDebugSnällla.exeSnälllaDebugSnällla.ilkSnäl.docx
SnälllaDebugSnällla.exeSnälllaDebugSnällla.ilkSnäl.docxSnälllaDebugSnällla.exeSnälllaDebugSnällla.ilkSnäl.docx
SnälllaDebugSnällla.exeSnälllaDebugSnällla.ilkSnäl.docx
 
Open Access publikācijas (2010. gada oktobris)
Open Access publikācijas (2010. gada oktobris)Open Access publikācijas (2010. gada oktobris)
Open Access publikācijas (2010. gada oktobris)
 
Tenha um domínio do regedit do windows
Tenha um domínio do regedit do windowsTenha um domínio do regedit do windows
Tenha um domínio do regedit do windows
 

Plus de Masayuki Nii

Plus de Masayuki Nii (20)

Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
 
トップエスイー勉強会2014第1回-INTER-Mediator
トップエスイー勉強会2014第1回-INTER-Mediatorトップエスイー勉強会2014第1回-INTER-Mediator
トップエスイー勉強会2014第1回-INTER-Mediator
 
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみるCocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
 
Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法
Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法
Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法
 
Cocoa勉強会#61-メインスレッド外でNSURLConnection
Cocoa勉強会#61-メインスレッド外でNSURLConnectionCocoa勉強会#61-メインスレッド外でNSURLConnection
Cocoa勉強会#61-メインスレッド外でNSURLConnection
 
Cocoa勉強会#6-SQLiteをCocoaで使う
Cocoa勉強会#6-SQLiteをCocoaで使うCocoa勉強会#6-SQLiteをCocoaで使う
Cocoa勉強会#6-SQLiteをCocoaで使う
 
Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号
Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号
Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号
 
Cocoa勉強会#57-Baseによるローカライズまとめ
Cocoa勉強会#57-BaseによるローカライズまとめCocoa勉強会#57-Baseによるローカライズまとめ
Cocoa勉強会#57-Baseによるローカライズまとめ
 
Cocoa勉強会#56-小ネタ集あなたの常識はすでに通用しない
Cocoa勉強会#56-小ネタ集あなたの常識はすでに通用しないCocoa勉強会#56-小ネタ集あなたの常識はすでに通用しない
Cocoa勉強会#56-小ネタ集あなたの常識はすでに通用しない
 
Cocoa勉強会#45-AWS SimpleDBを使ってみる
Cocoa勉強会#45-AWS SimpleDBを使ってみるCocoa勉強会#45-AWS SimpleDBを使ってみる
Cocoa勉強会#45-AWS SimpleDBを使ってみる
 
Cocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビュー
Cocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビューCocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビュー
Cocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビュー
 
Cocoa勉強会#33-意外に楽に使えるlibcurl
Cocoa勉強会#33-意外に楽に使えるlibcurlCocoa勉強会#33-意外に楽に使えるlibcurl
Cocoa勉強会#33-意外に楽に使えるlibcurl
 
Cocoa勉強会23-識別情報の変換〜文字エンコードとデータタイプ
Cocoa勉強会23-識別情報の変換〜文字エンコードとデータタイプCocoa勉強会23-識別情報の変換〜文字エンコードとデータタイプ
Cocoa勉強会23-識別情報の変換〜文字エンコードとデータタイプ
 
Cocoa勉強会#37-シェイクイベントの実装
Cocoa勉強会#37-シェイクイベントの実装Cocoa勉強会#37-シェイクイベントの実装
Cocoa勉強会#37-シェイクイベントの実装
 
Cocoa勉強会#32-表形式のデータに順序を記録する方法
Cocoa勉強会#32-表形式のデータに順序を記録する方法Cocoa勉強会#32-表形式のデータに順序を記録する方法
Cocoa勉強会#32-表形式のデータに順序を記録する方法
 
Cocoa勉強会#35-iPhoneでのコピペとカスタムUI
Cocoa勉強会#35-iPhoneでのコピペとカスタムUICocoa勉強会#35-iPhoneでのコピペとカスタムUI
Cocoa勉強会#35-iPhoneでのコピペとカスタムUI
 
Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証
Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証
Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証
 
Cocoa勉強会#38-UITableViewテーブル内のナビゲーション
Cocoa勉強会#38-UITableViewテーブル内のナビゲーションCocoa勉強会#38-UITableViewテーブル内のナビゲーション
Cocoa勉強会#38-UITableViewテーブル内のナビゲーション
 
Cocoa勉強会#43-Blocksを使う
Cocoa勉強会#43-Blocksを使うCocoa勉強会#43-Blocksを使う
Cocoa勉強会#43-Blocksを使う
 
Cocoa勉強会#42-UIWebKitをコンポーネントとして使う
Cocoa勉強会#42-UIWebKitをコンポーネントとして使うCocoa勉強会#42-UIWebKitをコンポーネントとして使う
Cocoa勉強会#42-UIWebKitをコンポーネントとして使う
 

Dernier

Dernier (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Cocoa勉強会#28-OpenSSLで暗号化したファイルを復号する

  • 2. 2014/2/23 Cocoa #27 QuickLook $ ech o 'MacBook Air' | open s s l bf -e -k apple2 -ou t tes t.en c $ h exdu m p -C tes t.en c 00000000 53 61 6c 74 65 64 5f 5f 09 40 94 44 e3 d9 23 71 |Salted__.@.D??#q| 00000010 9d e9 86 7f 3b 62 e1 80 09 5e 2f a4 b4 8d 7e 7e |.?..;b?..^/??.~~| 00000020 $ ech o 'MacBook Air' | open s s l bf -k apple2 -ou t tes t2 .en c $ h exdu m p -C tes t2 .en c 00000000 53 61 6c 74 65 64 5f 5f b2 04 99 d5 48 5e 28 b7 |Salted__?..?H^(?| 00000010 2e 42 9c 15 83 25 6a 39 e5 1b f7 a6 2c 85 c9 a5 |.B...%j9?.??,.ɥ| 00000020 $ open s s l bf -d -k apple2 -in tes t.en c MacBook Air $ open s s l bf -P -k apple2 salt=17731E3E93896C77 key=3C27DE1D1DD84C0FA67B6A49E423DF4A iv =B7FBF5536765B277 $ ech o 'MacBook Air' | open s s l bf -e -K 3 C2 7 DE1 D1 DD8 4 C0 FA6 7 B6 A4 9 E4 2 3 DF4 A -iv B7 FBF5 5 3 6 7 6 5 B2 7 7 -ou t tes t3 .en c $ h exdu m p -C tes t3 .en c 00000000 25 d0 54 e1 59 fa 67 11 13 16 32 7a c8 87 b6 8b |%?T?Y?g...2z?.?.| 00000010 $ ech o 'MacBook Air' | open s s l bf -e -K 3 C2 7 DE1 D1 DD8 4 C0 FA6 7 B6 A4 9 E4 2 3 DF4 A -iv B7 FBF5 5 3 6 7 6 5 B2 7 7 -ou t tes t4 .en c $ h exdu m p -C tes t4 .en c 00000000 25 d0 54 e1 59 fa 67 11 13 16 32 7a c8 87 b6 8b |%?T?Y?g...2z?.?.| 00000010 $ open s s l bf -in tes t3 .en c -d -K 3 C2 7 DE1 D1 DD8 4 C0 FA6 7 B6 A4 9 E4 2 3 DF4 A -iv B7 FBF5 5 3 6 7 6 5 B2 7 7 MacBook Air file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_OpenSSL-msyk/index.html 2/5
  • 4. 2014/2/23 Cocoa #27 QuickLook #import "AppController.h" @implementation AppController - (void)awakeFromNib { NSString *rPath = [[NSBundle mainBundle] resourcePath]; NSString *encFile = [rPath stringByAppendingPathComponent:@"data.enc"]; /* $ openssl bf -P -k apple2 salt=17731E3E93896C77 key=3C27DE1D1DD84C0FA67B6A49E423DF4A iv =B7FBF5536765B277 */ NSData* encData = [NSData dataWithContentsOfFile: encFile]; NSString* originalString = [[NSString alloc]initWithData: encData encoding: NSASCIIStringEncoding]; [originalText insertText: originalString]; int plainlen, tmplen; unsigned char iv[8] = {0xB7, 0xFB, 0xF5, 0x53, 0x67, 0x65, 0xB2, 0x77}; unsigned char key[16] = {0x3C, 0x27, 0xDE, 0x1D, 0x1D, 0xD8, 0x4C, 0x0F, 0xA6, 0x7B, 0x6A, 0x49, 0xE4, 0x23, 0xDF, 0x4A}; unsigned char* inData; unsigned char* outData; inData = (unsigned char*)[encData bytes]; int inDataLen = [encData length]; outData = malloc(inDataLen + 8); EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX_init( &ctx ); EVP_DecryptInit( &ctx, EVP_bf_cbc(), key ,iv ); int resultUpdate = EVP_DecryptUpdate( &ctx, outData, &plainlen, inData, inDataLen); int resultFinal = EVP_DecryptFinal( &ctx, outData + plainlen, &tmplen); EVP_CIPHER_CTX_cleanup(&ctx); if ( ( resultFinal != 1 ) || ( resultUpdate != 1 ) ) { [decriptedText insertText: @"Decription was not succeed." ]; } else { outData[ plainlen + tmplen ] = 0; NSString* decriptedString = [NSString stringWithUTF8String: (char*)outData]; [decriptedText insertText: decriptedString ]; } free(outData); } file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_OpenSSL-msyk/index.html 4/5