Skip to content

"Warning, state of non-volatile memory is unchanged." when trying to configure static password or delete slot. #48

@MartinTeichler

Description

@MartinTeichler

Hello,

I get the above error when trying to configure a static password or delete a slot. This error happens only when I proceed in a specific way:

  1. Configure a static password using the last example from this PDF (version 2.2):

     // Clear current settings.
     yk.ykClear();
    
     // Use selected config.
     yk.ykFlagProperty(ykFlagProperty.SECOND_CONFIG) = (slot == 2);
    
     // Don't append enter at the end.
     yk.ykFlagProperty(ykFlagProperty.APPEND_CR) = false;
    
     // Use static password mode => output scancodes (as opposed to modhex).
     yk.ykFlagProperty(ykFlagProperty.STATIC_TICKET) = false;
    
     // Use short ticket.
     yk.ykFlagProperty(ykFlagProperty.SHORT_TICKET) = true;
    
     // Encode plain text into keyboard scan codes.
     var scanCodes = text2scancode(input);
    
     // Split key to fit in various yubikey properties.
     var key1 = scanCodes.substr(0, FIXED_SIZE * 2);
     var key2 = scanCodes.substr(FIXED_SIZE * 2, UID_SIZE * 2);
     var key3 = scanCodes.substr(FIXED_SIZE * 2 + UID_SIZE * 2);
    
     // Set key parts.
     yk.ykStaticId = key1;
     yk.ykUID = key2;
     yk.ykKey = key3;
    
     // Write config to YubiKey.
     var programResult = yk.ykProgram;
    
  2. Without removing the Yubikey, use the current .Net SDK to configure a static password:

     public void SendStaticPasswordToYubikey(IYubiKeyDevice yubikey, Memory<char> payload, int slot)
     {
         if (slot != 1 && slot != 2)
             throw new ArgumentException($"{nameof(slot)} has to be either 1 or 2.");
    
         using (var otp = new OtpSession(yubikey))
         {
             var castSlot = (Slot)slot;
    
             if (castSlot == Slot.LongPress && otp.IsLongPressConfigured)
                 otp.DeleteSlot(Slot.LongPress);
             else if(castSlot == Slot.ShortPress && otp.IsShortPressConfigured)
                 otp.DeleteSlot(Slot.ShortPress);
    
             otp.ConfigureStaticPassword((Slot)slot)
                 .WithKeyboard(KeyboardLayout.en_US)
                 .SetPassword(payload)
                 .Execute();
         }
     }
    

The call to Execute will throw the above error. Is there any way to "fix" this? I tried deleting the slot, but I get the same error. The only way to make it go away is to delete the slot (which leads to the above error) and restart the program. After that, it will write to the key successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting replyWhen we are waiting for response from user

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions