Skip to content

Conversation

@Zhaars
Copy link
Contributor

@Zhaars Zhaars commented Feb 1, 2023

What has been done in this PR?

Currently, acra-keys export/import command supports keys from V2 keystore only, the idea was to add support for V1 keystore as well under one tool. But we have different utility that has similar functionality for backup keys of V1 keystore - acra-backup. As the result acra-backup functionality was merged under acra-keys export/import

Technically, there were introduced new interfaces keystore.Exporter for export subcommand and keystore.Importer for import subcommand. Corresponded _Backupers were implemented for keystores V1 and V2.

The important thing, is that acra-keys export interface was the following - it could be possible to export all keys from keystore via --all flags or export some special key by specifying exportID in the format like (client/client_test/storage) - which represent a relative path to the key in the keystore. Since all our subcommands inside acra-keys tool operate with a generic key definition (e.g poison-record, client/{some_client}/symmetric, etc) the same functionality was added for acra-keys export too, but specifying key as path was saved for backward compatibility reasons.

Checklist

Extend acra-keys export/import subcommand with V1 keystore support
@Zhaars Zhaars requested review from Lagovas and iamnotacake February 1, 2023 09:40
Added comments for eported types
Copy link
Collaborator

@Lagovas Lagovas left a comment

Choose a reason for hiding this comment

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

can you add description to PR what actually was done from the general view? like logic of acra-backup which ere implemented only for v1, moved to acra-keys import/export. Keystore v1 extended with implementation of interface X1, X2. Keystore v2 extended with Y1, Y2...

// Export only public key data.
ExportPublicOnly ExportMode = 0
// Export private and public key data.
ExportPrivateKeys = (1 << iota)
Copy link
Collaborator

Choose a reason for hiding this comment

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

hm, what the logic of such assigning?) 0, 1, 4... it's 000, 001, 100 in binary format..
if it just moved from acra-backup here and these values weren't dumped somewhere and used only internally, we can use more predictable values for that. Just iota or 1 << iota if we want use them as bit masks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, will fix the mask creation

Extend acra-keys export to work with keyID and key paths
Fixed acra-keys configs
},
{
KeyKind: keystore.KeyPath,
ContextID: []byte("testclientid_storage_sym"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

you are cheater )) compile arguments programmatically to test both cases ))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will add parsing from arguments)


if len(exportIDs) != 0 {
for _, exportID := range exportIDs {
switch exportID.KeyKind {
Copy link
Collaborator

Choose a reason for hiding this comment

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

please, add comment that we additionally verify public keys and do not for private keys due to they are encrypted and will be validated on the decryption step. because in the future a question will arise as why so and do we need validate private keys too


// DescribeKeyFile describes key by its purpose path for V1 and V2 keystore
func DescribeKeyFile(fileName string) (*keystore.KeyDescription, error) {
description, ok, err := describeV2(fileName)
Copy link
Collaborator

Choose a reason for hiding this comment

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

cool

@Zhaars Zhaars merged commit 47b679b into master Feb 6, 2023
@Lagovas Lagovas deleted the zhars/extend_acra_keys_export_import branch October 10, 2025 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants