This repository was archived by the owner on Apr 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,20 @@ module.exports.CryptoSuite = class {
155
155
* @returns {byte[] } Plain text after decryption
156
156
*/
157
157
decrypt ( key , ciphertext , opts ) { if ( key || ciphertext || opts ) ; }
158
+
159
+ /**
160
+ * Set the cryptoKeyStore.
161
+ *
162
+ * When the application needs to use a key store other than the default,
163
+ * it should use the {@link Client} newCryptoKeyStore to create an instance and
164
+ * use this function to set the instance on the CryptoSuite.
165
+ *
166
+ * @param {CryptoKeyStore } cryptoKeyStore The cryptoKeyStore.
167
+ * @abstract
168
+ */
169
+ setCryptoKeyStore ( cryptoKeyStore ) {
170
+ throw new Error ( 'Can\'t call abstract method, must be implemented by sub-class!' ) ;
171
+ }
158
172
} ;
159
173
160
174
/**
Original file line number Diff line number Diff line change @@ -102,14 +102,15 @@ declare namespace Client {
102
102
103
103
export interface ICryptoSuite {
104
104
decrypt ( key : ICryptoKey , cipherText : Buffer , opts : any ) : Buffer ;
105
- deriveKey ( key : ICryptoKey ) : ICryptoKey ;
105
+ deriveKey ( key : ICryptoKey , opts ?: KeyOpts ) : ICryptoKey ;
106
106
encrypt ( key : ICryptoKey , plainText : Buffer , opts : any ) : Buffer ;
107
107
getKey ( ski : string ) : Promise < ICryptoKey > ;
108
- generateKey ( opts : KeyOpts ) : Promise < ICryptoKey > ;
108
+ generateKey ( opts ? : KeyOpts ) : Promise < ICryptoKey > ;
109
109
hash ( msg : string , opts : any ) : string ;
110
- importKey ( pem : string , opts : KeyOpts ) : ICryptoKey | Promise < ICryptoKey > ;
110
+ importKey ( pem : string , opts ? : KeyOpts ) : ICryptoKey | Promise < ICryptoKey > ;
111
111
sign ( key : ICryptoKey , digest : Buffer ) : Buffer ;
112
112
verify ( key : ICryptoKey , signature : Buffer , digest : Buffer ) : boolean ;
113
+ setCryptoKeyStore ( cryptoKeyStore : ICryptoKeyStore ) : void ;
113
114
}
114
115
115
116
export interface UserConfig {
Original file line number Diff line number Diff line change @@ -40,6 +40,8 @@ import {
40
40
Peer ,
41
41
Orderer ,
42
42
EventHub ,
43
+ ICryptoSuite ,
44
+ ICryptoKeyStore ,
43
45
} from 'fabric-client' ;
44
46
import { IEnrollmentRequest } from 'fabric-ca-client' ;
45
47
@@ -80,6 +82,13 @@ test('test Peer', (t) => {
80
82
t . end ( ) ;
81
83
} ) ;
82
84
85
+ test ( 'test-crypto-key-store' , ( t ) => {
86
+ const store :ICryptoKeyStore = Client . newCryptoKeyStore ( ) ;
87
+ const cryptoSuite : ICryptoSuite = Client . newCryptoSuite ( ) ;
88
+ cryptoSuite . setCryptoKeyStore ( store ) ;
89
+ t . end ( )
90
+ } )
91
+
83
92
test ( 'use the connection profile file' , ( t ) => {
84
93
const client = Client . loadFromConfig ( config_network ) ;
85
94
t . pass ( 'Successfully load config from network.yaml' ) ;
You can’t perform that action at this time.
0 commit comments