Minor rename
This commit is contained in:
parent
985a7ccc78
commit
9b50fbfa35
4 changed files with 19 additions and 48 deletions
|
@ -1,29 +0,0 @@
|
|||
package debuglog
|
||||
|
||||
import (
|
||||
"cli-go/pkg/model"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// This file contains functions that are used to print debug information to the console.
|
||||
|
||||
func PrintAlbum(a *model.RemoteAlbum) {
|
||||
fmt.Printf("=======\n")
|
||||
fmt.Printf("ID: %d\n", a.ID)
|
||||
fmt.Printf("OwnerID: %d\n", a.OwnerID)
|
||||
if a.IsShared {
|
||||
fmt.Printf("Shared album")
|
||||
}
|
||||
fmt.Printf(" Name: %s\n", a.AlbumName)
|
||||
if a.PrivateMeta != nil {
|
||||
fmt.Printf("PrivateMeta: %s\n", a.PrivateMeta)
|
||||
}
|
||||
if a.PublicMeta != nil {
|
||||
fmt.Printf("PublicMeta: %s\n", a.PublicMeta)
|
||||
}
|
||||
if a.SharedMeta != nil {
|
||||
fmt.Printf("SharedMeta: %s\n", a.SharedMeta)
|
||||
}
|
||||
fmt.Printf("LastUpdatedAt: %d", a.LastUpdatedAt)
|
||||
fmt.Printf("\n=======")
|
||||
}
|
|
@ -2,7 +2,7 @@ package pkg
|
|||
|
||||
import (
|
||||
"cli-go/internal/api"
|
||||
enteCrypto "cli-go/internal/crypto"
|
||||
eCrypto "cli-go/internal/crypto"
|
||||
"cli-go/pkg/model"
|
||||
"cli-go/utils/encoding"
|
||||
"context"
|
||||
|
@ -26,7 +26,7 @@ func (c *ClICtrl) mapCollectionToAlbum(ctx context.Context, collection api.Colle
|
|||
album.AlbumKey = *model.MakeEncString(collectionKey, c.CliKey)
|
||||
var name string
|
||||
if collection.EncryptedName != "" {
|
||||
decrName, err := enteCrypto.SecretBoxOpenBase64(collection.EncryptedName, collection.NameDecryptionNonce, collectionKey)
|
||||
decrName, err := eCrypto.SecretBoxOpenBase64(collection.EncryptedName, collection.NameDecryptionNonce, collectionKey)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to decrypt collection name: %v", err)
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ func (c *ClICtrl) mapCollectionToAlbum(ctx context.Context, collection api.Colle
|
|||
}
|
||||
album.AlbumName = name
|
||||
if collection.MagicMetadata != nil {
|
||||
_, encodedJsonBytes, err := enteCrypto.DecryptChaChaBase64(collection.MagicMetadata.Data, collectionKey, collection.MagicMetadata.Header)
|
||||
_, encodedJsonBytes, err := eCrypto.DecryptChaChaBase64(collection.MagicMetadata.Data, collectionKey, collection.MagicMetadata.Header)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ func (c *ClICtrl) mapCollectionToAlbum(ctx context.Context, collection api.Colle
|
|||
}
|
||||
}
|
||||
if collection.PublicMagicMetadata != nil {
|
||||
_, encodedJsonBytes, err := enteCrypto.DecryptChaChaBase64(collection.PublicMagicMetadata.Data, collectionKey, collection.PublicMagicMetadata.Header)
|
||||
_, encodedJsonBytes, err := eCrypto.DecryptChaChaBase64(collection.PublicMagicMetadata.Data, collectionKey, collection.PublicMagicMetadata.Header)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ func (c *ClICtrl) mapCollectionToAlbum(ctx context.Context, collection api.Colle
|
|||
}
|
||||
}
|
||||
if album.IsShared && collection.SharedMagicMetadata != nil {
|
||||
_, encodedJsonBytes, err := enteCrypto.DecryptChaChaBase64(collection.SharedMagicMetadata.Data, collectionKey, collection.SharedMagicMetadata.Header)
|
||||
_, encodedJsonBytes, err := eCrypto.DecryptChaChaBase64(collection.SharedMagicMetadata.Data, collectionKey, collection.SharedMagicMetadata.Header)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ func (c *ClICtrl) mapApiFileToPhotoFile(ctx context.Context, album model.RemoteA
|
|||
return nil, errors.New("file is deleted")
|
||||
}
|
||||
albumKey := album.AlbumKey.MustDecrypt(c.CliKey)
|
||||
fileKey, err := enteCrypto.SecretBoxOpen(
|
||||
fileKey, err := eCrypto.SecretBoxOpen(
|
||||
encoding.DecodeBase64(file.EncryptedKey),
|
||||
encoding.DecodeBase64(file.KeyDecryptionNonce),
|
||||
albumKey)
|
||||
|
@ -95,7 +95,7 @@ func (c *ClICtrl) mapApiFileToPhotoFile(ctx context.Context, album model.RemoteA
|
|||
}
|
||||
}
|
||||
if file.Metadata.DecryptionHeader != "" {
|
||||
_, encodedJsonBytes, err := enteCrypto.DecryptChaChaBase64(file.Metadata.EncryptedData, fileKey, file.Metadata.DecryptionHeader)
|
||||
_, encodedJsonBytes, err := eCrypto.DecryptChaChaBase64(file.Metadata.EncryptedData, fileKey, file.Metadata.DecryptionHeader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ func (c *ClICtrl) mapApiFileToPhotoFile(ctx context.Context, album model.RemoteA
|
|||
}
|
||||
}
|
||||
if file.MagicMetadata != nil {
|
||||
_, encodedJsonBytes, err := enteCrypto.DecryptChaChaBase64(file.MagicMetadata.Data, fileKey, file.MagicMetadata.Header)
|
||||
_, encodedJsonBytes, err := eCrypto.DecryptChaChaBase64(file.MagicMetadata.Data, fileKey, file.MagicMetadata.Header)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ func (c *ClICtrl) mapApiFileToPhotoFile(ctx context.Context, album model.RemoteA
|
|||
}
|
||||
}
|
||||
if file.PubicMagicMetadata != nil {
|
||||
_, encodedJsonBytes, err := enteCrypto.DecryptChaChaBase64(file.PubicMagicMetadata.Data, fileKey, file.PubicMagicMetadata.Header)
|
||||
_, encodedJsonBytes, err := eCrypto.DecryptChaChaBase64(file.PubicMagicMetadata.Data, fileKey, file.PubicMagicMetadata.Header)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package secrets
|
|||
|
||||
import (
|
||||
"cli-go/internal/api"
|
||||
enteCrypto "cli-go/internal/crypto"
|
||||
eCrypto "cli-go/internal/crypto"
|
||||
"cli-go/pkg/model"
|
||||
"cli-go/utils/encoding"
|
||||
"context"
|
||||
|
@ -52,7 +52,7 @@ func (k *KeyHolder) GetCollectionKey(ctx context.Context, collection api.Collect
|
|||
accSecretInfo := k.GetAccountSecretInfo(ctx)
|
||||
userID := ctx.Value("user_id").(int64)
|
||||
if collection.Owner.ID == userID {
|
||||
collKey, err := enteCrypto.SecretBoxOpen(
|
||||
collKey, err := eCrypto.SecretBoxOpen(
|
||||
encoding.DecodeBase64(collection.EncryptedKey),
|
||||
encoding.DecodeBase64(collection.KeyDecryptionNonce),
|
||||
accSecretInfo.MasterKey)
|
||||
|
@ -61,7 +61,7 @@ func (k *KeyHolder) GetCollectionKey(ctx context.Context, collection api.Collect
|
|||
}
|
||||
return collKey, nil
|
||||
} else {
|
||||
collKey, err := enteCrypto.SealedBoxOpen(encoding.DecodeBase64(collection.EncryptedKey),
|
||||
collKey, err := eCrypto.SealedBoxOpen(encoding.DecodeBase64(collection.EncryptedKey),
|
||||
accSecretInfo.PublicKey, accSecretInfo.SecretKey)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("shared collection %d key drive failed %s", collection.ID, err)
|
||||
|
|
|
@ -3,7 +3,7 @@ package pkg
|
|||
import (
|
||||
"cli-go/internal"
|
||||
"cli-go/internal/api"
|
||||
enteCrypto "cli-go/internal/crypto"
|
||||
eCrypto "cli-go/internal/crypto"
|
||||
"cli-go/pkg/model"
|
||||
"cli-go/utils/encoding"
|
||||
"context"
|
||||
|
@ -21,12 +21,12 @@ func (c *ClICtrl) signInViaPassword(ctx context.Context, email string, srpAttr *
|
|||
return nil, nil, flowErr
|
||||
}
|
||||
fmt.Println("\nPlease wait authenticating...")
|
||||
keyEncKey, err := enteCrypto.DeriveArgonKey(password, srpAttr.KekSalt, srpAttr.MemLimit, srpAttr.OpsLimit)
|
||||
keyEncKey, err := eCrypto.DeriveArgonKey(password, srpAttr.KekSalt, srpAttr.MemLimit, srpAttr.OpsLimit)
|
||||
if err != nil {
|
||||
fmt.Printf("error deriving key encryption key: %v", err)
|
||||
return nil, nil, err
|
||||
}
|
||||
loginKey := enteCrypto.DeriveLoginKey(keyEncKey)
|
||||
loginKey := eCrypto.DeriveLoginKey(keyEncKey)
|
||||
|
||||
srpParams := srp.GetParams(4096)
|
||||
identify := []byte(srpAttr.SRPUserID.String())
|
||||
|
@ -70,7 +70,7 @@ func (c *ClICtrl) decryptAccSecretInfo(
|
|||
return nil, flowErr
|
||||
}
|
||||
fmt.Println("\nPlease wait authenticating...")
|
||||
currentKeyEncKey, err = enteCrypto.DeriveArgonKey(password,
|
||||
currentKeyEncKey, err = eCrypto.DeriveArgonKey(password,
|
||||
authResp.KeyAttributes.KEKSalt, authResp.KeyAttributes.MemLimit, authResp.KeyAttributes.OpsLimit)
|
||||
if err != nil {
|
||||
fmt.Printf("error deriving key encryption key: %v", err)
|
||||
|
@ -82,7 +82,7 @@ func (c *ClICtrl) decryptAccSecretInfo(
|
|||
|
||||
encryptedKey := encoding.DecodeBase64(authResp.KeyAttributes.EncryptedKey)
|
||||
encryptedKeyNonce := encoding.DecodeBase64(authResp.KeyAttributes.KeyDecryptionNonce)
|
||||
masterKey, err = enteCrypto.SecretBoxOpen(encryptedKey, encryptedKeyNonce, currentKeyEncKey)
|
||||
masterKey, err = eCrypto.SecretBoxOpen(encryptedKey, encryptedKeyNonce, currentKeyEncKey)
|
||||
if err != nil {
|
||||
if keyEncKey != nil {
|
||||
fmt.Printf("Failed to get key from keyEncryptionKey %s", err)
|
||||
|
@ -92,7 +92,7 @@ func (c *ClICtrl) decryptAccSecretInfo(
|
|||
continue
|
||||
}
|
||||
}
|
||||
secretKey, err = enteCrypto.SecretBoxOpen(
|
||||
secretKey, err = eCrypto.SecretBoxOpen(
|
||||
encoding.DecodeBase64(authResp.KeyAttributes.EncryptedSecretKey),
|
||||
encoding.DecodeBase64(authResp.KeyAttributes.SecretKeyDecryptionNonce),
|
||||
masterKey,
|
||||
|
@ -101,7 +101,7 @@ func (c *ClICtrl) decryptAccSecretInfo(
|
|||
fmt.Printf("error decrypting master key: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
tokenKey, err = enteCrypto.SealedBoxOpen(
|
||||
tokenKey, err = eCrypto.SealedBoxOpen(
|
||||
encoding.DecodeBase64(authResp.EncryptedToken),
|
||||
publicKey,
|
||||
secretKey,
|
||||
|
|
Loading…
Add table
Reference in a new issue