Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cellframe-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
16
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
cellframe-sdk
Commits
eb9ee6d7
Commit
eb9ee6d7
authored
1 year ago
by
daniil.frolov
Browse files
Options
Downloads
Patches
Plain Diff
[+] Add receipt provider sign verification
parent
f4e3da9e
No related branches found
Branches containing commit
No related tags found
1 merge request
!1078
features-8615
Pipeline
#25871
passed with stage
in 7 minutes and 48 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/net/srv/dap_chain_net_srv.c
+39
-4
39 additions, 4 deletions
modules/net/srv/dap_chain_net_srv.c
with
39 additions
and
4 deletions
modules/net/srv/dap_chain_net_srv.c
+
39
−
4
View file @
eb9ee6d7
...
...
@@ -678,14 +678,49 @@ static bool s_pay_verificator_callback(dap_ledger_t * a_ledger,dap_hash_fast_t *
dap_chain_datum_tx_item_get
(
a_tx_in
,
NULL
,
TX_ITEM_TYPE_RECEIPT
,
NULL
);
if
(
!
l_receipt
)
return
false
;
dap_sign_t
*
l_sign
=
dap_chain_datum_tx_receipt_sign_get
(
l_receipt
,
l_receipt
->
size
,
1
);
// Check provider sign
dap_sign_t
*
l_sign
=
dap_chain_datum_tx_receipt_sign_get
(
l_receipt
,
l_receipt
->
size
,
0
);
if
(
!
l_sign
)
return
false
;
dap_hash_fast_t
l_pkey_hash
;
if
(
dap_sign_verify_all
(
l_sign
,
l_sign
->
header
.
sign_pkey_size
+
l_sign
->
header
.
sign_size
,
&
l_receipt
->
receipt_info
,
sizeof
(
l_receipt
->
receipt_info
))){
return
false
;
}
// Checking that the signature matches the provider's signature
dap_hash_fast_t
l_tx_sign_pkey_hash
=
{};
dap_hash_fast_t
l_provider_pkey_hash
=
{};
if
(
!
dap_sign_get_pkey_hash
(
l_sign
,
&
l_provider_pkey_hash
))
return
false
;
int
l_item_size
=
0
;
uint8_t
*
l_sig
=
dap_chain_datum_tx_item_get
(
a_tx_in
,
0
,
TX_ITEM_TYPE_SIG
,
&
l_item_size
);
if
(
!
l_sig
){
return
false
;
}
l_sign
=
dap_chain_datum_tx_item_sign_get_sig
((
dap_chain_tx_sig_t
*
)
l_sig
);
if
(
!
l_sign
||
!
dap_sign_get_pkey_hash
(
l_sign
,
&
l_tx_sign_pkey_hash
))
return
false
;
if
(
!
dap_hash_fast_compare
(
&
l_tx_sign_pkey_hash
,
&
l_provider_pkey_hash
)){
return
false
;
}
// Check client sign
l_sign
=
dap_chain_datum_tx_receipt_sign_get
(
l_receipt
,
l_receipt
->
size
,
1
);
if
(
!
l_sign
)
return
false
;
dap_hash_fast_t
l_pkey_hash
=
{};
if
(
!
dap_sign_get_pkey_hash
(
l_sign
,
&
l_pkey_hash
))
return
false
;
return
dap_hash_fast_compare
(
&
l_pkey_hash
,
&
a_cond
->
subtype
.
srv_pay
.
pkey_hash
);
// TODO add comparision a_tx sign pkey with receipt provider sign pkey
if
(
!
dap_hash_fast_compare
(
&
l_pkey_hash
,
&
a_cond
->
subtype
.
srv_pay
.
pkey_hash
)){
return
false
;
}
return
true
;
}
int
dap_chain_net_srv_parse_pricelist
(
dap_chain_net_srv_t
*
a_srv
,
const
char
*
a_config_section
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment