A link to my blog tracking my Beaglebone Black projects.
http://mybbbprojects.blogspot.com/
Friday, July 18, 2014
Sunday, June 29, 2014
Passing AES keys through RSA public key encryption (PERL)
I've been interested with encryption for a while but never found a reason to actually write any code about it until recently.
Here is a sample perl script that goes through the motions of passing AES 256 key through an RSA public key encryption and then goes on to decrypt a message encrypted with the AES key.
The encrypted AES key and the encrypted message are both encoded in base64 for passing through email or other ASCII method of transfer.
I wrote this script as a learning tool to understand the AES and RSA methods. Other than that this script has no usefulness.
You may use this script in whole or part to further your understanding of cryptography methods.
I make no claims that this is the best way to accomplish passing a key to someone but it is a method. I also make no claims that this code is correct and welcome any comments/suggestions to improve the process, especially the generation of the AES key. I have no idea if the method I use is considered secure.
############################################################################
#!/usr/local/bin/perl
use strict;
use warnings;
use Crypt::CBC;
use MIME::Base64;
use Crypt::OpenSSL::RSA;
use Digest::SHA qw(sha1 sha1_hex sha1_base64 sha384 sha512 sha512_hex sha512_base64 sha256 sha256_hex sha256_base64 hmac_sha256 hmac_sha256_base64 hmac_sha256_hex hmac_sha512 hmac_sha512_base64);
use Bytes::Random::Secure qw(
random_bytes random_bytes_base64 random_bytes_hex
);
##############################################################################
#Generate the keys
##############################################################################
print "#######################################################################
# Generate the keys
#######################################################################\n\n";
my (%rsa_key_pair); #using a hash to store my private/public and other public keys. The hash itself is not encrypted but that is trivial to fix once we learn how to do it with AES
#also since this is a tutorial we generate a new set of keys each time the script is run - in the real world we'd need to dig these keys out of a key file stored on a drive
#this key file should also be encrypted with a passphrase (not discussed in this tutorial)
print "Generating RSA key pair...\n\n";
my $rsa = Crypt::OpenSSL::RSA->generate_key(2048);
my $keyidx = $rsa->get_public_key_string() if defined $rsa; #get the index of the key-pair
$keyidx = sha512_hex( $keyidx, "" ); #hash the index
$keyidx = substr( $keyidx, 0, 6 ); #shorten the hash to 6 digits
$rsa_key_pair{$keyidx}{'pubK'} = $rsa->get_public_key_string(); #load the hash
$rsa_key_pair{$keyidx}{'privK'} = $rsa->get_private_key_string();
$rsa_key_pair{$keyidx}{'Local'} = 1;
my $rsa_public_key = $rsa_key_pair{$keyidx}{'pubK'}; #set local key variables - not necessary but convenient
my $rsa_private_key = $rsa_key_pair{$keyidx}{'privK'};
#print $rsa_private_key; #print them if you want to see them
#print "\n\n";
#print $rsa_public_key;
#print "\n\n";
print "Generating AES key...\n\n";
my $random_generator = Bytes::Random::Secure->new(
Bits => 64,
NonBlocking => 1,
); # Seed with 64 bits, and use /dev/urandom (or other non-blocking).
my $AES32byte_random = $random_generator->bytes(32); # A string of 32 random bytes which we'll use as the AES key
print "AES32byte_random: ";
print $AES32byte_random;
print "\nSizeof AES32byte_random: ";
print length $AES32byte_random;
print "\n\n";
##############################################################################
#The encryption process
##############################################################################
print "#######################################################################
# The Encryption Process
#######################################################################\n\n";
my $RSA_en_cipher = Crypt::OpenSSL::RSA->new_public_key($rsa_public_key); #create a new public key cipher object
my $binary_encrypted_key = $RSA_en_cipher->encrypt($AES32byte_random); # encrypt the AES key
print "Binary encrypted key: \n";
print $binary_encrypted_key;
print "\n\n";
my $encoded_encrypted_key = encode_base64($binary_encrypted_key); #encode the encrypted AES key - encrypt and encode can be combined in one line - this is a tutorial
print "Encoded encrypted key: \n" . $encoded_encrypted_key . "\n\n";
#at this point send the encoded encrypted key to the private key holder via email or text message etc.
#the message to encrypt - why we're doing this exercise - well one of the reasons anyway
my $cleartext = "This module is a Perl-only implementation of the cryptographic cipher block chaining mode (CBC).
In combination with a block cipher such as DES or IDEA, you can encrypt and decrypt messages of arbitrarily long length.
The encrypted messages are compatible with the encryption format used by the OpenSSL package.
To use this module, you will first create a Crypt::CBC cipher object with new().
At the time of cipher creation, you specify an encryption key to use and, optionally, a block encryption algorithm.
You will then call the start() method to initialize the encryption or decryption process,
crypt() to encrypt or decrypt one or more blocks of data, and lastly finish(), to pad and encrypt the final block.
For your convenience, you can call the encrypt() and decrypt() methods to operate on a whole data value at once.";
#create the AES encryption cipher object
my $AES_en_cryption_cipher = Crypt::CBC->new(
{
'key' => $AES32byte_random,
'cipher' => 'Rijndael',
'padding' => 'standard',
});
my $AES_en_crypted_message = $AES_en_cryption_cipher->encrypt($cleartext); #encrypt the message
print "Encrypted message:\n";
print $AES_en_crypted_message;
print "\n\n";
my $encoded_AES_en_crypted_message = encode_base64($AES_en_crypted_message); #encode the encrypted message to send via email etc.
print "Encoded encrypted message:\n";
print $encoded_AES_en_crypted_message;
print "\n\n";
#Now pass the message via email etc. to the other person who should now have the AES key decrypted so they can now decrypt the message
##############################################################################
#The decryption process - this happens at the private keyholder's side - this is a tutorial
##############################################################################
print "#######################################################################
# The Decryption Process
#######################################################################\n\n";
#decode
print "Decoding keys...\n";
my $encoded_decryption_key = $encoded_encrypted_key; #just to keep the variables separate - this also simulates the passing of the encrypted key via email etc.
print "Encoded decryption key: \n" . $encoded_decryption_key . "\n\n";
my $binary_decryption_key = decode_base64($encoded_decryption_key); #decode the key into binary so we can decrypt it
print "Binary decryption key: \n" . $binary_decryption_key . "\n\n";
#decrypt
print "Decrypting keys...\n";
my $RSA_de_cipher = Crypt::OpenSSL::RSA->new_private_key($rsa_private_key); # create a new decryption cipher object using the PRIVATE key
my $binary_decrypted_key = $RSA_de_cipher->decrypt($binary_decryption_key); # decrypt the AES key
print "Binary decrypted key: \n" . $binary_decrypted_key . "\n\n\n"; #this should be the binary 256bit binary AES key
#let's test that
print "Testing AES key pass through RSA public key encryption:\n\n";
print $AES32byte_random . "\n\n - should equal - \n\n" . $binary_decrypted_key . "\n\n"; #print the two binary keys - do they line up? - visual compare
if ($AES32byte_random eq $binary_decrypted_key) #let the computer compare then too
{
print "\nSUCCESS!\n\n";
}
else
{
print "\nFAIL! Now exiting!\n\n";
exit;
}
print "Now to decrypt the message with the passed AES key...\n\n";
#create a new AES encryption cipher object
my $AES_de_cryption_cipher = Crypt::CBC->new(
{
'key' => $binary_decrypted_key, #uses the binary AES key we just decoded and decrypted
'cipher' => 'Rijndael', #aka AES
'padding' => 'standard', #padding is a good thing so we can use this key more than once
});
my $message_to_decode = $encoded_AES_en_crypted_message; #here is the simulated encrypted message send through email etc.
print "Encoded message to decrypt:\n";
print $message_to_decode;
print "\n\n";
$message_to_decode = decode_base64($message_to_decode); #decode into binary
print "Decoded message to decrypt:\n";
print $message_to_decode;
print "\n\n";
my $decoded_message = $AES_de_cryption_cipher->decrypt($message_to_decode); #decode the message
print "Decrypted message:\n"; #should be the same as the $cleartext variable above
print $decoded_message;
print "\n\n";
#let's test it
print "Testing if decode was successful...\n";
if ($decoded_message eq $cleartext)
{
print "\nMessages match - SUCCESS!\n\n";
}
else
{
print "\nMessages do NOT match - FAIL! Now exiting!\n\n";
exit;
}
exit;
###################################################################
#script run output
###################################################################
#######################################################################
# Generate the keys
#######################################################################
Generating RSA key pair...
Generating AES key...
AES32byte_random: g&ÿ}■·ºQ♂╚rF░%Y¡▀}╨;┐█¶Ñ3~Ç≡╞ª►▒
Sizeof AES32byte_random: 32
#######################################################################
# The Encryption Process
#######################################################################
Binary encrypted key:
←╖Ä ▼╣è♥à☻;XÉzMIè√0H0Ω↨í░ônö╔≈z▓|1§⌐╚£*∙V☼ªE≡9╧'N┬N/àb╨Xjgzƒ█l4▲{═☻√■W╬p☺╢7ê
x.╪K
z5♦!Éèê¡*ä■⌠╥B╨CGPoΘ╝îσxδ╬╜;>9q]‼ε/Vτúf7îª╢ö╞Ü9┤&A«O╓
âh#╛F░-å♠▒╬╣♂∞╙┴≥`£╣≡■ó╤
BΓû║áy\ìÅ░3╢╢@à╟AF╨▄Σ╕╞;╜⌂2/ëδ§"Hîw┤║↔![╠↨3Æ>↔]cQå«{¿╦¼↕à╜┬←ôMfñ╥╕╬ú.æB∞Σ<û
Encoded encrypted key:
G7eOCR+5igOFAjtYkHpNSYr7MEgw6hehsJNulMn3erJ8MRWpyJwq+VYPpkXwOc8nTsJOL4Vi0Fhq
Z3qf22w0HnvNAvv+V85wAbY3iHgu2EsKejUEIZCKiK0qhP700kLQQ0dQb+m8jOV46869Oz45cV0T
7i9W56NmN4ymtpTGmjm0JkGuT9YKg2gjvkawLYYHBrHOuQvs08HyYJy58P6i0QokOP/ysLmx35d7
9PWhkz0vKig1DULilrqgeVyNj7AztrZAhcdBRtDc5LjGO71/Mi+J6xUiSIx3tLodIVvMFzOSPh1d
Y1GGrnuoy6wShb3CG5NNZqTSuM6jLpFC7OQ8lg==
Encrypted message:
σgò↨ⁿ¼╖báv+▒É▼¡êΦáª#gJ¼èo[ÖiV▲ª╘kÖ7v»wQa╩0g-Σ└ÖfVÖ♫╢æù8àΣ§gìºφ=æBΦCJ│äÆw■σB0¥ 2╔
æm╫>Cí▐▼Äc!3☻æY(ß╥¡ΦEôéM┌á─o?íτt▄┌█¿§Σtφ{▓¥«ε╕p☺↓Ç=3╥61≡D╡√ÜW⌡αow╒╝√Q⌡ò⌐╘(↓‼Xw♠Ä
┴Ö☻ª{ë╔Z▓ε♀]o4Éc+♥_¡α(▬"ºH♂ë\&K┌d$☺/z☼▲╙☻¼┤à)Γ╒>,▀\█♂NÅ:,└┐∙φ&L☼!7☺;m╚¬h≈┴à▼+♥│d
oYGR∙U;hÆKK╖¶Γ░♥@;çî╗E▀▒l≥╢P←é☺úIÜjg┬B▒~╧(δä5@ᬽ°╛L♫`τge‼íK%}¬fµé' k▀ä▌∙⌐S▒
)j╨╫♂2uäü⌂ºb↨8⌡≤x╨0▒"┬♦▌ñ»♫↓╛PÖ╦;nΘ,Éû▒å,8╔â↕╡'<»≡:╜╫c╫Ü▒Φ·LΓô;µ¬☻░G■±èJδT☼╘{█É↨
xg▲zôVQ♠▼↨├)►c╢$²╓τzùvßπX♣^╜YkPà↑Θ{j¶╚½½`î0«Æ╓⌐Ä│↑.ì▬₧▌►S♥└►Ü[¿x┐6N]i╘UµtF↕_S▄↔Ä
↑¿²├L}y*┤╠═Ä╝÷┘╣1╨# üB{¬°S┌☻*'≤ñúä▌]ö§Üε,üª╬ú6▬Vu'¶Σ0╡k!╛ûúÖE*_%☺╗ö╟▄bε╜²╤{V¼╨╗√f├╖╡I▼┼≤≤∟[Θⁿ7n┤≥Ñ╠╗♫ÑÇ┬8
♦☼·Hæ▓☺#ΣìY>[µ╗`
Encoded encrypted message:
U2FsdGVkX1/gYdAOA7DFcM46bvXhGmWpamEwDYOfHLc436Fpu5OBDFXnNFsmzB+EsOGMy/G1MRMp
nPNCc0jqDlFRiJ0HycUVoBqRvOjU2l2Smnlrsh31DeVnlRf8rLdioHYrsZAfrYjooKYjZ0qsim9b
mWlWHqbUa5k3dq93UWHKMGct5MCZZlaZDraRlziF5BVnjaftBz2RQuhDSrOEknf+5UIwnQAyyb1n
mMIlDmaYNBPheHqs53hWQz+AyHQz3ZRAxSCmbQ2Rbdc+Q6HeH45jITMCkVko4dKt6EWTgk3aoMRv
P6HndNza26gV5HTte7Kdru64cAEZgD0z0jYx8ES1+5pX9eBvd9W8+1H1lanUKBkTWHcGjsGZAqZ7
iclasu4MXW/sCDSQYysDX63gKBYip0gLiVwmS9pkJAEveg8e0wKstIUp4tU+LN9c2wtOjzoswL/5
7SZMDyE3ATttyKpo98GFHysDs2RvWUdS+VU7aJJLS7cU4rADQDuHjLtF37Fs8rZQG4IBo0maamfC
QrF+zyjrhDVAoKqr+L5MDmDnZ2UToUslfapm5oInCWvfhN35qVOxKWrQ1wsydYSBf6diFzj183jQ
MLEiwgTdpK8OGb5Qmcs7bukskJaxhiw4yYMStSc8r/A6vddj15qx6PpM4pM7FAjmqgKwR/7xikrr
VA/Ue9uQF3hnHnqTVlEGHxfDKRBjtgck/dbnepd24eNYBV69WWtQhRjpe2oUyKurYIwwrpLWqY6z
GC6NFp7dEFMDwBCaW6h4vzZOXWnUVeZ0RhJfU9wdjhrVX+R73ZhoT7FMnLkoYsi8twMVshxE6xNO
GEAXgsiT38SUzD4GvBUsJ+ian36XVR1wnoKxeOjlwCn9RWVkrWazEld/B+MNGKj9w0x9eSq0zM2O
vPbZuTHQI/+BQnuq+DxmOePe+W5UyrIEoVSlE0C84aSJw73FL5px57xlWL6XMH7Z5LVXs51bI/j4
KCNeNgPqE62wHiFT2gIqJ/Oko4TdXZQVmu4sgabOozYWVnUnFOQwtWshvpajmUUqXyUBu5TH3GLu
vf3Re1as0Lv7ZsO3tUkfxfPzHFvp/DdutPKlzLsOpYDCOAQP+kiRsgEj5I1ZPlvmu2A=
#######################################################################
# The Decryption Process
#######################################################################
Decoding keys...
Encoded decryption key:
G7eOCR+5igOFAjtYkHpNSYr7MEgw6hehsJNulMn3erJ8MRWpyJwq+VYPpkXwOc8nTsJOL4Vi0Fhq
Z3qf22w0HnvNAvv+V85wAbY3iHgu2EsKejUEIZCKiK0qhP700kLQQ0dQb+m8jOV46869Oz45cV0T
7i9W56NmN4ymtpTGmjm0JkGuT9YKg2gjvkawLYYHBrHOuQvs08HyYJy58P6i0QokOP/ysLmx35d7
9PWhkz0vKig1DULilrqgeVyNj7AztrZAhcdBRtDc5LjGO71/Mi+J6xUiSIx3tLodIVvMFzOSPh1d
Y1GGrnuoy6wShb3CG5NNZqTSuM6jLpFC7OQ8lg==
Binary decryption key:
←╖Ä ▼╣è♥à☻;XÉzMIè√0H0Ω↨í░ônö╔≈z▓|1§⌐╚£*∙V☼ªE≡9╧'N┬N/àb╨Xjgzƒ█l4▲{═☻√■W╬p☺╢7ê
x.╪K
z5♦!Éèê¡*ä■⌠╥B╨CGPoΘ╝îσxδ╬╜;>9q]‼ε/Vτúf7îª╢ö╞Ü9┤&A«O╓
âh#╛F░-å♠▒╬╣♂∞╙┴≥`£╣≡■ó╤
BΓû║áy\ìÅ░3╢╢@à╟AF╨▄Σ╕╞;╜⌂2/ëδ§"Hîw┤║↔![╠↨3Æ>↔]cQå«{¿╦¼↕à╜┬←ôMfñ╥╕╬ú.æB∞Σ<û
Decrypting keys...
Binary decrypted key:
g&ÿ}■·ºQ♂╚rF░%Y¡▀}╨;┐█¶Ñ3~Ç≡╞ª►▒
Testing AES key pass through RSA public key encryption:
g&ÿ}■·ºQ♂╚rF░%Y¡▀}╨;┐█¶Ñ3~Ç≡╞ª►▒
- should equal -
g&ÿ}■·ºQ♂╚rF░%Y¡▀}╨;┐█¶Ñ3~Ç≡╞ª►▒
SUCCESS!
Now to decrypt the message with the passed AES key...
Encoded message to decrypt:
U2FsdGVkX1/gYdAOA7DFcM46bvXhGmWpamEwDYOfHLc436Fpu5OBDFXnNFsmzB+EsOGMy/G1MRMp
nPNCc0jqDlFRiJ0HycUVoBqRvOjU2l2Smnlrsh31DeVnlRf8rLdioHYrsZAfrYjooKYjZ0qsim9b
mWlWHqbUa5k3dq93UWHKMGct5MCZZlaZDraRlziF5BVnjaftBz2RQuhDSrOEknf+5UIwnQAyyb1n
mMIlDmaYNBPheHqs53hWQz+AyHQz3ZRAxSCmbQ2Rbdc+Q6HeH45jITMCkVko4dKt6EWTgk3aoMRv
P6HndNza26gV5HTte7Kdru64cAEZgD0z0jYx8ES1+5pX9eBvd9W8+1H1lanUKBkTWHcGjsGZAqZ7
iclasu4MXW/sCDSQYysDX63gKBYip0gLiVwmS9pkJAEveg8e0wKstIUp4tU+LN9c2wtOjzoswL/5
7SZMDyE3ATttyKpo98GFHysDs2RvWUdS+VU7aJJLS7cU4rADQDuHjLtF37Fs8rZQG4IBo0maamfC
QrF+zyjrhDVAoKqr+L5MDmDnZ2UToUslfapm5oInCWvfhN35qVOxKWrQ1wsydYSBf6diFzj183jQ
MLEiwgTdpK8OGb5Qmcs7bukskJaxhiw4yYMStSc8r/A6vddj15qx6PpM4pM7FAjmqgKwR/7xikrr
VA/Ue9uQF3hnHnqTVlEGHxfDKRBjtgck/dbnepd24eNYBV69WWtQhRjpe2oUyKurYIwwrpLWqY6z
GC6NFp7dEFMDwBCaW6h4vzZOXWnUVeZ0RhJfU9wdjhrVX+R73ZhoT7FMnLkoYsi8twMVshxE6xNO
GEAXgsiT38SUzD4GvBUsJ+ian36XVR1wnoKxeOjlwCn9RWVkrWazEld/B+MNGKj9w0x9eSq0zM2O
vPbZuTHQI/+BQnuq+DxmOePe+W5UyrIEoVSlE0C84aSJw73FL5px57xlWL6XMH7Z5LVXs51bI/j4
KCNeNgPqE62wHiFT2gIqJ/Oko4TdXZQVmu4sgabOozYWVnUnFOQwtWshvpajmUUqXyUBu5TH3GLu
vf3Re1as0Lv7ZsO3tUkfxfPzHFvp/DdutPKlzLsOpYDCOAQP+kiRsgEj5I1ZPlvmu2A=
Decoded message to decrypt:
σgò↨ⁿ¼╖báv+▒É▼¡êΦáª#gJ¼èo[ÖiV▲ª╘kÖ7v»wQa╩0g-Σ└ÖfVÖ♫╢æù8àΣ§gìºφ=æBΦCJ│äÆw■σB0¥ 2╔
æm╫>Cí▐▼Äc!3☻æY(ß╥¡ΦEôéM┌á─o?íτt▄┌█¿§Σtφ{▓¥«ε╕p☺↓Ç=3╥61≡D╡√ÜW⌡αow╒╝√Q⌡ò⌐╘(↓‼Xw♠Ä
┴Ö☻ª{ë╔Z▓ε♀]o4Éc+♥_¡α(▬"ºH♂ë\&K┌d$☺/z☼▲╙☻¼┤à)Γ╒>,▀\█♂NÅ:,└┐∙φ&L☼!7☺;m╚¬h≈┴à▼+♥│d
oYGR∙U;hÆKK╖¶Γ░♥@;çî╗E▀▒l≥╢P←é☺úIÜjg┬B▒~╧(δä5@ᬽ°╛L♫`τge‼íK%}¬fµé' k▀ä▌∙⌐S▒
)j╨╫♂2uäü⌂ºb↨8⌡≤x╨0▒"┬♦▌ñ»♫↓╛PÖ╦;nΘ,Éû▒å,8╔â↕╡'<»≡:╜╫c╫Ü▒Φ·LΓô;µ¬☻░G■±èJδT☼╘{█É↨
xg▲zôVQ♠▼↨├)►c╢$²╓τzùvßπX♣^╜YkPà↑Θ{j¶╚½½`î0«Æ╓⌐Ä│↑.ì▬₧▌►S♥└►Ü[¿x┐6N]i╘UµtF↕_S▄↔Ä
↑¿²├L}y*┤╠═Ä╝÷┘╣1╨# üB{¬°S┌☻*'≤ñúä▌]ö§Üε,üª╬ú6▬Vu'¶Σ0╡k!╛ûúÖE*_%☺╗ö╟▄bε╜²╤{V¼╨╗√f├╖╡I▼┼≤≤∟[Θⁿ7n┤≥Ñ╠╗♫ÑÇ┬8
♦☼·Hæ▓☺#ΣìY>[µ╗`
Decoded message:
This module is a Perl-only implementation of the cryptographic cipher block chai
ning mode (CBC).
In combination with a block cipher such as DES or IDEA, you can encrypt and decr
ypt messages of arbitrarily long length.
The encrypted messages are compatible with the encryption format used by the Ope
nSSL package.
To use this module, you will first create a Crypt::CBC cipher object with new().
At the time of cipher creation, you specify an encryption key to use and, option
ally, a block encryption algorithm.
You will then call the start() method to initialize the encryption or decryption
process,
crypt() to encrypt or decrypt one or more blocks of data, and lastly finish(), t
o pad and encrypt the final block.
For your convenience, you can call the encrypt() and decrypt() methods to operat
e on a whole data value at once.
Testing if decode was successful...
Messages match - SUCCESS!
Press any key to continue . . .
Here is a sample perl script that goes through the motions of passing AES 256 key through an RSA public key encryption and then goes on to decrypt a message encrypted with the AES key.
The encrypted AES key and the encrypted message are both encoded in base64 for passing through email or other ASCII method of transfer.
I wrote this script as a learning tool to understand the AES and RSA methods. Other than that this script has no usefulness.
You may use this script in whole or part to further your understanding of cryptography methods.
I make no claims that this is the best way to accomplish passing a key to someone but it is a method. I also make no claims that this code is correct and welcome any comments/suggestions to improve the process, especially the generation of the AES key. I have no idea if the method I use is considered secure.
############################################################################
#!/usr/local/bin/perl
use strict;
use warnings;
use Crypt::CBC;
use MIME::Base64;
use Crypt::OpenSSL::RSA;
use Digest::SHA qw(sha1 sha1_hex sha1_base64 sha384 sha512 sha512_hex sha512_base64 sha256 sha256_hex sha256_base64 hmac_sha256 hmac_sha256_base64 hmac_sha256_hex hmac_sha512 hmac_sha512_base64);
use Bytes::Random::Secure qw(
random_bytes random_bytes_base64 random_bytes_hex
);
##############################################################################
#Generate the keys
##############################################################################
print "#######################################################################
# Generate the keys
#######################################################################\n\n";
my (%rsa_key_pair); #using a hash to store my private/public and other public keys. The hash itself is not encrypted but that is trivial to fix once we learn how to do it with AES
#also since this is a tutorial we generate a new set of keys each time the script is run - in the real world we'd need to dig these keys out of a key file stored on a drive
#this key file should also be encrypted with a passphrase (not discussed in this tutorial)
print "Generating RSA key pair...\n\n";
my $rsa = Crypt::OpenSSL::RSA->generate_key(2048);
my $keyidx = $rsa->get_public_key_string() if defined $rsa; #get the index of the key-pair
$keyidx = sha512_hex( $keyidx, "" ); #hash the index
$keyidx = substr( $keyidx, 0, 6 ); #shorten the hash to 6 digits
$rsa_key_pair{$keyidx}{'pubK'} = $rsa->get_public_key_string(); #load the hash
$rsa_key_pair{$keyidx}{'privK'} = $rsa->get_private_key_string();
$rsa_key_pair{$keyidx}{'Local'} = 1;
my $rsa_public_key = $rsa_key_pair{$keyidx}{'pubK'}; #set local key variables - not necessary but convenient
my $rsa_private_key = $rsa_key_pair{$keyidx}{'privK'};
#print $rsa_private_key; #print them if you want to see them
#print "\n\n";
#print $rsa_public_key;
#print "\n\n";
print "Generating AES key...\n\n";
my $random_generator = Bytes::Random::Secure->new(
Bits => 64,
NonBlocking => 1,
); # Seed with 64 bits, and use /dev/urandom (or other non-blocking).
my $AES32byte_random = $random_generator->bytes(32); # A string of 32 random bytes which we'll use as the AES key
print "AES32byte_random: ";
print $AES32byte_random;
print "\nSizeof AES32byte_random: ";
print length $AES32byte_random;
print "\n\n";
##############################################################################
#The encryption process
##############################################################################
print "#######################################################################
# The Encryption Process
#######################################################################\n\n";
my $RSA_en_cipher = Crypt::OpenSSL::RSA->new_public_key($rsa_public_key); #create a new public key cipher object
my $binary_encrypted_key = $RSA_en_cipher->encrypt($AES32byte_random); # encrypt the AES key
print "Binary encrypted key: \n";
print $binary_encrypted_key;
print "\n\n";
my $encoded_encrypted_key = encode_base64($binary_encrypted_key); #encode the encrypted AES key - encrypt and encode can be combined in one line - this is a tutorial
print "Encoded encrypted key: \n" . $encoded_encrypted_key . "\n\n";
#at this point send the encoded encrypted key to the private key holder via email or text message etc.
#the message to encrypt - why we're doing this exercise - well one of the reasons anyway
my $cleartext = "This module is a Perl-only implementation of the cryptographic cipher block chaining mode (CBC).
In combination with a block cipher such as DES or IDEA, you can encrypt and decrypt messages of arbitrarily long length.
The encrypted messages are compatible with the encryption format used by the OpenSSL package.
To use this module, you will first create a Crypt::CBC cipher object with new().
At the time of cipher creation, you specify an encryption key to use and, optionally, a block encryption algorithm.
You will then call the start() method to initialize the encryption or decryption process,
crypt() to encrypt or decrypt one or more blocks of data, and lastly finish(), to pad and encrypt the final block.
For your convenience, you can call the encrypt() and decrypt() methods to operate on a whole data value at once.";
#create the AES encryption cipher object
my $AES_en_cryption_cipher = Crypt::CBC->new(
{
'key' => $AES32byte_random,
'cipher' => 'Rijndael',
'padding' => 'standard',
});
my $AES_en_crypted_message = $AES_en_cryption_cipher->encrypt($cleartext); #encrypt the message
print "Encrypted message:\n";
print $AES_en_crypted_message;
print "\n\n";
my $encoded_AES_en_crypted_message = encode_base64($AES_en_crypted_message); #encode the encrypted message to send via email etc.
print "Encoded encrypted message:\n";
print $encoded_AES_en_crypted_message;
print "\n\n";
#Now pass the message via email etc. to the other person who should now have the AES key decrypted so they can now decrypt the message
##############################################################################
#The decryption process - this happens at the private keyholder's side - this is a tutorial
##############################################################################
print "#######################################################################
# The Decryption Process
#######################################################################\n\n";
#decode
print "Decoding keys...\n";
my $encoded_decryption_key = $encoded_encrypted_key; #just to keep the variables separate - this also simulates the passing of the encrypted key via email etc.
print "Encoded decryption key: \n" . $encoded_decryption_key . "\n\n";
my $binary_decryption_key = decode_base64($encoded_decryption_key); #decode the key into binary so we can decrypt it
print "Binary decryption key: \n" . $binary_decryption_key . "\n\n";
#decrypt
print "Decrypting keys...\n";
my $RSA_de_cipher = Crypt::OpenSSL::RSA->new_private_key($rsa_private_key); # create a new decryption cipher object using the PRIVATE key
my $binary_decrypted_key = $RSA_de_cipher->decrypt($binary_decryption_key); # decrypt the AES key
print "Binary decrypted key: \n" . $binary_decrypted_key . "\n\n\n"; #this should be the binary 256bit binary AES key
#let's test that
print "Testing AES key pass through RSA public key encryption:\n\n";
print $AES32byte_random . "\n\n - should equal - \n\n" . $binary_decrypted_key . "\n\n"; #print the two binary keys - do they line up? - visual compare
if ($AES32byte_random eq $binary_decrypted_key) #let the computer compare then too
{
print "\nSUCCESS!\n\n";
}
else
{
print "\nFAIL! Now exiting!\n\n";
exit;
}
print "Now to decrypt the message with the passed AES key...\n\n";
#create a new AES encryption cipher object
my $AES_de_cryption_cipher = Crypt::CBC->new(
{
'key' => $binary_decrypted_key, #uses the binary AES key we just decoded and decrypted
'cipher' => 'Rijndael', #aka AES
'padding' => 'standard', #padding is a good thing so we can use this key more than once
});
my $message_to_decode = $encoded_AES_en_crypted_message; #here is the simulated encrypted message send through email etc.
print "Encoded message to decrypt:\n";
print $message_to_decode;
print "\n\n";
$message_to_decode = decode_base64($message_to_decode); #decode into binary
print "Decoded message to decrypt:\n";
print $message_to_decode;
print "\n\n";
my $decoded_message = $AES_de_cryption_cipher->decrypt($message_to_decode); #decode the message
print "Decrypted message:\n"; #should be the same as the $cleartext variable above
print $decoded_message;
print "\n\n";
#let's test it
print "Testing if decode was successful...\n";
if ($decoded_message eq $cleartext)
{
print "\nMessages match - SUCCESS!\n\n";
}
else
{
print "\nMessages do NOT match - FAIL! Now exiting!\n\n";
exit;
}
exit;
###################################################################
#script run output
###################################################################
#######################################################################
# Generate the keys
#######################################################################
Generating RSA key pair...
Generating AES key...
AES32byte_random: g&ÿ}■·ºQ♂╚rF░%Y¡▀}╨;┐█¶Ñ3~Ç≡╞ª►▒
Sizeof AES32byte_random: 32
#######################################################################
# The Encryption Process
#######################################################################
Binary encrypted key:
←╖Ä ▼╣è♥à☻;XÉzMIè√0H0Ω↨í░ônö╔≈z▓|1§⌐╚£*∙V☼ªE≡9╧'N┬N/àb╨Xjgzƒ█l4▲{═☻√■W╬p☺╢7ê
x.╪K
z5♦!Éèê¡*ä■⌠╥B╨CGPoΘ╝îσxδ╬╜;>9q]‼ε/Vτúf7îª╢ö╞Ü9┤&A«O╓
âh#╛F░-å♠▒╬╣♂∞╙┴≥`£╣≡■ó╤
BΓû║áy\ìÅ░3╢╢@à╟AF╨▄Σ╕╞;╜⌂2/ëδ§"Hîw┤║↔![╠↨3Æ>↔]cQå«{¿╦¼↕à╜┬←ôMfñ╥╕╬ú.æB∞Σ<û
Encoded encrypted key:
G7eOCR+5igOFAjtYkHpNSYr7MEgw6hehsJNulMn3erJ8MRWpyJwq+VYPpkXwOc8nTsJOL4Vi0Fhq
Z3qf22w0HnvNAvv+V85wAbY3iHgu2EsKejUEIZCKiK0qhP700kLQQ0dQb+m8jOV46869Oz45cV0T
7i9W56NmN4ymtpTGmjm0JkGuT9YKg2gjvkawLYYHBrHOuQvs08HyYJy58P6i0QokOP/ysLmx35d7
9PWhkz0vKig1DULilrqgeVyNj7AztrZAhcdBRtDc5LjGO71/Mi+J6xUiSIx3tLodIVvMFzOSPh1d
Y1GGrnuoy6wShb3CG5NNZqTSuM6jLpFC7OQ8lg==
Encrypted message:
σgò↨ⁿ¼╖báv+▒É▼¡êΦáª#gJ¼èo[ÖiV▲ª╘kÖ7v»wQa╩0g-Σ└ÖfVÖ♫╢æù8àΣ§gìºφ=æBΦCJ│äÆw■σB0¥ 2╔
æm╫>Cí▐▼Äc!3☻æY(ß╥¡ΦEôéM┌á─o?íτt▄┌█¿§Σtφ{▓¥«ε╕p☺↓Ç=3╥61≡D╡√ÜW⌡αow╒╝√Q⌡ò⌐╘(↓‼Xw♠Ä
┴Ö☻ª{ë╔Z▓ε♀]o4Éc+♥_¡α(▬"ºH♂ë\&K┌d$☺/z☼▲╙☻¼┤à)Γ╒>,▀\█♂NÅ:,└┐∙φ&L☼!7☺;m╚¬h≈┴à▼+♥│d
oYGR∙U;hÆKK╖¶Γ░♥@;çî╗E▀▒l≥╢P←é☺úIÜjg┬B▒~╧(δä5@ᬽ°╛L♫`τge‼íK%}¬fµé' k▀ä▌∙⌐S▒
)j╨╫♂2uäü⌂ºb↨8⌡≤x╨0▒"┬♦▌ñ»♫↓╛PÖ╦;nΘ,Éû▒å,8╔â↕╡'<»≡:╜╫c╫Ü▒Φ·LΓô;µ¬☻░G■±èJδT☼╘{█É↨
xg▲zôVQ♠▼↨├)►c╢$²╓τzùvßπX♣^╜YkPà↑Θ{j¶╚½½`î0«Æ╓⌐Ä│↑.ì▬₧▌►S♥└►Ü[¿x┐6N]i╘UµtF↕_S▄↔Ä
↑¿²├L}y*┤╠═Ä╝÷┘╣1╨# üB{¬°
♦☼·Hæ▓☺#ΣìY>[µ╗`
Encoded encrypted message:
U2FsdGVkX1/gYdAOA7DFcM46bvXhGmWpamEwDYOfHLc436Fpu5OBDFXnNFsmzB+EsOGMy/G1MRMp
nPNCc0jqDlFRiJ0HycUVoBqRvOjU2l2Smnlrsh31DeVnlRf8rLdioHYrsZAfrYjooKYjZ0qsim9b
mWlWHqbUa5k3dq93UWHKMGct5MCZZlaZDraRlziF5BVnjaftBz2RQuhDSrOEknf+5UIwnQAyyb1n
mMIlDmaYNBPheHqs53hWQz+AyHQz3ZRAxSCmbQ2Rbdc+Q6HeH45jITMCkVko4dKt6EWTgk3aoMRv
P6HndNza26gV5HTte7Kdru64cAEZgD0z0jYx8ES1+5pX9eBvd9W8+1H1lanUKBkTWHcGjsGZAqZ7
iclasu4MXW/sCDSQYysDX63gKBYip0gLiVwmS9pkJAEveg8e0wKstIUp4tU+LN9c2wtOjzoswL/5
7SZMDyE3ATttyKpo98GFHysDs2RvWUdS+VU7aJJLS7cU4rADQDuHjLtF37Fs8rZQG4IBo0maamfC
QrF+zyjrhDVAoKqr+L5MDmDnZ2UToUslfapm5oInCWvfhN35qVOxKWrQ1wsydYSBf6diFzj183jQ
MLEiwgTdpK8OGb5Qmcs7bukskJaxhiw4yYMStSc8r/A6vddj15qx6PpM4pM7FAjmqgKwR/7xikrr
VA/Ue9uQF3hnHnqTVlEGHxfDKRBjtgck/dbnepd24eNYBV69WWtQhRjpe2oUyKurYIwwrpLWqY6z
GC6NFp7dEFMDwBCaW6h4vzZOXWnUVeZ0RhJfU9wdjhrVX+R73ZhoT7FMnLkoYsi8twMVshxE6xNO
GEAXgsiT38SUzD4GvBUsJ+ian36XVR1wnoKxeOjlwCn9RWVkrWazEld/B+MNGKj9w0x9eSq0zM2O
vPbZuTHQI/+BQnuq+DxmOePe+W5UyrIEoVSlE0C84aSJw73FL5px57xlWL6XMH7Z5LVXs51bI/j4
KCNeNgPqE62wHiFT2gIqJ/Oko4TdXZQVmu4sgabOozYWVnUnFOQwtWshvpajmUUqXyUBu5TH3GLu
vf3Re1as0Lv7ZsO3tUkfxfPzHFvp/DdutPKlzLsOpYDCOAQP+kiRsgEj5I1ZPlvmu2A=
#######################################################################
# The Decryption Process
#######################################################################
Decoding keys...
Encoded decryption key:
G7eOCR+5igOFAjtYkHpNSYr7MEgw6hehsJNulMn3erJ8MRWpyJwq+VYPpkXwOc8nTsJOL4Vi0Fhq
Z3qf22w0HnvNAvv+V85wAbY3iHgu2EsKejUEIZCKiK0qhP700kLQQ0dQb+m8jOV46869Oz45cV0T
7i9W56NmN4ymtpTGmjm0JkGuT9YKg2gjvkawLYYHBrHOuQvs08HyYJy58P6i0QokOP/ysLmx35d7
9PWhkz0vKig1DULilrqgeVyNj7AztrZAhcdBRtDc5LjGO71/Mi+J6xUiSIx3tLodIVvMFzOSPh1d
Y1GGrnuoy6wShb3CG5NNZqTSuM6jLpFC7OQ8lg==
Binary decryption key:
←╖Ä ▼╣è♥à☻;XÉzMIè√0H0Ω↨í░ônö╔≈z▓|1§⌐╚£*∙V☼ªE≡9╧'N┬N/àb╨Xjgzƒ█l4▲{═☻√■W╬p☺╢7ê
x.╪K
z5♦!Éèê¡*ä■⌠╥B╨CGPoΘ╝îσxδ╬╜;>9q]‼ε/Vτúf7îª╢ö╞Ü9┤&A«O╓
âh#╛F░-å♠▒╬╣♂∞╙┴≥`£╣≡■ó╤
BΓû║áy\ìÅ░3╢╢@à╟AF╨▄Σ╕╞;╜⌂2/ëδ§"Hîw┤║↔![╠↨3Æ>↔]cQå«{¿╦¼↕à╜┬←ôMfñ╥╕╬ú.æB∞Σ<û
Decrypting keys...
Binary decrypted key:
g&ÿ}■·ºQ♂╚rF░%Y¡▀}╨;┐█¶Ñ3~Ç≡╞ª►▒
Testing AES key pass through RSA public key encryption:
g&ÿ}■·ºQ♂╚rF░%Y¡▀}╨;┐█¶Ñ3~Ç≡╞ª►▒
- should equal -
g&ÿ}■·ºQ♂╚rF░%Y¡▀}╨;┐█¶Ñ3~Ç≡╞ª►▒
SUCCESS!
Now to decrypt the message with the passed AES key...
Encoded message to decrypt:
U2FsdGVkX1/gYdAOA7DFcM46bvXhGmWpamEwDYOfHLc436Fpu5OBDFXnNFsmzB+EsOGMy/G1MRMp
nPNCc0jqDlFRiJ0HycUVoBqRvOjU2l2Smnlrsh31DeVnlRf8rLdioHYrsZAfrYjooKYjZ0qsim9b
mWlWHqbUa5k3dq93UWHKMGct5MCZZlaZDraRlziF5BVnjaftBz2RQuhDSrOEknf+5UIwnQAyyb1n
mMIlDmaYNBPheHqs53hWQz+AyHQz3ZRAxSCmbQ2Rbdc+Q6HeH45jITMCkVko4dKt6EWTgk3aoMRv
P6HndNza26gV5HTte7Kdru64cAEZgD0z0jYx8ES1+5pX9eBvd9W8+1H1lanUKBkTWHcGjsGZAqZ7
iclasu4MXW/sCDSQYysDX63gKBYip0gLiVwmS9pkJAEveg8e0wKstIUp4tU+LN9c2wtOjzoswL/5
7SZMDyE3ATttyKpo98GFHysDs2RvWUdS+VU7aJJLS7cU4rADQDuHjLtF37Fs8rZQG4IBo0maamfC
QrF+zyjrhDVAoKqr+L5MDmDnZ2UToUslfapm5oInCWvfhN35qVOxKWrQ1wsydYSBf6diFzj183jQ
MLEiwgTdpK8OGb5Qmcs7bukskJaxhiw4yYMStSc8r/A6vddj15qx6PpM4pM7FAjmqgKwR/7xikrr
VA/Ue9uQF3hnHnqTVlEGHxfDKRBjtgck/dbnepd24eNYBV69WWtQhRjpe2oUyKurYIwwrpLWqY6z
GC6NFp7dEFMDwBCaW6h4vzZOXWnUVeZ0RhJfU9wdjhrVX+R73ZhoT7FMnLkoYsi8twMVshxE6xNO
GEAXgsiT38SUzD4GvBUsJ+ian36XVR1wnoKxeOjlwCn9RWVkrWazEld/B+MNGKj9w0x9eSq0zM2O
vPbZuTHQI/+BQnuq+DxmOePe+W5UyrIEoVSlE0C84aSJw73FL5px57xlWL6XMH7Z5LVXs51bI/j4
KCNeNgPqE62wHiFT2gIqJ/Oko4TdXZQVmu4sgabOozYWVnUnFOQwtWshvpajmUUqXyUBu5TH3GLu
vf3Re1as0Lv7ZsO3tUkfxfPzHFvp/DdutPKlzLsOpYDCOAQP+kiRsgEj5I1ZPlvmu2A=
Decoded message to decrypt:
σgò↨ⁿ¼╖báv+▒É▼¡êΦáª#gJ¼èo[ÖiV▲ª╘kÖ7v»wQa╩0g-Σ└ÖfVÖ♫╢æù8àΣ§gìºφ=æBΦCJ│äÆw■σB0¥ 2╔
æm╫>Cí▐▼Äc!3☻æY(ß╥¡ΦEôéM┌á─o?íτt▄┌█¿§Σtφ{▓¥«ε╕p☺↓Ç=3╥61≡D╡√ÜW⌡αow╒╝√Q⌡ò⌐╘(↓‼Xw♠Ä
┴Ö☻ª{ë╔Z▓ε♀]o4Éc+♥_¡α(▬"ºH♂ë\&K┌d$☺/z☼▲╙☻¼┤à)Γ╒>,▀\█♂NÅ:,└┐∙φ&L☼!7☺;m╚¬h≈┴à▼+♥│d
oYGR∙U;hÆKK╖¶Γ░♥@;çî╗E▀▒l≥╢P←é☺úIÜjg┬B▒~╧(δä5@ᬽ°╛L♫`τge‼íK%}¬fµé' k▀ä▌∙⌐S▒
)j╨╫♂2uäü⌂ºb↨8⌡≤x╨0▒"┬♦▌ñ»♫↓╛PÖ╦;nΘ,Éû▒å,8╔â↕╡'<»≡:╜╫c╫Ü▒Φ·LΓô;µ¬☻░G■±èJδT☼╘{█É↨
xg▲zôVQ♠▼↨├)►c╢$²╓τzùvßπX♣^╜YkPà↑Θ{j¶╚½½`î0«Æ╓⌐Ä│↑.ì▬₧▌►S♥└►Ü[¿x┐6N]i╘UµtF↕_S▄↔Ä
↑¿²├L}y*┤╠═Ä╝÷┘╣1╨# üB{¬°
♦☼·Hæ▓☺#ΣìY>[µ╗`
Decoded message:
This module is a Perl-only implementation of the cryptographic cipher block chai
ning mode (CBC).
In combination with a block cipher such as DES or IDEA, you can encrypt and decr
ypt messages of arbitrarily long length.
The encrypted messages are compatible with the encryption format used by the Ope
nSSL package.
To use this module, you will first create a Crypt::CBC cipher object with new().
At the time of cipher creation, you specify an encryption key to use and, option
ally, a block encryption algorithm.
You will then call the start() method to initialize the encryption or decryption
process,
crypt() to encrypt or decrypt one or more blocks of data, and lastly finish(), t
o pad and encrypt the final block.
For your convenience, you can call the encrypt() and decrypt() methods to operat
e on a whole data value at once.
Testing if decode was successful...
Messages match - SUCCESS!
Press any key to continue . . .
Sunday, March 30, 2014
924 QSOs on my 897D
It's been just over a year and I decided to inquire as to how many QSOs I've had on it.
In exactly 365 days since I first used it I've had 924 QSOs.
Running total so far is 956 QSOs, mostly digital and more specifically JT65HF.
Still missing 4 states and like 60 some-odd countries confirmed for WAS and DXCC.
Some day I'll pop the log in excel and work up some stats.
73
Friday, March 28, 2014
Mo' Power Mo' Power!
When it comes to JT65A and many other digital modes, more power is not always the answer!
Do you need to know how little power is really needed to make that QSO in JT65A?
http://dwestbrook.net/projects/ham/dBCalc
Many times I've seen -1dB signals on my waterfall, and that's just too much power.
Many times I've seen over-driven signals killing the entire pass-band. You just ruined an entire 60 second over for everyone.
If you're getting -10dB or stronger signal reports you are using too much power.
So you guys out there that brag about using "...40W 3EL..." (and more!) to make a continental QSO you can do it on 5watts or less. I DX on an OCF wire up at 24 feet on 20 watts.
Anyone listening?
*crickets*
Tuesday, March 25, 2014
Great Morse Code Tutorial
I've been learning Morse Code using the Koch method, and while it's the best method that works for me, I was getting board just repeating combinations of letters and would forgo my training sessions.
I decided to search the internet and see if there were any other methods to learn Morse Code and I stumbled across the CW Operators Club and their CW Academy. The next academy is not until Jan/Feb of 2015 (it's that popular and all booked up for this year!) and I couldn't wait that long to continue my training.
On their CW Academy Student Resources page I came across a link to a CW tutorial by Ron Brownstein of CWOps. It talks about using some program called Morse Code Trainer.
The Morse Code Trainer software is web/java based and is written by Stephen C Phillips. It follows the Koch principle but unlike other Koch software I have used before, they start introducing words using the letters you have just learned. In the first session alone you learn the words 'tea', 'tee', 'eat', 'ate', 'at', 'tat', 'teen', 'neat', 'ten', net, and 'tan'. How's that compared to boring repetitive strings of e, a, t, and n's?
So why is learning words important? Well for one, speed. If you only learn to recognize letters you limit your speed to how fast you can recognize individual letters. Once the speed gets up to where the dits and dahs run together you lose the ability to distinguish between the letters. If you learn to recognize the pattern or rhythm of the word instead of the letters you have just gained a lot of speed. The other important thing about learning words is proper Morse character spacing. If you only send letters equally spaced then that is what you get at the other end, a string of letters that you have to play a puzzle game with to form a sentence. But if you send words with spaces between the words you now have a proper sentence at the receiving end. The software starts you at 20wpm character and word spacing and I didn't find it hard follow along at that speed. So you can see already in session 1 you can copy and send words at 20wpm, a respectable speed for a beginner!
So what equipment have I been using to struggle through this learning process in place of CW Academy?
I am using my Yaesu 897D in CW mode but with BK turned off so I'm not transmitting and an old Vibroplex Original Standard bug (circa 1955) that belonged to my Grandfather. I have the sound from the radio headphone jack going in to the computer and have DM780 (Ham Radio Deluxe V5) listening to the audio so it translates the code into letters or more importantly words on the screen. I now know when my spacing is correct as sentences with words show up on the screen instead of a string of letters.
Using the bug to send along with Morse Code Trainer to learn the letters and words (that's how CW Academy does it) makes the process a lot more interesting for me and keeps me coming back for the training sessions. I may be too distracted by the bug as I find myself sending more than listening and my listening skills (at least to the live radio) seem to be lacking.
Session 1 as sent by the Morse Code Trainer software |
Having said that however, I am only on session 2 in the learning, so my vocabulary is still very small and I think that has a lot to do with it.
So I'll keep plugging away with this Morse Code Trainer software and see where it goes.
73, and who knows maybe we'll CW on the air sometime soon!
Saturday, March 15, 2014
Elmer Series - PROGRAMMING THE BAOFENG UV-B5 - 2
PROGRAMMING THE
BAOFENG UV-B5 - 2
In the previous post we discussed how a duplex repeater
system works and the parameters that need to be programmed into the radio in
order to access the repeater system, repeater output frequency, repeater
offset, offset direction, and CTCSS tone.
Now let’s program these into the radio.
I recommend you read through the steps first so you have an
idea what the procedure entails. I’ll
write up an abbreviated step guide further down to use once you get familiar
with the process so you don’t have to find the actual step amongst all the
text.
The first thing you need to do is to gather the required
information for the repeater you are trying to access.
The following parameters are for the EAARS
repeater located on MULE Mountain in Bisbee, AZ.
Output: 147.080
Offset: 00600
Offset Direction: +
CTCSS: 141.3
To make things easier right now I recommend we turn Voice
Prompts on and set it to ENGLISH. Once
you get familiar with the radio you will want to turn voice prompts off as it
get annoying after a while. Voice
prompts have their uses so turn them on when you want to use them.
Press the Menu button.
Rotate the VFO knob to Menu 09 (VOICE).
Press the AB button.
Rotate the VFO knob until ENGLIS is displayed on the screen
and a voice says “ON”.
Now we are going to set the radio to VFO mode so we can type
the output frequency into the radio.
1. Press the VM/Scan button to switch between memory and VFO modes. VFO mode is indicated when no channel number is displayed on the screen.
Now were going to type the frequency into the radio using
the keypad. You will only press number
keys, there is no need to enter any decimal point in the procedure.
2. Press the 1, 4, 7, 0, 8, 0 keys in that order. 147.080 should be displayed to the right of the arrow symbol on the LCD display.
Now were going to set the repeater offset amount.
3. Press the menu button and rotate the VFO knob to menu 22 (OFFSET) is displayed.
4. Press the AB button to edit that menu setting. The arrow should drop to the second line on the LCD display.
5. Now press the 0, 0, 6, 0, 0 buttons in that order. 00.600 should be displayed to the right of the arrow on the LCD display indicating the value is ready to be changed.
6. Press the Menu button to accept the value. 600kHz is now stored as the repeater offset.
Now were going to set the offset shift direction to +.
7. Press the menu button and rotate the VFO knob to menu 21 (SFTD).
8. Press the AB button to edit the menu setting. The arrow should drop to the second line on the LCD display indicating the value is ready to be changed.
9. Rotate the VFO knob until a + is displayed on the LCD display.
10. Press the menu button to store the value.
Now were going to set the CTCSS tone.
11. Press the menu button and rotate the VFO knob to menu 12 (T-CODE).
12. Press the AB button to edit the menu setting. The arrow should drop to the second line on the LCD display indicating the value is ready to be changed.
13. Press the menu key again to switch between CTCSS, DCSN, and DCSI. If you have voice prompts on turn the VFO knob slowly until the voice says “CTCSS”. A number should be displayed that does not have an N nor an I after it.
14. Rotate the VFO knob until 141.3 is displayed on the screen. If you are too slow in getting to 141.3 the radio may timeout and exit the menu system. If that happens, just repeat steps 11-14 again until you get to 141.3.
15. Press the Menu button to store the value.
One other setting we’ll need to ensure is set correctly is the FM bandwidth. It needs to be set to Wideband (WIDE).
16. Press the menu button.
17. Rotate the VFO knob to menu item 28 and the voice prompt says “Channel Bandwidth”.
18. Press the AB button to edit the menu setting.
19. Rotate the VFO knob until the display shows WIDE.
We now have all the parameters entered into the radio, however we now need to store them in a memory channel so they are stored permanently. If this is the first time storing information to a memory channel I recommend you use channel 1, but you can store in any channel you desire. If you have stored other frequencies into memory make sure you know what the next empty channel number is or the channel number of a channel you want to write over.
20. We first need to check that the frequency we entered earlier (147.080) is still displayed in the screen to the right of the arrow. If not, just press 1, 4, 7, 0, 8, 0 on the keypad again.
21. Press and hold the VM/Scan button until the voice prompts says “Memory Channel” or a channel number flashes on the LCD display above the arrow.
22. Rotate the VFO knob to the desired channel you want to store the repeater parameters too.
23. Press the VM/Scan button again and the voice prompt will respond with “Confirm” indicating the information was written to the memory channel.
Now were going to check that the parameters were stored correctly in memory.
24. Press the VM/Scan button until the voice says “Channel Mode” and a channel number displays above the arrow in the LCD display.
25. Rotate the VFO knob until the channel you just stored the information in is displayed on the screen. The voice prompt will say the channel number.
26. Ensure the LCD display indicates 147.080
27. The W symbol should be displayed indicating the radio is in FM Wideband.
28. The + symbol should be displayed indicating a positive offset shift.
To check the CTCSS, offset amount and shift direction we’ll need to enter the menu system to see them.
29. Press the Menu button.
30. Rotate the VFO knob to menu 22 (OFFSET) and the voice prompt says “Offset Frequency”.
31. Ensure it displays 00.600.
32. Rotate the VFO knob to menu to menu 21 (SFTD) and the voice prompt says “Frequency Direction”.
33. Ensure it displays the + symbol.
34. Rotate the VFO knob to menu 12 and the voice prompt says “CTCSS”.
35. Ensure it displays 141.3.
If any of the values are incorrect you will have to exit the
menu, change to VFO mode, and enter menu mode again and rotate the VFO knob to
the menu number that contains the incorrect value and change it. Once it is changed you will have to follow
steps 20 through 23 to save it again and overwrite the incorrect value.
That’s all there is to programming a repeater frequency into
the UV-B5 radio and checking it’s accuracy.
Here are the steps in sequence without all the explanation
included to make it easier to follow once you understand the steps above. If at
any time the radio times out and exits the menu mode, just hit the menu button
again and rotate the VFO knob to the desired menu number.
Entering the Repeater Information
1. Press the VM/Scan button to switch to VFO modes
2. Press the number keys to enter the repeaters output frequency
3. Press the menu button and rotate the VFO knob to menu 22 (OFFSET) is displayed
4. Press the AB button to edit that menu setting
5. Now press the number keys to enter the desired offset
6. Press the Menu button to accept the value
7. Rotate the VFO knob to menu 21 (SFTD)
8. Press the AB button to edit the menu setting
9. Rotate the VFO knob until a the desired shift is displayed on the LCD display
10. Press the menu button to store the value
11. Rotate the VFO knob to menu 12 (T-CODE)
12. Press the AB button to edit the menu setting
13. Press the menu key again to switch between CTCSS, DCSN, and DCSI
14. Rotate the VFO knob until the desired tone is displayed on the screen
15. Press the Menu button to store the value
16. Rotate the VFO knob to menu item 28 and the voice prompt says “Channel Bandwidth”
17. Press the AB button to edit the menu setting
18. Rotate the VFO knob until the display shows WIDE
Storing the Repeater Information in Memory
19. Check that the desired frequency is still displayed in the screen to the right of the arrow. If not, just enter it again.
20. Press and hold the VM/Scan button until the voice prompts says “Memory Channel” or a channel number flashes on the LCD display above the arrow.
21. Rotate the VFO knob to the desired channel you want to store the repeater parameters too.
22. Press the VM/Scan button again and the voice prompt will respond with “Confirm” indicating the information was written to the memory channel.
Checking the Stored Information
23. Press the VM/Scan button until the voice says “Channel Mode” and a channel number displays above the arrow in the LCD display.
24. Rotate the VFO knob until the channel you just stored the information in is displayed on the screen.
25. Ensure the LCD display indicates the repeater output frequency
26. The W symbol should be displayed indicating the radio is in FM Wideband
27. The + or - symbol should be displayed indicating the desired offset shift
28. Press the Menu button
29. Rotate the VFO knob to menu 22 (OFFSET) and the voice prompt says “Offset Frequency”
30. Ensure it displays the desired offset frequency
31. Rotate the VFO knob to menu to menu 21 (SFTD) and the voice prompt says “Frequency Direction”
32. Ensure it displays either the + or – symbol as desired
33. Rotate the VFO knob to menu 12 and the voice prompt says “CTCSS”
34. Ensure it displays the desired CTCSS tone
Labels:
Baofeng,
Elmer Series,
HT,
Programming Repeaters,
UV-B5
Elmer Series - PROGRAMMING THE BAOFENG UV-B5 - 1
PROGRAMMING THE
BAOFENG UV-B5 - 1
Programming the Baofeng UV-B5 from the keypad and radio menu
system is relatively easy and can be accomplished without using PC software
[edit]like unlike[/edit] some of the other Chinese radios.
To understand why we are programming the radio with the
settings we need to understand how a repeater operates.
A repeater is a radio system that retransmits signals that
it hears. There are two distinctively
different repeater types, simplex and duplex.
We’re not going to discuss simplex repeaters in this post
other than to say they listen and transmit on the same frequency and therefore
have to record the received signal and then retransmit the signal when the
received signal stops. The simplex system takes twice as long to send a message
than a duplex system.
The duplex repeater is more complex to setup and requires
special equipment which increases the cost.
However, it is the more popular system because it retransmits the
received signal as it’s being received.
In order for a duplex repeater to work it needs to operate
using two frequencies, one to listen to the received signal (repeater input
frequency) and one to re-transmit the received signal (repeater output frequency).
In the US the difference ( repeater offset) between the repeaters input and
output frequencies of the most common repeater bands are as follows:
- 6 meter (50MHz): 500kHz (negative offset)
- 2 meter (144MHz): 600kHz (positive or negative offset depending on repeater output)
- 70cm (440MHz): 5MHz (positive or negative offset depending on local conditions)
The repeater offset can either be shifted higher (positive
offset) or lower (negative offset) from the repeater output frequency. For the 6 meter (50MHz) band the offset is
usually negative. For the 2 meter
(144MHz) band the offset shift is based on what the output frequency is. For the 70cm (440MHz) band the offset shift
is determined by local conditions.
Because local interference or even a distant signal under
the right conditions can interfere with the repeater causing it to transmit
when it shouldn’t, most repeaters are set up to not transmit unless they also
receive a special signal. The most
common special signal used for this purpose is called Continuous Tone-Coded
Squelch System (CTCSS).
CTCSS is a
sub-audible (can’t be heard) tone that is transmitted along with the voice
signal and when the repeater hears the correct tone it will retransmit the
voice.
So now that we know the basics of how a duplex repeater
works and some of the settings (output frequency, repeater offset, offset
shift, CTCSS tone) that enable us to use a repeater system, let’s move on and
discuss how to program these settings into the Baofeng UV-B5.
Labels:
Baofeng,
Elmer Series,
HT,
Programming Repeaters,
UV-B5
Subscribe to:
Posts (Atom)