Fidelio, Act Two

As promised, here is my adaption of the second act of Beethoven‘s one and only opera Fidelio. Read the first act if you haven’t already.

Scene 1

Florestan: Shit, it’s really dark in here. It’s a good thing I’m really, really righteous and brave! I just hope Leonore is OK.

Scene 2

Fidelionore: Brr, it’s cold as balls down here.

Rocco: Sorry, Pizarro must have forgotten to pay the electricity bill. Anyway, here we are.

Fidelionore: He’s not moving!

Rocco: You think he’s dead? Nah, just asleep. Help me dig. You scared?

Fidelionore: Just cold. Sorry.

Rocco: Start digging, it’ll keep you warm.

They dig.

Fidelionore: I think he’s waking up!

Rocco: Get out of here, I need to talk to him.

Florestan: I have been imprisoned here for over two years, and surely I must know where I am and what has happened, but the audience wasn’t here, so please pretend I don’t know, and tell me who is keeping me here.

Rocco: Pizarro, and believe me, I like him about as much as you do.

Florestan: Pizarro? Shit. Send word to Sevilla, let my wife know where I am!

Rocco: Sorry, bud, no can do. I brought some wine to dull the pain of digging another man’s grave, want a drop?

Florestan: Why the hell not.

Rocco: Fidelio, bring the wine! Hey, you don’t look too good.

Florestan: Poor kid!

Fidelionore: I don’t feel too good.

Rocco: Look, it sucks that he’s going to die, but I’m only following orders.

Fidelionore: Want some stale bread? I’ve been carrying this around for days instead of grabbing a fresh piece at the breakfast table every morning.

Rocco: I am about to become complicit in an innocent man’s death, but it’s all good because I’m only following orders, plus I gave him some wine.

Florestan: I am sorry that I cannot repay you for bringing me a stale piece of bread and the dregs of your wine after you were done digging my grave.

Rocco: Okiedokie, off to tell Pizarro everything is ready.

Fidelionore: Don’t worry, it’ll all work out. Somehow. Maybe. I hope.

Scene 3

Pizarro: All done?

Rocco: All done.

Pizarro: Send the kid away and untie the prisoner while I gloat over his impending doom and make sure to let him know at whose hand it will come.

Florestan: Murderer!

Fidelionore: Murderer!

Rocco: Just following orders.

Fidelionore throws herself between Pizarro and Florestan

Fidelionore: You’ll have to kill me first!

Pizarro: Wut?

Fidelionore: I’m his wife, dumbass. Did nobody notice the hips and the tits and the fact that I’m a ducking soprano?

Pizarro: You’re his wife?

Rocco: You’re his wife?

Florestan: You’re my wife?

Pizarro: Wow, you’re really brave.

Rocco: Wow, you’re really brave.

Florestan: Wow, you’re really brave.

Pizarro: Shit, now I have to kill them both.

Fidelionore: Well, sucks to be you.

The alarm sounds.

Fidelionore: You’re saved!

Florestan: I’m saved?

Pizarro: Shit, Fernando!

Rocco: We’re saved!

Scene 4

Jaquino: Hey boss, Secretary Fernando has arrived.

Rocco: Send the guards down to, eh, ensure Pizarro gets safely up the stairs.

Fidelionore & Florestan: We’re saved!

Pizarro: I’m doomed!

Rocco: Remember, I was only following orders!

Scene 5

Fidelionore: You’re saved!

Florestan: We gonna frick!

Scene 6

Prisoners: We’re free!

Fernando: The King has sent me to free you!

Prisoners: Bonus heart-wrenching chorus!

Scene 7

Rocco: Help! Help!

Pizarro: Shut up!

Fernando: What’s all this then?

Rocco: Have mercy on Florestan—

Fernando: Florestan? Isn’t he dead?

Rocco: Only mostly dead. There’s a big difference between mostly dead and all dead. Mostly dead is slightly alive.

Fernando: Florestan is slightly alive?


Rocco: …with his wife Leonore! Dressed as a man!

Marzelline: Oh shit.

Rocco: Pizarro was going to murder him!

Pizarro: And I would have gotten away with it too, if it weren’t for that meddling kid! Besides, you were helping.

Rocco: For the last time, I was only following orders!

Pizarro is arrested and taken away

Fernando: Here, Leonore, unshackle your husband.

Everybody: WE’RE SO HAPPY!

Florestan: Let this be a lesson to you all, the righteous always prevail in the end!

Fidelionore: Not to mention Tru Wuv.

Everybody: Yeah, yeah, we’re all very impressed.

Fidelionore: We gonna frick!


Thank you, you’ve been a lovely audience.

Fidelio, Act One

I went to see a concert version of Fidelio at the Norwegian National Opera last night. For those of you who aren’t well versed in opera or in the classical or romantic eras of Western music, Fidelio is Beethoven‘s only opera; initially written in 1804 under the title Leonore, oder Der Triumph der ehelichen Liebe, it took ten years and numerous rewrites before it became what we know today as Fidelio. I know Fidelio quite well, having owned a copy of Karajan’s 1970 recording since my teens, but never really paid attention to the lyrics as a whole until I saw it on stage. I was mildly surprised at how progressive and (in places) possibly even scandalous they are, for their time. They deserve wider recognition. So without further ado, I present my abridged and somewhat… improved version of the libretto.


Two years ago, Florestan uncovered evidence of his rival Pizarro’s crimes. Since then, he has been illegally detained by the latter in the prison he governs. Florestan’s wife Leonore has tracked Florestan down and obtained employment at the prison, disguised as a young man named Fidelio (because opera, that’s why). She has gradually gained warden Rocco’s trust. Prison guard Jaquino is infatuated with Rocco’s daughter Marzelline, who is infatuated with Fidelio (because opera, that’s why).

Scene 1

Jaquino: Finally got you cornered! I need to talk to you.

Marzelline: Dude, I got work to do.

Jaquino: Come on, give a guy a break!

Marzelline: OK, spit it out. Just don’t expect me to like it.

Jaquino: I’ve decided that you are to be my wife. We can have the wedding in a few weeks.

Marzelline: LOL WUT

someone knocks


Marzelline: Dude, I don’t even like you. I’m in love with Fidelio.

Jaquino: What can I do to convince you?

knocking intensifies

Marzelline: Good, maybe he’ll let me go now.

Rocco (off-stage): Jaquino, you lazy good-for-nothing, get back to work!

Marzelline: You heard the man, now scram!

Jaquino leaves

Marzelline: Poor guy. I used to like him until I met Fidelio. Now there’s a man in touch with his feminine side!

Scene 2

Marzelline pines for Fidelio

Scene 3

Rocco: Where the f— is Fidelio?

Marzelline: Hell if I know. Oh, wait, there he is!

Scene 4

Fidelionore: Sorry, boss. Dude took forever. Here’s the receipt.

Rocco: Wow, how’d you talk the price down so much?

Fidelionore: I try my best, boss.

Rocco: Good man. Don’t worry, you’ll get what you’re after.

Fidelionore: Say what now?

Rocco: Oh come on, I know you like Marzelline.


Fidelionore: Oh shit.

Rocco: I’m so happy for them!

Jaquino: Oh shit.

Rocco: Good, then it’s settled! We can have the wedding as soon as that ass Pizarro leaves for Sevilla.

Marzelline: Squee!

Rocco: One thing though, Fidelio. Promise me you’ll provide for my daughter. Love means nothing if you can’t put food on the table. Gold, gold, gold, gold, gold, gold, gold!

Fidelionore: Well, I still maintain that true love… but there’s one thing that bothers me. Why don’t you trust me to accompany you down to the lower cells?

Rocco: It’s not that I don’t trust you, it’s that I’m not allowed to let anyone near them.

Fidelionore: But you work your fingers to the bone! Let me help.

Rocco: Well, maybe. But I won’t let you near the oubliette. It’s too gruesome.

