Using ePassport with Active/Chip Authentication to sign documents I'm a complete newby, so please pardon my ignorance when it comes to basic cryptography aspects. 

My question is whether a biometric passport with Active/Chip Authentication (AA or CA) can be used to generate digital signatures for docs (or rather their hashes). If so, is there any API available to do that? 

Thank you in advance for your feedback!
Active Authentication (AA henceforth) relies on RSA or ECDSA and allows you to sign data. However, as our is not meant to sign data you should not use it for that purpose.

First of all,  the only PKI that verifies the public key is that used for passive authentication of the passport - so you probably have to set up a separate PKI for it to be useful. Passive authentication simply embeds the public key in a "data group" which is then authenticated by a signature set by a country's signing certificate. However, the public key used is not in a certificate itself.

Second, the signing is used for passport authentication only and therefore does not require user confirmation / commitment such as  entering a PIN. Hence any reader with access to the contents of the passport is allowed access to the signing procedure, so having a signature does not prove user consent in any way.

The old AA algorithm uses the ISO/IEC 9796-2 signature scheme 1 giving message recovery. I've never been able to find out why (and I was directly involved), probably it was copied from some banking standard. Newer ones may use PSS as well. If 9796 is used then you might not be able to find too many parties that are able to verify the generated signature. AA is performed using the INTERNAL AUTHENTICATE command and is performed over RND.IFD which is specified for 8 bytes only, severely limiting input data.

If the passport still uses AA then you might also have a problem with the size of the keys. If you want to sign something for non-repudiation then you may want to have an RSA key size of 3072 bits or above. There aren't many smart cards that have the hardware for such large key sizes (at least not if you want to fit the other tens of pages of protocol spec in there as well).

In principle AA may use ECDSA, but it makes more sense for the country to use CA if that's the case. Finally, there may also be passports that use PACE-CAM, where the CA internal authentication is embedded in the initial authentication procedure.



For Chip Authentication (CA) the signature generation was considered a threat to the privacy of the user. A country could for instance use it to sign time and coordinates to create tracking.  That's why CA is based on Diffie-Hellman key agreement rather than a signature generation function. Unfortunately, that also makes it unavailable for signature generation.



Conclusion: it is next to impossible to use AA and CA for digital signatures  used for non-repudiation; AA was not designed to support such use case and CA was deliberately designed to avoid the use case. AA could be used to sign 8 bytes without user consent, but that's about it.

Besides the technological barriers, I'd certainly consider using AA or CA for anything other than (national) border control morally wrong. It should not be used even with consent, as any advantage that is gained can also be used to pressure people into using a passport for what it is not designed to do.