Sphere Mask

I see there is a sphere mask node and it works great but I was wondering if there is an equivalent for making something like a cube mask? Basically I want the same effect of the cube mask but using a different shape to mask with.

You can rebuild a cube equivalent with nodes this way:

For A/B vectors with 3 components change the setup to: http://abload.de/img/boxmask02gjs55.png

Any ideas on how to add a rotation to this?

fwiw there has been box mask 3d and box mask 2d in the engine for quite some time now. Just look for them in the material function list. I believe they were added around 4.7 or 4.8?