Marzelline: Is that where the secret prisoner is kept?

Fidelionore: Has he been there long?

Rocco: Two years. And now Pizarro has ordered me to let him starve in the dark.

Marzelline: Please don’t take Fidelio there, it’ll break his heart!

Fidelionore: Are you calling me a wuss?

Rocco: You need guts to get ahead in life, boy.

Fidelionore: I got plenty. Try me.

Marzelline: Your determination to see a man being starved to death makes me inexplicably proud.

Rocco: Fine! I’ll ask the governor to allow you to assist me. I’m working myself to death as it is.

Marzelline: I am so turned on right now.

Scene 5

Pizarro storms in from who knows where

Pizarro: Man the walls! Let no-one in without my express permission. Rocco, bring me my mail!

Rocco: Here, sir.

Pizarro: Bill—bill—advertising—overdue bill—Sears catalogue—final notice—pre-approved credit card—oh shit, I know that letterhead. “It has come to my attention that you are illegally keeping political prisoners, and I am therefore conducting a surprise inspection. You have a few hours to hide the evidence. XOXO Fernando.” Holy shit, he and Florestan were like besties. Captain! Post guards and sound the alarm the moment you see Secretary Fernando’s limo arrive!

Captain: Sir, yes, sir!

Pizarro: The only thing that can save me now is an act of unsurpassed bravery. And I will finally have my revenge, which I could have had at any time in the two years this man has been my prisoner, but inexplicably postponed! Oh, I can’t wait to see the knife twist in his heart! Rocco!

Rocco: Sir?

Pizarro: Rocco, I want you to prove my bravery, courage and high moral conviction by murdering this man in my place.

Rocco: Let’s not, and say we did.

Pizarro: Wuss. Never mind, I’ll do it myself. Go dig his grave while I put on an unconvincing disguise so I can tell myself it wasn’t really me who did it. And God help you if I get blood on my shoes!

Rocco: Oh well. At least he won’t starve any more.

Scene 6

Fidelionore: WHAT THE F— JUST HAPPENED? I have to stop this.

Scene 7

Jaquino: Marzelline! You used to love me, but ever since this Fidelio…

Marzelline: Leave me alone!

Scene 8

Rocco: Let it go, son. She doesn’t want you.

Fidelionore: Rocco, won’t you please let the prisoners out into the sun? Pizarro doesn’t need to know.

Rocco: Oh, why the hell not. Jaquino, Fidelio, open the upper cells!

Scene 9

Prisoners: Watch as we march dramatically out of our cells and sing a heart-wrenching chorus about how bad it is to imprison people for their political opinions! But not too loud, someone might hear us.

Scene 10

Fidelionore: How did it go?

Rocco: He agreed to the wedding and to let you accompany me to the lower cells.

Fidelionore: O frabjous day! Callooh! Callay!

Rocco: What are you going on about? Anyway, we have to go down to the secret prisoner.

Fidelionore: Is he being released?

Rocco: Released? Oh, no, we are to bury him.

Fidelionore: What?! He’s dead?

Rocco: Well, not quite yet…


Rocco: No, just dig his grave and wash my hands of his murder.

Fidelionore starts crying

Rocco: Oh, grow up. Let’s go.

Scene 11

Marzelline: Dad! Dad! Pizarro is looking for you, and let me tell you, he is PISSED. The guard captain told him we let the prisoners out. You know how mad he gets…

Rocco: Oh shit. Quick, get everybody back inside.

Scene 12

Pizarro: Rocco! ROCCO! Who the FRACK gave you permission to let the prisoners out?

Rocco: Well, uh, it’s, uh, spring, and also the King’s birthday or something? Also, I only let the regular prisoners out, not the secret one.

Pizarro: Oh, shut up, and go dig that grave.

Prisoners: We’re really sad to have to go back inside.

Marzelline: I’m really sad to see the prisoners go back inside.

Fidelionore: I’m really sad to see the prisoners go back inside.

Jaquino: Oh, screw them.

Pizarro: Off you go, Rocco, and stay there until the deed is done.

