Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport HMACContext to 3.x #48869

Merged
merged 1 commit into from
May 21, 2021
Merged

Conversation

tavurth
Copy link
Contributor

@tavurth tavurth commented May 19, 2021

I backported this PR #43536

Thank you @jonbonazza!

I also tested with this simple script from the docs:

godotengine/godot-proposals#1098

extends Control

var ctx = HMACContext.new()

func _ready():
	var key = "supersecret".to_utf8()
	var err = ctx.start(HashingContext.HASH_SHA256, key)
	assert(err == OK)
	var msg1 = "this is ".to_utf8()
	var msg2 = "vewy vewy secret".to_utf8()
	err = ctx.update(msg1)
	assert(err == OK)
	err = ctx.update(msg2)
	assert(err == OK)
	var hmac = ctx.finish()
	print(hmac.hex_encode())

godotengine/godot-proposals#1127

@tavurth tavurth requested review from a team as code owners May 19, 2021 23:09
@tavurth tavurth changed the title Backport HMac crypto to 3.x Backport AESContext crypto (Hmac) to 3.x May 19, 2021
@Calinou Calinou added this to the 3.4 milestone May 19, 2021
@tavurth tavurth force-pushed the feature/hmac-port branch 2 times, most recently from 07e9bb6 to 9795a27 Compare May 19, 2021 23:28
Copy link
Collaborator

@Faless Faless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script you mention in the PR is not the one for HMAContext, but for AESContext (which was already backported).
The tests in main/tests/* cannot be run as they are not called in main_test.cpp and would not compile anyway due to missing references.
We can either skip those, or add the missing functions.

@Faless Faless changed the title Backport AESContext crypto (Hmac) to 3.x Backport HMACContext to 3.x May 20, 2021
@tavurth
Copy link
Contributor Author

tavurth commented May 20, 2021

Thank you for the review @Faless!

I've made the changes you requested, since those tests won't run anyway (/mbedtls/tests I couldn't figure out the dependency tree) I removed them for now.

I updated the PR description with the ammended HMAC test, sorry my mistake for that. I checked and it's working also.

I couldn't find how to run tests locally, is that documented anywhere?

@Faless
Copy link
Collaborator

Faless commented May 20, 2021

I couldn't find how to run tests locally

bin/godot --test crypto

@tavurth
Copy link
Contributor Author

tavurth commented May 20, 2021

Thank you!

                                                                                                                                                     15m ⚑
▶ ./bin/godot.osx.tools.x86_64 --test crypto
arguments
0: ./bin/godot.osx.tools.x86_64
1: --test
2: crypto
Current path: /Users/will/src/godot
Godot Engine v3.4.beta.custom_build.0f88bdc07 - https://godotengine.org
OpenGL ES 3.0 Renderer: Intel(R) Iris(TM) Plus Graphics 655
OpenGL ES Batching: ON

Registered camera FaceTime HD Camera (Built-in) with id 1 position 0 at index 0
	PASS

Passed 1 of 1 tests

Fix headers

Fix docs formatting

Changes for PR

Fix tests
#include "core/crypto/crypto.h"
#include "core/os/os.h"

namespace TestCrypto {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the test pass when compiling with module_mbedtls_enabled=no?

Copy link
Contributor Author

@tavurth tavurth May 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I compiled just now using:

scons platform=osx arch=x86_64 module_mbedtls_enabled=no --jobs=$(sysctl -n hw.logicalcpu)

And tests are passing, is that correct?

Copy link
Collaborator

@Faless Faless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! 👍

@akien-mga akien-mga merged commit 2660faf into godotengine:3.x May 21, 2021
@akien-mga
Copy link
Member

Thanks! And congrats for your first merged Godot contribution 🎉

@tavurth
Copy link
Contributor Author

tavurth commented May 21, 2021

Thank you @akien-mga @Faless!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants