FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Nethereum/src/Nethereum.KeyStore/KeyStoreScryptService.cs at master · Nethereum/Nethereum · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
Nethereum
/
Nethereum
Public
Notifications
You must be signed in to change notification settings
Fork
745
Star
2.3k
Code
Issues
103
Pull requests
5
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Nethereum
/
src
/
Nethereum.KeyStore
/
KeyStoreScryptService.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
68 lines (57 loc) · 2.35 KB
Breadcrumbs
Nethereum
/
src
/
Nethereum.KeyStore
/
KeyStoreScryptService.cs
Copy path
File metadata and controls
68 lines (57 loc) · 2.35 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using
System
;
using
Nethereum
.
Hex
.
HexConvertors
.
Extensions
;
using
Nethereum
.
KeyStore
.
Crypto
;
using
Nethereum
.
KeyStore
.
JsonDeserialisation
;
using
Nethereum
.
KeyStore
.
Model
;
namespace
Nethereum
.
KeyStore
{
public
class
KeyStoreScryptService
:
KeyStoreServiceBase
<
ScryptParams
>
{
public
const
string
KdfType
=
"scrypt"
;
public
KeyStoreScryptService
(
)
{
}
public
KeyStoreScryptService
(
IRandomBytesGenerator
randomBytesGenerator
,
KeyStoreCrypto
keyStoreCrypto
)
:
base
(
randomBytesGenerator
,
keyStoreCrypto
)
{
}
public
KeyStoreScryptService
(
IRandomBytesGenerator
randomBytesGenerator
)
:
base
(
randomBytesGenerator
)
{
}
protected
override
byte
[
]
GenerateDerivedKey
(
string
password
,
byte
[
]
salt
,
ScryptParams
kdfParams
)
{
return
KeyStoreCrypto
.
GenerateDerivedScryptKey
(
KeyStoreCrypto
.
GetPasswordAsBytes
(
password
)
,
salt
,
kdfParams
.
N
,
kdfParams
.
R
,
kdfParams
.
P
,
kdfParams
.
Dklen
)
;
}
protected
override
ScryptParams
GetDefaultParams
(
)
{
return
new
ScryptParams
{
Dklen
=
32
,
N
=
262144
,
R
=
1
,
P
=
8
}
;
}
public
override
KeyStore
<
ScryptParams
>
DeserializeKeyStoreFromJson
(
string
json
)
{
return
JsonKeyStoreScryptSerialiser
.
DeserialiseScrypt
(
json
)
;
}
public
override
string
SerializeKeyStoreToJson
(
KeyStore
<
ScryptParams
>
keyStore
)
{
return
JsonKeyStoreScryptSerialiser
.
SerialiseScrypt
(
keyStore
)
;
}
public
override
string
GetKdfType
(
)
{
return
KdfType
;
}
protected
override
byte
[
]
DecryptFromCryptoInfo
(
string
password
,
CryptoInfo
<
ScryptParams
>
cryptoInfo
)
{
if
(
password
==
null
)
throw
new
ArgumentNullException
(
nameof
(
password
)
)
;
if
(
cryptoInfo
==
null
)
throw
new
ArgumentNullException
(
nameof
(
cryptoInfo
)
)
;
return
KeyStoreCrypto
.
DecryptScrypt
(
password
,
cryptoInfo
.
Mac
.
HexToByteArray
(
)
,
cryptoInfo
.
CipherParams
.
Iv
.
HexToByteArray
(
)
,
cryptoInfo
.
CipherText
.
HexToByteArray
(
)
,
cryptoInfo
.
Kdfparams
.
N
,
cryptoInfo
.
Kdfparams
.
P
,
cryptoInfo
.
Kdfparams
.
R
,
cryptoInfo
.
Kdfparams
.
Salt
.
HexToByteArray
(
)
,
cryptoInfo
.
Kdfparams
.
Dklen
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL