Skip to content

add dev tools to decode payloads and use crypt_shared#1172

Open
kevinAlbs wants to merge 2 commits into
mongodb:masterfrom
kevinAlbs:SKUNK-243
Open

add dev tools to decode payloads and use crypt_shared#1172
kevinAlbs wants to merge 2 commits into
mongodb:masterfrom
kevinAlbs:SKUNK-243

Conversation

@kevinAlbs
Copy link
Copy Markdown
Collaborator

This PR adds tools into libmongocrypt to (hopefully) benefit development:

  • call_crypt_shared.sh can process a command with the Crypt Shared library.
  • decode_payload.sh can decode a BSON binary subtype 6 payload.

Sample usage

The README.md files describe more usage.

To decode a payload:

./tools/decode_payload.sh --json ADgAAAAQYQABAAAABWtpABAAAAAEYWFhYWFhYWFhYWFhYWFhYQJ2AAwAAAA0NTctNTUtNTQ2MgAA
Output
{
    "name": "FLE1EncryptionPlaceholder",
    "dump": {
        "a": 1,
        "ki": {
            "$binary": {
                "base64": "YWFhYWFhYWFhYWFhYWFhYQ==",
                "subType": "04"
            }
        },
        "v": "457-55-5462"
    }
}

To process a command with crypt_shared:

export CRYPT_SHARED_LIB_PATH
./tools/call_crypt_shared.sh --cmd ./tools/call_crypt_shared/tests/find.yml
Output
{
    "hasEncryptionPlaceholders": true,
    "schemaRequiresEncryption": true,
    "result": {
        "find": "test",
        "filter": {
            "value": {
                "$eq": {
                    "$binary": {
                        "base64": "A1gAAAAQdAACAAAAEGEAAgAAAAVraQAQAAAABBI0VngSNJh2EjQSNFZ4kBIFa3UAEAAAAAQSNFZ4EjSYdhI0EjRWeJASEHYAQOIBABJjbQAAAAAAAAAAAAA=",
                        "subType": "06"
                    }
                }
            }
        },
        "encryptionInformation": {
            "type": {
                "$numberInt": "1"
            },
            "schema": {
                "test.test": {
                    "escCollection": "enxcol_.test.esc",
                    "ecocCollection": "enxcol_.test.ecoc",
                    "fields": [
                        {
                            "keyId": {
                                "$binary": {
                                    "base64": "EjRWeBI0mHYSNBI0VniQEg==",
                                    "subType": "04"
                                }
                            },
                            "path": "value",
                            "bsonType": "int",
                            "queries": {
                                "queryType": "equality",
                                "contention": {
                                    "$numberLong": "0"
                                }
                            }
                        }
                    ]
                }
            }
        }
    }
}

@kevinAlbs kevinAlbs requested a review from mdb-ad May 15, 2026 18:48
@kevinAlbs kevinAlbs requested a review from a team as a code owner May 15, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant