09-03-2025 01:52 PM
Hi, all:
I recently encounter one thing which I do not understand.
My vendor's device yang has the following:
leaf secret-key
{
tailf:info "Secret key string shared for a connection";
type tailf:aes-256-cfb-128-encrypted-string;
mandatory true;
}
I set the secret-key to "Hello World!" in FASTMAP.
But when I do dry-run or actually applyTrans
I see
for dry-run:
+ secret-key $9$VLjeFOYX6YJBjQH68ulnt1SMT6joLrmXfqIz4Bq76Xg=
for applyTrans the trace log
<edit-config>
:
:
<secret-key>$9$VLjeFOYX6YJBjQH68ulnt1SMT6joLrmXfqIz4Bq76Xg=</secret-key>
I checked tailf-common.yang, aes-256-cfb-128-encrypted-string is:
typedef aes-256-cfb-128-encrypted-string {
type string;
description
"The aes-256-cfb-128-encrypted-string works exactly like
des3-cbc-encrypted-string but AES/256bits in CFB mode is used to
encrypt the string. The prefix for encrypted values is '$9$'.";
}
it is a string.
I wonder where the $9$VLjeFOYX6YJBjQH68ulnt1SMT6joLrmXfqIz4Bq76Xg= value come from? How does NSO know to encrypt the plain-text "Hello World!"
THX
sm000x
Solved! Go to Solution.
09-04-2025 01:48 AM
Hello @sm000x,
looking at the Cisco NSO Docs: Encrypted Strings you will find:
"By using the NSO built-in encrypted YANG extension types tailf:aes-cfb-128-encrypted-string or tailf:aes-256-cfb-128-encrypted-string, it is possible to store encrypted string values in NSO that can be decrypted."
The YANG type aes-256-cfb-128-encrypted-string signals to NSO that any input value should be encrypted using the AES-256 algorithm, CFB mode, with 128-bit segments.
So when you enter plaintext (like "Hello World!") in the UI or via API, NSO automatically encrypts this value prior to storing or displaying it in configuration. For this purpose NSO uses its internal encryption engine and the master key managed in the system configuration. The encrypted string is then prefixed with $9$ to indicate its encoding type.
Any output will show this base64-encoded ciphertext, e.g. $9$VLjeFOYX6YJBjQH68ulnt1SMT6joLrmXfqIz4Bq76Xg=, as stored in the configuration for security reasons.
HTH!
09-04-2025 05:01 AM
Hi @sm000x,
NSO knows the master key used for encryption and the $9$ prefix indicates the encoding type.
Therefore, NSO is able to decrypt the base64-encoded ciphertext at any time as needed.
So the cleartext is only processed internally by NSO and any output will always show the encoded ciphertext.
HTH!
09-04-2025 01:48 AM
Hello @sm000x,
looking at the Cisco NSO Docs: Encrypted Strings you will find:
"By using the NSO built-in encrypted YANG extension types tailf:aes-cfb-128-encrypted-string or tailf:aes-256-cfb-128-encrypted-string, it is possible to store encrypted string values in NSO that can be decrypted."
The YANG type aes-256-cfb-128-encrypted-string signals to NSO that any input value should be encrypted using the AES-256 algorithm, CFB mode, with 128-bit segments.
So when you enter plaintext (like "Hello World!") in the UI or via API, NSO automatically encrypts this value prior to storing or displaying it in configuration. For this purpose NSO uses its internal encryption engine and the master key managed in the system configuration. The encrypted string is then prefixed with $9$ to indicate its encoding type.
Any output will show this base64-encoded ciphertext, e.g. $9$VLjeFOYX6YJBjQH68ulnt1SMT6joLrmXfqIz4Bq76Xg=, as stored in the configuration for security reasons.
HTH!
09-04-2025 04:17 AM
Hi, Jens:
Thank you so very much for the explanation. This is very helpful.
Thank you
sm000x
09-04-2025 04:49 AM
09-04-2025 05:01 AM
Hi @sm000x,
NSO knows the master key used for encryption and the $9$ prefix indicates the encoding type.
Therefore, NSO is able to decrypt the base64-encoded ciphertext at any time as needed.
So the cleartext is only processed internally by NSO and any output will always show the encoded ciphertext.
HTH!
09-04-2025 05:11 AM
09-04-2025 05:43 AM
You're welcome! We are here to help.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide