Use a shorter repository id in the URL, to simplify a tiny bit
This commit is contained in:
parent
3f3c9f05fc
commit
4fe095e1c7
2 changed files with 8 additions and 7 deletions
|
@ -23,8 +23,8 @@ Example use::
|
|||
git remote add cryptremote gcrypt::ssh://example.com:repo
|
||||
git push cryptremote master
|
||||
> gcrypt: Setting up new repository at ssh://example.com:repo
|
||||
> gcrypt: Repository ID is 99b45a84a13168fc5efe
|
||||
> gcrypt: Repository URL is gcrypt::ssh://example.com:repo/G/99b45a84a13168fc5efe
|
||||
> gcrypt: Repository ID is KNBr0wKzct52
|
||||
> gcrypt: Repository URL is gcrypt::ssh://example.com:repo/G/KNBr0wKzct52
|
||||
> gcrypt: (configuration for cryptremote updated)
|
||||
> [ more lines .. ]
|
||||
> To gcrypt::[...]
|
||||
|
|
|
@ -217,9 +217,10 @@ PRIVDECRYPT()
|
|||
})
|
||||
}
|
||||
|
||||
# Generate $1 random bytes
|
||||
genkey()
|
||||
{
|
||||
gpg --armor --gen-rand 1 128 | tr -d \\n
|
||||
gpg --armor --gen-rand 1 "$1"
|
||||
}
|
||||
|
||||
pack_hash()
|
||||
|
@ -260,15 +261,15 @@ make_new_repo()
|
|||
local urlid_= fix_config=
|
||||
echo_info "Setting up new repository at $URL"
|
||||
PUTREPO "$URL"
|
||||
Masterkey="$(genkey)"
|
||||
Masterkey="$(genkey 128)"
|
||||
|
||||
# We need a relatively short ID for URL+REPO
|
||||
# The manifest will be stored at SHA224(urlid_)
|
||||
# Needed assumption: the same user should have no duplicate urlid_
|
||||
# For now, we use 20 random hex digits (80 bits), can be increased
|
||||
urlid_=$(genkey | pack_hash | cut -c 1-20)
|
||||
# For now, we arbitrarily use 9 random bytes (72 bits)
|
||||
urlid_=$(genkey 9 | tr '/+' 'Zz')
|
||||
Repoid=$(xecho_n "$urlid_" | pack_hash)
|
||||
echo_info "Repository ID is" "$urlid_"
|
||||
echo_info "Repository ID is" "$urlid_"
|
||||
isnoteq "${NAME#gcrypt::}" "$URL" && {
|
||||
git config "remote.$NAME.url" "gcrypt::$URL/G/$urlid_"
|
||||
fix_config=1
|
||||
|
|
Loading…
Reference in a new issue