End of Act One

I’ll post Act Two as soon as that ass Pizarro leaves for Sevilla.

Update: Act Two

Not up to our usual standards

For a few years now, I’ve been working on and off on a set of libraries which collect cryptography- and security-related code I’ve written for other projects as well as functionality which is not already available under a permissive license, or where existing implementations do not meet my expectations of cleanliness, readability, portability and embeddability.

(Aside: the reasons why this has taken years, when I initially expected to publish the first release in the spring or summer of 2014, are too complex to explain here; I may write about them at a later date. Keywords are health, family and world events.)

Two of the major features of that collection are the OATH Authentication Methods (which includes the algorithm used by Google Authenticator and a number of commercial one-time code fobs) and the Common Platform Enumeration, part of the Security Content Automation Protocol. I implemented the former years ago for my employer, and it has languished in the OpenPAM repository since 2012. The latter, however, has proven particularly elusive and frustrating, to the point where it has existed for two years as merely a header file and a set of mostly empty functions, just to sketch out the API. I decided to have another go at it yesterday, and actually made quite a bit of progress, only to hit the wall again. And this morning, I realized why.

The CPE standard exists as a set of NIST Interagency reports: NISTIR 7695 (naming), NISTIR 7696 (name matching), NISTIR 7697 (dictionary) and NISTIR 7698 (applicability language). The one I’ve been struggling with is 7695—it is the foundation for the other three, so I can’t get started on them until I’m done with 7695.

It should have been a breeze. On the surface, the specification seems quite thorough: basic concepts, representations, conversion between representations (including pseudocode). You know the kind of specification that you can read through once, then sit down at the computer, start from the top, and code your way down to the bottom? RFC 4226 and RFC 6238, which describe OATH event-based and time-based one-time passwords respectively, are like that. NISTIR 7695 looks like it should be. But it isn’t. And I’ve been treating it like it was, with my nose so close to the code that I couldn’t see the big picture and realize that it is actually not very well written at all, and that the best way to implement it is to read it, understand it, and then set it aside before coding.

One sign that NISTIR 7695 is a bad specification is the pseudocode. It is common for specifications to describe algorithms, protocols and / or interfaces in the normative text and provide examples, pseudocode and / or a reference implementation (sometimes of dubious quality, as is the case for RFC 4226 and RFC 6238) as non-normative appendices. NISTIR 7695, however, eschews natural-language descriptions and includes pseudocode and examples in the normative text. By way of example, here is the description of the algorithm used to convert (“bind”, in their terminology) a well-formed name to a formatted string, in its entirety: Summary of algorithm

The procedure iterates over the eleven allowed attributes in a fixed order. Corresponding attribute values are obtained from the input WFN and conversions of logical values are applied. A result string is formed by concatenating the attribute values separated by colons.

This is followed by one page of pseudocode and two pages of examples. But the examples are far from exhaustive; as unit tests, they wouldn’t even cover all of the common path, let alone any of the error handling paths. And the pseudocode looks like it was written by someone who learned Pascal in college thirty years ago and hasn’t programmed since.

The description of the reverse operation, converting a formatted string to a well-formed name, is slightly better in some respects and much worse in others. There is more pseudocode, and the examples include one—one!—instance of invalid input… but the pseudocode includes two functions—about one third of the total—which consist almost entirely of comments describing what the functions should do, rather than actual code.

You think I’m joking? Here is one of them:

function get_comp_fs(fs,i)
  ;; Return the i’th field of the formatted string. If i=0,
  ;; return the string to the left of the first forward slash.
  ;; The colon is the field delimiter unless prefixed by a
  ;; backslash.
  ;; For example, given the formatted string:
  ;; cpe:2.3:a:foo:bar\:mumble:1.0:*:...
  ;; get_comp_fs(fs,0) = "cpe"
  ;; get_comp_fs(fs,1) = "2.3"
  ;; get_comp_fs(fs,2) = "a"
  ;; get_comp_fs(fs,3) = "foo"
  ;; get_comp_fs(fs,4) = "bar\:mumble"
  ;; get_comp_fs(fs,5) = "1.0"
  ;; etc.

