From 37023024b7ce52fbb7b201ab5ea614208d8014dc Mon Sep 17 00:00:00 2001 From: morkt Date: Thu, 29 Sep 2016 11:30:01 +0400 Subject: [PATCH] (NS2): use different encryption for keys shorter than 96 bytes. --- ArcFormats/NScripter/ArcNS2.cs | 16 +++++++++++----- supported.html | 12 ++++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/ArcFormats/NScripter/ArcNS2.cs b/ArcFormats/NScripter/ArcNS2.cs index b5136860..4af017ef 100644 --- a/ArcFormats/NScripter/ArcNS2.cs +++ b/ArcFormats/NScripter/ArcNS2.cs @@ -75,10 +75,8 @@ namespace GameRes.Formats.NScripter if (string.IsNullOrEmpty (password)) return null; var key = Encoding.ASCII.GetBytes (password); - if (key.Length < 96) - throw new OperationCanceledException ("Password should be at least 96 characters long"); - using (var input = new Ns2Stream (file, key)) + using (var input = OpenEncryptedStream (file, key)) { dir = ReadIndex (input); if (null == dir) @@ -132,10 +130,18 @@ namespace GameRes.Formats.NScripter { return arc.File.CreateStream (entry.Offset, entry.Size); } - var encrypted = new Ns2Stream (arc.File, nsa_arc.Key); + var encrypted = OpenEncryptedStream (arc.File, nsa_arc.Key); return new StreamRegion (encrypted, entry.Offset, entry.Size); } + Stream OpenEncryptedStream (ArcView file, byte[] key) + { + if (key.Length < 96) + return new EncryptedViewStream (file, key); + else + return new Ns2Stream (file, key); + } + private string QueryPassword () { var options = Query (arcStrings.ArcEncryptedNotice); @@ -165,7 +171,7 @@ namespace GameRes.Formats.NScripter { byte[] m_key; - static readonly Cryptography.MD5 MD5 = new Cryptography.MD5(); + readonly Cryptography.MD5 MD5 = new Cryptography.MD5(); const int BlockSize = 32; diff --git a/supported.html b/supported.html index e4b07182..18b63956 100644 --- a/supported.html +++ b/supported.html @@ -71,6 +71,7 @@ Eiyuu x Maou
Wasurenagusa ~Forget-me-Not~
*.gsp-NoGSD +Asanagi no Aquanauts
I Cup Bonyuu Kangofu
Natsuiro ☆ Communication ♪
Saimin Gakuen
@@ -176,6 +177,8 @@ Ren'ai Jugyou ~Oshiego no Yuuwaku~
*.nsa
*.sar-Yes1NScripter Binary Pot
Chou Gedou Yuusha
+Shinshoku ~Inma no Ikenie~
+Shinshoku 2 ~Inma no Ikenie~
Tsukihime
Umineko
@@ -490,6 +493,7 @@ Tsurugi Otome Noah
*.pmp
*.pmw-YesScenePlayer Eraburu ~Erabu + Love x Double de~
Nyuujoku Hitozuma Jogakuen
+WW&F ~Taishou Teito Denkitan~
*.datGAMEDAT PACK
GAMEDAT PAC2No bootUP!
Pajamas Soft
Aries Aneimo 2 ~Second Stage~
@@ -732,9 +736,10 @@ Majiresu!! ~Omatase Little Wing~
*.arg
*.argbBGRANo *.pacPACKNoEmic +Chikan Densha Otoko ~Densetsu no Target~
Futamajo
-*.bmpMWPNo +*.bmpMWP
TEYLNo *.dat+*l.dat-
GLNKNoStudio Miris
Caligula Itadaki Jangarian
Tetsuwan Gacchu!
@@ -862,6 +867,7 @@ Gakuen Saimin Reido
*.akbAKBNo *.cpzCPZ5
CPZ6NoCMVS +Amatsutsumi
Chrono Clock
Hapymaher
Haruiro Ouse
@@ -1093,8 +1099,10 @@ Denpa no Dorei
Soushinjutsu Plus
Soushinjutsu 2
-*.ns2-NoNScripter +*.ns2-NoNScripter2 Rakuin Hime Runed Princess
+Shinshoku -Zero- ~Inma no Ikenie~
+Shinshoku 3 ~Inma no Ikenie~
*.dat-NoNekoSDK Elevator Panic ~Misshitsu no Inkou~