This function shouldn’t even exist. It should just be a lookup in an associative array, or a call to an accessor if the pseudocode was object-oriented. So why does it exist? Because the main problem with NISTIR 7695, which I should have identified on my first read-through but stupidly didn’t, is that it assumes that implementations would use well-formed names—a textual representation of a CPE name—as their internal representation. The bind and unbind functions, which should be described in terms of how to format and parse URIs and formatted strings, are instead described in terms of how to convert to and from WFNs. I cannot overstate how wrong this is. A specification should never describe a particular internal representation, except in a non-normative reference implementation, because it prevents conforming implementations from choosing more efficient representations, or representations which are better suited to a particular language and environment, and because it leads to this sort of nonsense.

So, is the CPE naming specification salvageable? Well, it includes complete ABNF grammars for URIs and formatted strings, which is good, and a partial ABNF grammar for well-formed names, which is… less good, but fixable. It also explains the meanings of the different fields; it would be useless otherwise. But apart from that, and the boilerplate at the top and bottom, it should be completely rewritten, including the pseudocode and examples, which should reference fictional, rather than real, vendors and products. Here is how I would structure it (text in italic is carried over from the original):

  1. Introduction
    1.1. Purpose and scope
    1.2. Document structure
    1.3. Document conventions
    1.4. Relationship to existing specifications and standards
  2. Definitions and abbreviations
  3. Conformance
  4. CPE data model
    4.1 Required attributes
    4.2 Optional attributes
    4.3 Special attribute values
  5. Textual representations
    5.1. Well-formed name
    5.2. URI
    5.3. Formatted string
  6. API
    6.1. Creating and destroying names
    6.2. Setting and getting attributes
    6.3. Binding and unbinding
  7. Non-normative examples
    7.1. Valid and invalid attribute values
    7.2. Valid and invalid well-formed names
    7.3. Valid and invalid URIs
    7.4. Valid and invalid formatted strings
  8. Non-normative pseudo-code
  9. References
  10. Change log

I’m still going to implement CPE naming, but I’m going to implement it the way I think the standard should have been written, not the way it actually was written. Amusingly, the conformance chapter is so vague that I can do this and still claim conformance with the Terrible, Horrible, No Good, Very Bad specification. And it should only take a few hours.

By the way, if anybody from MITRE or NIST reads this and genuinely wants to improve the specification, I’ll be happy to help.

PS: possibly my favorite feature of NISTIR 7695, and additional proof that the authors are not programmers: the specification mandates that WFNs are UTF-8 strings, which are fine for storage and transmission but horrible to work with in memory. But in the next sentence, it notes that only characters with hexadecimal values between x00 and x7F may be used, and subsequent sections further restrict the set of allowable characters. In case you didn’t know, the normalized UTF-8 representation of a sequence of characters with hexadecimal values between x00 and x7F is identical, bit by bit, to the ASCII representation of the same sequence.

How to solve every problem in the world

  1. Identify a complex problem in country A which is deeply rooted in that country’s demography / economy / culture / political system.
  2. Point out that country B, which has a completely different demography / economy / culture / political system, does not have that problem or has found a simple solution to it.
  3. Declare that the problem is trivial and that country A are idiots for having it in the first place.
  4. Job done, have a beer.

FreeBSD and CVE-2015-7547

As you have probably heard by now, a buffer overflow was recently discovered in GNU libc’s resolver code which can allow a malicious DNS server to inject code into a vulnerable client. This was announced yesterday as CVE-2015-7547. The best sources of information on the bug are currently Google’s Online Security Blog and Carlos O’Donnell’s in-depth analysis.

Naturally, people have started asking whether FreeBSD is affected. The FreeBSD Security Officer has not yet released an official statement, but in the meantime, here is a brief look at the issue as far as FreeBSD is concerned.

Continue reading “FreeBSD and CVE-2015-7547” »